@@ -0,0 +1,93 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Charts module. | |||
|
8 | ** | |||
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |||
|
10 | ** accordance with the Qt License Agreement provided with the Software | |||
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |||
|
12 | ** agreement between you and The Qt Company. | |||
|
13 | ** | |||
|
14 | ** If you have questions regarding the use of this file, please use | |||
|
15 | ** contact form at http://qt.io | |||
|
16 | ** | |||
|
17 | ****************************************************************************/ | |||
|
18 | ||||
|
19 | import QtQuick 2.0 | |||
|
20 | import QtTest 1.0 | |||
|
21 | import QtCharts 2.0 | |||
|
22 | ||||
|
23 | Rectangle { | |||
|
24 | width: 400 | |||
|
25 | height: 300 | |||
|
26 | ||||
|
27 | TestCase { | |||
|
28 | id: tc1 | |||
|
29 | name: "tst_qml-qtquicktest CategoryAxis" | |||
|
30 | when: windowShown | |||
|
31 | ||||
|
32 | function test_minMax() { | |||
|
33 | compare(lineSeries1.axisX.min, 0, "AxisX min"); | |||
|
34 | compare(lineSeries1.axisX.max, 10, "AxisX max"); | |||
|
35 | compare(lineSeries1.axisY.min, 0, "AxisY min"); | |||
|
36 | compare(lineSeries1.axisY.max, 10, "AxisY max"); | |||
|
37 | } | |||
|
38 | ||||
|
39 | function test_categories() { | |||
|
40 | compare(lineSeries1.axisY.startValue, 0, "AxisY start value"); | |||
|
41 | compare(lineSeries1.axisY.count, 3, "AxisY count"); | |||
|
42 | compare(lineSeries1.axisY.categoriesLabels[0], "label0", "AxisY categories labels"); | |||
|
43 | compare(lineSeries1.axisY.categoriesLabels[1], "label1", "AxisY categories labels"); | |||
|
44 | compare(lineSeries1.axisY.categoriesLabels[2], "label2", "AxisY categories labels"); | |||
|
45 | } | |||
|
46 | ||||
|
47 | function test_signals() { | |||
|
48 | axisLabelsPositionSpy.clear(); | |||
|
49 | lineSeries1.axisY.labelsPosition = CategoryAxis.AxisLabelsPositionOnValue; | |||
|
50 | compare(axisLabelsPositionSpy.count, 1, "onLabelsPositionChanged"); | |||
|
51 | } | |||
|
52 | } | |||
|
53 | ||||
|
54 | ChartView { | |||
|
55 | id: chartView | |||
|
56 | anchors.fill: parent | |||
|
57 | ||||
|
58 | LineSeries { | |||
|
59 | id: lineSeries1 | |||
|
60 | axisX: ValueAxis { | |||
|
61 | id: axisX | |||
|
62 | min: 0 | |||
|
63 | max: 10 | |||
|
64 | } | |||
|
65 | axisY: CategoryAxis { | |||
|
66 | id: axisY | |||
|
67 | min: 0 | |||
|
68 | max: 10 | |||
|
69 | startValue: 0 | |||
|
70 | CategoryRange { | |||
|
71 | label: "label0" | |||
|
72 | endValue: 1 | |||
|
73 | } | |||
|
74 | CategoryRange { | |||
|
75 | label: "label1" | |||
|
76 | endValue: 3 | |||
|
77 | } | |||
|
78 | CategoryRange { | |||
|
79 | label: "label2" | |||
|
80 | endValue: 10 | |||
|
81 | } | |||
|
82 | SignalSpy { | |||
|
83 | id: axisLabelsPositionSpy | |||
|
84 | target: axisY | |||
|
85 | signalName: "labelsPositionChanged" | |||
|
86 | } | |||
|
87 | } | |||
|
88 | XYPoint { x: -1; y: -1 } | |||
|
89 | XYPoint { x: 0; y: 0 } | |||
|
90 | XYPoint { x: 5; y: 5 } | |||
|
91 | } | |||
|
92 | } | |||
|
93 | } |
@@ -0,0 +1,78 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Charts module. | |||
|
8 | ** | |||
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |||
|
10 | ** accordance with the Qt License Agreement provided with the Software | |||
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |||
|
12 | ** agreement between you and The Qt Company. | |||
|
13 | ** | |||
|
14 | ** If you have questions regarding the use of this file, please use | |||
|
15 | ** contact form at http://qt.io | |||
|
16 | ** | |||
|
17 | ****************************************************************************/ | |||
|
18 | ||||
|
19 | import QtQuick 2.0 | |||
|
20 | import QtTest 1.0 | |||
|
21 | import QtCharts 2.0 | |||
|
22 | ||||
|
23 | Rectangle { | |||
|
24 | width: 400 | |||
|
25 | height: 300 | |||
|
26 | ||||
|
27 | TestCase { | |||
|
28 | id: tc1 | |||
|
29 | name: "tst_qml-qtquicktest ChartView Properties" | |||
|
30 | when: windowShown | |||
|
31 | ||||
|
32 | function test_chartViewProperties() { | |||
|
33 | compare(chartView.animationOptions, ChartView.NoAnimation, "ChartView.animationOptions"); | |||
|
34 | verify(chartView.backgroundColor != undefined); | |||
|
35 | verify(chartView.margins.bottom > 0, "ChartView.margins.bottom"); | |||
|
36 | verify(chartView.margins.top > 0, "ChartView.margins.top"); | |||
|
37 | verify(chartView.margins.left > 0, "ChartView.margins.left"); | |||
|
38 | verify(chartView.margins.right > 0, "ChartView.margins.right"); | |||
|
39 | compare(chartView.count, 0, "ChartView.count"); | |||
|
40 | compare(chartView.dropShadowEnabled, false, "ChartView.dropShadowEnabled"); | |||
|
41 | verify(chartView.plotArea.height > 0, "ChartView.plotArea.height"); | |||
|
42 | verify(chartView.plotArea.width > 0, "ChartView.plotArea.width"); | |||
|
43 | verify(chartView.plotArea.x > 0, "ChartView.plotArea.x"); | |||
|
44 | verify(chartView.plotArea.y > 0, "ChartView.plotArea.y"); | |||
|
45 | compare(chartView.theme, ChartView.ChartThemeLight, "ChartView.theme"); | |||
|
46 | compare(chartView.title, "", "ChartView.title"); | |||
|
47 | compare(chartView.title, "", "ChartView.title"); | |||
|
48 | verify(chartView.titleColor != undefined, "ChartView.titleColor"); | |||
|
49 | compare(chartView.titleFont.bold, false, "ChartView.titleFont.bold"); | |||
|
50 | // Legend | |||
|
51 | compare(chartView.legend.visible, true, "ChartView.legend.visible"); | |||
|
52 | compare(chartView.legend.alignment, Qt.AlignTop, "ChartView.legend.alignment"); | |||
|
53 | compare(chartView.legend.backgroundVisible, false, "ChartView.legend.backgroundVisible"); | |||
|
54 | verify(chartView.legend.borderColor != undefined, "ChartView.legend.borderColor"); | |||
|
55 | verify(chartView.legend.color != undefined, "ChartView.legend.color"); | |||
|
56 | compare(chartView.legend.reverseMarkers, false, "ChartView.legend.reverseMarkers"); | |||
|
57 | // Legend font | |||
|
58 | compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold"); | |||
|
59 | compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization"); | |||
|
60 | verify(chartView.legend.font.family != "", "ChartView.legend.font.family"); | |||
|
61 | compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic"); | |||
|
62 | compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing"); | |||
|
63 | verify(chartView.legend.font.pixelSize > 0 | |||
|
64 | && chartView.legend.font.pixelSize < 50, "ChartView.legend.font.pixelSize"); | |||
|
65 | verify(chartView.legend.font.pointSize > 0 | |||
|
66 | && chartView.legend.font.pointSize < 50, "ChartView.legend.font.pointSize"); | |||
|
67 | compare(chartView.legend.font.strikeout, false, "ChartView.legend.font.strikeout"); | |||
|
68 | compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline"); | |||
|
69 | compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight"); | |||
|
70 | compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing"); | |||
|
71 | } | |||
|
72 | } | |||
|
73 | ||||
|
74 | ChartView { | |||
|
75 | id: chartView | |||
|
76 | anchors.fill: parent | |||
|
77 | } | |||
|
78 | } |
@@ -0,0 +1,115 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Charts module. | |||
|
8 | ** | |||
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |||
|
10 | ** accordance with the Qt License Agreement provided with the Software | |||
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |||
|
12 | ** agreement between you and The Qt Company. | |||
|
13 | ** | |||
|
14 | ** If you have questions regarding the use of this file, please use | |||
|
15 | ** contact form at http://qt.io | |||
|
16 | ** | |||
|
17 | ****************************************************************************/ | |||
|
18 | ||||
|
19 | import QtQuick 2.0 | |||
|
20 | import QtTest 1.0 | |||
|
21 | import QtCharts 2.0 | |||
|
22 | ||||
|
23 | Rectangle { | |||
|
24 | width: 400 | |||
|
25 | height: 300 | |||
|
26 | ||||
|
27 | TestCase { | |||
|
28 | id: tc1 | |||
|
29 | name: "tst_qml-qtquicktest ValueAxis" | |||
|
30 | when: windowShown | |||
|
31 | ||||
|
32 | // test functions are run in alphabetical order, the name has 'a' so that it | |||
|
33 | // will be the first function to execute. | |||
|
34 | function test_a_properties() { | |||
|
35 | // Default properties | |||
|
36 | verify(axisX.min < 0, "AxisX min"); | |||
|
37 | verify(axisX.max > 0, "AxisX max"); | |||
|
38 | verify(axisY.min < 0, "AxisY min"); | |||
|
39 | verify(axisY.max > 0, "AxisY max"); | |||
|
40 | verify(axisX.tickCount == 5, "AxisX tick count"); | |||
|
41 | verify(axisY.tickCount == 5, "AxisY tick count"); | |||
|
42 | verify(axisX.labelFormat == "", "label format"); | |||
|
43 | ||||
|
44 | // Modify properties | |||
|
45 | axisX.tickCount = 3; | |||
|
46 | verify(axisX.tickCount == 3, "set tick count"); | |||
|
47 | } | |||
|
48 | ||||
|
49 | function test_functions() { | |||
|
50 | // Set the axis ranges to not "nice" ones... | |||
|
51 | var min = 0.032456456; | |||
|
52 | var max = 10.67845634; | |||
|
53 | axisX.min = min; | |||
|
54 | axisX.max = max; | |||
|
55 | axisY.min = min; | |||
|
56 | axisY.max = max; | |||
|
57 | ||||
|
58 | // ...And then apply nice numbers and verify the range was changed | |||
|
59 | axisX.applyNiceNumbers(); | |||
|
60 | axisY.applyNiceNumbers(); | |||
|
61 | verify(axisX.min != min); | |||
|
62 | verify(axisX.max != max); | |||
|
63 | verify(axisY.min != min); | |||
|
64 | verify(axisY.max != max); | |||
|
65 | } | |||
|
66 | ||||
|
67 | function test_signals() { | |||
|
68 | minChangedSpy.clear(); | |||
|
69 | maxChangedSpy.clear(); | |||
|
70 | ||||
|
71 | axisX.min = 2; | |||
|
72 | compare(minChangedSpy.count, 1, "onMinChanged"); | |||
|
73 | compare(maxChangedSpy.count, 0, "onMaxChanged"); | |||
|
74 | ||||
|
75 | axisX.max = 8; | |||
|
76 | compare(minChangedSpy.count, 1, "onMinChanged"); | |||
|
77 | compare(maxChangedSpy.count, 1, "onMaxChanged"); | |||
|
78 | ||||
|
79 | // restore original values | |||
|
80 | axisX.min = 0; | |||
|
81 | axisX.max = 10; | |||
|
82 | compare(minChangedSpy.count, 2, "onMinChanged"); | |||
|
83 | compare(maxChangedSpy.count, 2, "onMaxChanged"); | |||
|
84 | } | |||
|
85 | } | |||
|
86 | ||||
|
87 | ChartView { | |||
|
88 | id: chartView | |||
|
89 | anchors.fill: parent | |||
|
90 | ||||
|
91 | LineSeries { | |||
|
92 | id: lineSeries1 | |||
|
93 | axisX: ValueAxis { | |||
|
94 | id: axisX | |||
|
95 | } | |||
|
96 | axisY: ValueAxis { | |||
|
97 | id: axisY | |||
|
98 | } | |||
|
99 | XYPoint { x: -1; y: -1 } | |||
|
100 | XYPoint { x: 0; y: 0 } | |||
|
101 | XYPoint { x: 5; y: 5 } | |||
|
102 | } | |||
|
103 | ||||
|
104 | SignalSpy { | |||
|
105 | id: minChangedSpy | |||
|
106 | target: axisX | |||
|
107 | signalName: "minChanged" | |||
|
108 | } | |||
|
109 | SignalSpy { | |||
|
110 | id: maxChangedSpy | |||
|
111 | target: axisX | |||
|
112 | signalName: "maxChanged" | |||
|
113 | } | |||
|
114 | } | |||
|
115 | } |
General Comments 0
You need to be logged in to leave comments.
Login now