@@ -0,0 +1,116 | |||||
|
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 BarCategoryAxis 2.0" | |||
|
30 | when: windowShown | |||
|
31 | ||||
|
32 | function test_minMax() { | |||
|
33 | compare(barSeries1.axisX.min, "Jan", "AxisX min"); | |||
|
34 | compare(barSeries1.axisX.max, "Jun", "AxisX max"); | |||
|
35 | compare(barSeries1.axisY.min, 0, "AxisY min"); | |||
|
36 | compare(barSeries1.axisY.max, 10, "AxisY max"); | |||
|
37 | } | |||
|
38 | ||||
|
39 | function test_categories() { | |||
|
40 | compare(barSeries1.axisX.count, 6, "AxisX count"); | |||
|
41 | categoriesCountChangedSpy.clear(); | |||
|
42 | categoriesChangedSpy.clear(); | |||
|
43 | ||||
|
44 | // Replace categories | |||
|
45 | barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"]; | |||
|
46 | compare(barSeries1.axisX.count, 4, "AxisX count"); | |||
|
47 | compare(categoriesCountChangedSpy.count, 1, "onCountChanged"); | |||
|
48 | compare(categoriesChangedSpy.count, 1, "onCategoriesChanged"); | |||
|
49 | ||||
|
50 | // Reset the original categories | |||
|
51 | barSeries1.axisX.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] | |||
|
52 | compare(barSeries1.axisX.count, 6, "AxisX count"); | |||
|
53 | compare(categoriesCountChangedSpy.count, 2, "onCountChanged"); | |||
|
54 | compare(categoriesChangedSpy.count, 2, "onCategoriesChanged"); | |||
|
55 | } | |||
|
56 | ||||
|
57 | function test_minMaxChanged() { | |||
|
58 | axisY.min = -1; | |||
|
59 | compare(minChangedSpy.count, 1, "onMinChanged"); | |||
|
60 | compare(maxChangedSpy.count, 0, "onMaxChanged"); | |||
|
61 | axisY.max = 12; | |||
|
62 | compare(minChangedSpy.count, 1, "onMinChanged"); | |||
|
63 | compare(maxChangedSpy.count, 1, "onMaxChanged"); | |||
|
64 | } | |||
|
65 | ||||
|
66 | function test_seriesAxisClear() { | |||
|
67 | verify(barSeries1.axisX.min !== "", "barSeries1.axisX.min"); | |||
|
68 | verify(barSeries1.axisX.max !== "", "barSeries1.axisX.max"); | |||
|
69 | verify(barSeries1.axisX.count !== 0, "barSeries1.axisX.count"); // category count | |||
|
70 | barSeries1.axisX.clear(); | |||
|
71 | verify(barSeries1.axisX.min === "", "barSeries1.axisX.min"); | |||
|
72 | verify(barSeries1.axisX.max === "", "barSeries1.axisX.max"); | |||
|
73 | verify(barSeries1.axisX.count === 0); | |||
|
74 | } | |||
|
75 | ||||
|
76 | } | |||
|
77 | ||||
|
78 | ChartView { | |||
|
79 | id: chartView | |||
|
80 | anchors.fill: parent | |||
|
81 | ||||
|
82 | BarSeries { | |||
|
83 | id: barSeries1 | |||
|
84 | axisX: BarCategoryAxis { | |||
|
85 | id: axisX | |||
|
86 | categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun" ] | |||
|
87 | } | |||
|
88 | axisY: ValueAxis { | |||
|
89 | id: axisY | |||
|
90 | min: 0 | |||
|
91 | max: 10 | |||
|
92 | } | |||
|
93 | } | |||
|
94 | ||||
|
95 | SignalSpy { | |||
|
96 | id: categoriesCountChangedSpy | |||
|
97 | target: axisX | |||
|
98 | signalName: "countChanged" | |||
|
99 | } | |||
|
100 | SignalSpy { | |||
|
101 | id: categoriesChangedSpy | |||
|
102 | target: axisX | |||
|
103 | signalName: "categoriesChanged" | |||
|
104 | } | |||
|
105 | SignalSpy { | |||
|
106 | id: minChangedSpy | |||
|
107 | target: axisY | |||
|
108 | signalName: "minChanged" | |||
|
109 | } | |||
|
110 | SignalSpy { | |||
|
111 | id: maxChangedSpy | |||
|
112 | target: axisY | |||
|
113 | signalName: "maxChanged" | |||
|
114 | } | |||
|
115 | } | |||
|
116 | } |
@@ -0,0 +1,161 | |||||
|
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 BarSeries 2.0" | |||
|
30 | when: windowShown | |||
|
31 | ||||
|
32 | function test_properties() { | |||
|
33 | compare(barSeries.barWidth, 0.5); | |||
|
34 | compare(barSeries.labelsVisible, false); | |||
|
35 | compare(barSeries.labelsPosition, BarSeries.LabelsCenter); | |||
|
36 | } | |||
|
37 | ||||
|
38 | function test_setproperties() { | |||
|
39 | var set = barSeries.append("property", [1, 2, 3]) | |||
|
40 | compare(set.brushFilename, ""); | |||
|
41 | } | |||
|
42 | ||||
|
43 | function test_axes() { | |||
|
44 | verify(chartView.axisX() == barSeries.axisX); | |||
|
45 | verify(chartView.axisY() == barSeries.axisY); | |||
|
46 | ||||
|
47 | compare(barSeries.axisX, stackedBarSeries.axisX); | |||
|
48 | compare(barSeries.axisY, stackedBarSeries.axisY); | |||
|
49 | ||||
|
50 | compare(barSeries.axisX, percentBarSeries.axisX); | |||
|
51 | compare(barSeries.axisY, percentBarSeries.axisY); | |||
|
52 | } | |||
|
53 | ||||
|
54 | function test_append() { | |||
|
55 | var setCount = 5; | |||
|
56 | var valueCount = 50; | |||
|
57 | addedSpy.clear(); | |||
|
58 | append(setCount, valueCount); | |||
|
59 | ||||
|
60 | compare(barSeries.count, setCount); | |||
|
61 | for (var k = 0; k < setCount; k++) { | |||
|
62 | compare(barSeries.at(k).count, valueCount); | |||
|
63 | compare(barSeries.at(k).label, "barset" + k); | |||
|
64 | } | |||
|
65 | compare(addedSpy.count, setCount); | |||
|
66 | ||||
|
67 | barSeries.clear(); | |||
|
68 | compare(barSeries.count, 0); | |||
|
69 | } | |||
|
70 | ||||
|
71 | function test_insert() { | |||
|
72 | var setCount = 5; | |||
|
73 | var valueCount = 50; | |||
|
74 | addedSpy.clear(); | |||
|
75 | append(setCount, valueCount); | |||
|
76 | ||||
|
77 | for (var i = 0; i < setCount; i++) { | |||
|
78 | var values = []; | |||
|
79 | for (var j = 0; j < valueCount; j++) | |||
|
80 | values[j] = Math.random() * 10; | |||
|
81 | var set = barSeries.insert(i, "barset" + i, values); | |||
|
82 | compare(set.label, "barset" + i); | |||
|
83 | } | |||
|
84 | ||||
|
85 | compare(barSeries.count, setCount * 2); | |||
|
86 | for (var k = 0; k < setCount * 2; k++) | |||
|
87 | compare(barSeries.at(k).count, valueCount); | |||
|
88 | compare(addedSpy.count, 2 * setCount); | |||
|
89 | ||||
|
90 | barSeries.clear(); | |||
|
91 | compare(barSeries.count, 0); | |||
|
92 | } | |||
|
93 | ||||
|
94 | function test_signals() { | |||
|
95 | labelsPositionSpy.clear(); | |||
|
96 | barSeries.labelsPosition = BarSeries.LabelsOutsideEnd; | |||
|
97 | compare(labelsPositionSpy.count, 1, "onLabelsPositionChanged") | |||
|
98 | } | |||
|
99 | ||||
|
100 | function test_remove() { | |||
|
101 | var setCount = 5; | |||
|
102 | var valueCount = 50; | |||
|
103 | removedSpy.clear(); | |||
|
104 | append(setCount, valueCount); | |||
|
105 | ||||
|
106 | for (var k = 0; k < setCount; k++) | |||
|
107 | barSeries.remove(barSeries.at(0)); | |||
|
108 | ||||
|
109 | compare(barSeries.count, 0); | |||
|
110 | compare(removedSpy.count, setCount); | |||
|
111 | } | |||
|
112 | ||||
|
113 | // Not a test function, used by one or more test functions | |||
|
114 | function append(setCount, valueCount) { | |||
|
115 | for (var i = 0; i < setCount; i++) { | |||
|
116 | var values = []; | |||
|
117 | for (var j = 0; j < valueCount; j++) | |||
|
118 | values[j] = Math.random() * 10; | |||
|
119 | barSeries.append("barset" + i, values); | |||
|
120 | } | |||
|
121 | } | |||
|
122 | } | |||
|
123 | ||||
|
124 | ChartView { | |||
|
125 | id: chartView | |||
|
126 | anchors.fill: parent | |||
|
127 | ||||
|
128 | BarSeries { | |||
|
129 | id: barSeries | |||
|
130 | name: "bar" | |||
|
131 | axisX: BarCategoryAxis {} | |||
|
132 | axisY: ValueAxis { min: 0; max: 10 } | |||
|
133 | ||||
|
134 | SignalSpy { | |||
|
135 | id: addedSpy | |||
|
136 | target: barSeries | |||
|
137 | signalName: "barsetsAdded" | |||
|
138 | } | |||
|
139 | SignalSpy { | |||
|
140 | id: removedSpy | |||
|
141 | target: barSeries | |||
|
142 | signalName: "barsetsRemoved" | |||
|
143 | } | |||
|
144 | SignalSpy { | |||
|
145 | id: labelsPositionSpy | |||
|
146 | target: barSeries | |||
|
147 | signalName: "labelsPositionChanged" | |||
|
148 | } | |||
|
149 | } | |||
|
150 | ||||
|
151 | StackedBarSeries { | |||
|
152 | id: stackedBarSeries | |||
|
153 | name: "stackedBar" | |||
|
154 | } | |||
|
155 | ||||
|
156 | PercentBarSeries { | |||
|
157 | id: percentBarSeries | |||
|
158 | name: "percentBar" | |||
|
159 | } | |||
|
160 | } | |||
|
161 | } |
@@ -0,0 +1,98 | |||||
|
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 BoxPlotSeries 2.0" | |||
|
30 | when: windowShown | |||
|
31 | ||||
|
32 | function test_properties() { | |||
|
33 | compare(boxPlotSeries.boxWidth, 0.5); | |||
|
34 | compare(boxPlotSeries.brushFilename, ""); | |||
|
35 | } | |||
|
36 | ||||
|
37 | function test_setproperties() { | |||
|
38 | var set = boxPlotSeries.append("boxplot", [1, 2, 5, 6, 8]); | |||
|
39 | compare(set.label, "boxplot"); | |||
|
40 | compare(set.count, 5); | |||
|
41 | compare(set.brushFilename, ""); | |||
|
42 | } | |||
|
43 | ||||
|
44 | function test_append() { | |||
|
45 | boxPlotSeries.clear(); | |||
|
46 | addedSpy.clear(); | |||
|
47 | countChangedSpy.clear(); | |||
|
48 | var count = 50; | |||
|
49 | for (var i = 0; i < count; i++) | |||
|
50 | boxPlotSeries.append("boxplot" + i, Math.random()); | |||
|
51 | compare(addedSpy.count, count); | |||
|
52 | compare(countChangedSpy.count, count); | |||
|
53 | compare(boxPlotSeries.count, count) | |||
|
54 | boxPlotSeries.clear(); | |||
|
55 | } | |||
|
56 | ||||
|
57 | function test_remove() { | |||
|
58 | boxPlotSeries.clear(); | |||
|
59 | removedSpy.clear(); | |||
|
60 | countChangedSpy.clear(); | |||
|
61 | var count = 50; | |||
|
62 | for (var i = 0; i < count; i++) | |||
|
63 | boxPlotSeries.append("boxplot" + i, Math.random()); | |||
|
64 | for (var j = 0; j < count; j++) | |||
|
65 | boxPlotSeries.remove(boxPlotSeries.at(0)); | |||
|
66 | compare(removedSpy.count, count); | |||
|
67 | compare(countChangedSpy.count, 2 * count); | |||
|
68 | compare(boxPlotSeries.count, 0) | |||
|
69 | } | |||
|
70 | } | |||
|
71 | ||||
|
72 | ChartView { | |||
|
73 | id: chartView | |||
|
74 | anchors.fill: parent | |||
|
75 | ||||
|
76 | BoxPlotSeries { | |||
|
77 | id: boxPlotSeries | |||
|
78 | name: "boxplot" | |||
|
79 | BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] } | |||
|
80 | ||||
|
81 | SignalSpy { | |||
|
82 | id: addedSpy | |||
|
83 | target: boxPlotSeries | |||
|
84 | signalName: "boxsetsAdded" | |||
|
85 | } | |||
|
86 | SignalSpy { | |||
|
87 | id: removedSpy | |||
|
88 | target: boxPlotSeries | |||
|
89 | signalName: "boxsetsRemoved" | |||
|
90 | } | |||
|
91 | SignalSpy { | |||
|
92 | id: countChangedSpy | |||
|
93 | target: boxPlotSeries | |||
|
94 | signalName: "countChanged" | |||
|
95 | } | |||
|
96 | } | |||
|
97 | } | |||
|
98 | } |
@@ -0,0 +1,71 | |||||
|
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 Signals 2.0" | |||
|
30 | when: windowShown | |||
|
31 | ||||
|
32 | // Verify onSeriesAdded and onSeriesRemoved signals | |||
|
33 | function test_chartView() { | |||
|
34 | var series = chartView.createSeries(ChartView.SeriesTypeLine, "line"); | |||
|
35 | seriesAddedSpy.wait(); | |||
|
36 | compare(seriesAddedSpy.count, 1, "ChartView.onSeriesAdded"); | |||
|
37 | ||||
|
38 | // Modifying layout triggers more than one plotAreaChanged signal | |||
|
39 | chartView.titleFont.pixelSize = 50; | |||
|
40 | verify(plotAreaChangedSpy.count > 0, "ChartView.onPlotAreaChanged"); | |||
|
41 | ||||
|
42 | chartView.removeSeries(series); | |||
|
43 | seriesRemovedSpy.wait(); | |||
|
44 | compare(seriesRemovedSpy.count, 1, "ChartView.onSeriesAdded"); | |||
|
45 | } | |||
|
46 | } | |||
|
47 | ||||
|
48 | ChartView { | |||
|
49 | id: chartView | |||
|
50 | anchors.fill: parent | |||
|
51 | title: "Chart" | |||
|
52 | ||||
|
53 | SignalSpy { | |||
|
54 | id: plotAreaChangedSpy | |||
|
55 | target: chartView | |||
|
56 | signalName: "plotAreaChanged" | |||
|
57 | } | |||
|
58 | ||||
|
59 | SignalSpy { | |||
|
60 | id: seriesAddedSpy | |||
|
61 | target: chartView | |||
|
62 | signalName: "seriesAdded" | |||
|
63 | } | |||
|
64 | ||||
|
65 | SignalSpy { | |||
|
66 | id: seriesRemovedSpy | |||
|
67 | target: chartView | |||
|
68 | signalName: "seriesRemoved" | |||
|
69 | } | |||
|
70 | } | |||
|
71 | } |
@@ -0,0 +1,133 | |||||
|
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 PieSeries 2.0" | |||
|
30 | when: windowShown | |||
|
31 | ||||
|
32 | function test_properties() { | |||
|
33 | compare(pieSeries.endAngle, 360); | |||
|
34 | compare(pieSeries.holeSize, 0); | |||
|
35 | compare(pieSeries.horizontalPosition, 0.5); | |||
|
36 | compare(pieSeries.size, 0.7); | |||
|
37 | compare(pieSeries.startAngle, 0); | |||
|
38 | compare(pieSeries.sum, 0); | |||
|
39 | compare(pieSeries.verticalPosition, 0.5); | |||
|
40 | } | |||
|
41 | ||||
|
42 | function test_sliceproperties() { | |||
|
43 | var slice = pieSeries.append("slice", 10); | |||
|
44 | compare(slice.angleSpan, 360.0); | |||
|
45 | verify(slice.borderColor != undefined); | |||
|
46 | compare(slice.borderWidth, 1); | |||
|
47 | verify(slice.color != undefined); | |||
|
48 | compare(slice.explodeDistanceFactor, 0.15); | |||
|
49 | compare(slice.exploded, false); | |||
|
50 | compare(slice.label, "slice"); | |||
|
51 | compare(slice.labelArmLengthFactor, 0.15); | |||
|
52 | verify(slice.labelColor != undefined); | |||
|
53 | compare(slice.labelFont.bold, false); | |||
|
54 | compare(slice.labelPosition, PieSlice.LabelOutside); | |||
|
55 | compare(slice.labelVisible, false); | |||
|
56 | compare(slice.percentage, 1.0); | |||
|
57 | compare(slice.startAngle, 0.0); | |||
|
58 | compare(slice.value, 10.0); | |||
|
59 | compare(slice.brushFilename, ""); | |||
|
60 | } | |||
|
61 | ||||
|
62 | function test_append() { | |||
|
63 | addedSpy.clear(); | |||
|
64 | countChangedSpy.clear(); | |||
|
65 | sumChangedSpy.clear(); | |||
|
66 | var count = 50; | |||
|
67 | for (var i = 0; i < count; i++) | |||
|
68 | pieSeries.append("slice" + i, Math.random()); | |||
|
69 | compare(addedSpy.count, count); | |||
|
70 | compare(countChangedSpy.count, count); | |||
|
71 | compare(sumChangedSpy.count, count); | |||
|
72 | pieSeries.clear(); | |||
|
73 | } | |||
|
74 | ||||
|
75 | function test_remove() { | |||
|
76 | removedSpy.clear(); | |||
|
77 | countChangedSpy.clear(); | |||
|
78 | sumChangedSpy.clear(); | |||
|
79 | var count = 50; | |||
|
80 | for (var i = 0; i < count; i++) | |||
|
81 | pieSeries.append("slice" + i, Math.random()); | |||
|
82 | for (var j = 0; j < count; j++) | |||
|
83 | pieSeries.remove(pieSeries.at(0)); | |||
|
84 | compare(removedSpy.count, count); | |||
|
85 | compare(countChangedSpy.count, 2 * count); | |||
|
86 | compare(sumChangedSpy.count, 2 * count); | |||
|
87 | compare(pieSeries.count, 0); | |||
|
88 | } | |||
|
89 | ||||
|
90 | function test_find_and_at() { | |||
|
91 | var count = 50; | |||
|
92 | for (var i = 0; i < count; i++) | |||
|
93 | pieSeries.append("slice" + i, Math.random()); | |||
|
94 | for (var j = 0; j < count; j++) { | |||
|
95 | compare(pieSeries.find("slice" + j).label, "slice" + j); | |||
|
96 | compare(pieSeries.find("slice" + j).brushFilename, ""); | |||
|
97 | } | |||
|
98 | compare(pieSeries.at(3).brushFilename,""); | |||
|
99 | pieSeries.clear(); | |||
|
100 | } | |||
|
101 | } | |||
|
102 | ||||
|
103 | ChartView { | |||
|
104 | id: chartView | |||
|
105 | anchors.fill: parent | |||
|
106 | ||||
|
107 | PieSeries { | |||
|
108 | id: pieSeries | |||
|
109 | name: "pie" | |||
|
110 | ||||
|
111 | SignalSpy { | |||
|
112 | id: addedSpy | |||
|
113 | target: pieSeries | |||
|
114 | signalName: "added" | |||
|
115 | } | |||
|
116 | SignalSpy { | |||
|
117 | id: removedSpy | |||
|
118 | target: pieSeries | |||
|
119 | signalName: "removed" | |||
|
120 | } | |||
|
121 | SignalSpy { | |||
|
122 | id: sumChangedSpy | |||
|
123 | target: pieSeries | |||
|
124 | signalName: "sumChanged" | |||
|
125 | } | |||
|
126 | SignalSpy { | |||
|
127 | id: countChangedSpy | |||
|
128 | target: pieSeries | |||
|
129 | signalName: "countChanged" | |||
|
130 | } | |||
|
131 | } | |||
|
132 | } | |||
|
133 | } |
@@ -1,116 +1,116 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | import QtQuick 2.0 |
|
19 | import QtQuick 2.0 | |
20 | import QtTest 1.0 |
|
20 | import QtTest 1.0 | |
21 |
import QtCharts 2. |
|
21 | import QtCharts 2.1 | |
22 |
|
22 | |||
23 | Rectangle { |
|
23 | Rectangle { | |
24 | width: 400 |
|
24 | width: 400 | |
25 | height: 300 |
|
25 | height: 300 | |
26 |
|
26 | |||
27 | TestCase { |
|
27 | TestCase { | |
28 | id: tc1 |
|
28 | id: tc1 | |
29 | name: "tst_qml-qtquicktest BarCategoryAxis" |
|
29 | name: "tst_qml-qtquicktest BarCategoryAxis" | |
30 | when: windowShown |
|
30 | when: windowShown | |
31 |
|
31 | |||
32 | function test_minMax() { |
|
32 | function test_minMax() { | |
33 | compare(barSeries1.axisX.min, "Jan", "AxisX min"); |
|
33 | compare(barSeries1.axisX.min, "Jan", "AxisX min"); | |
34 | compare(barSeries1.axisX.max, "Jun", "AxisX max"); |
|
34 | compare(barSeries1.axisX.max, "Jun", "AxisX max"); | |
35 | compare(barSeries1.axisY.min, 0, "AxisY min"); |
|
35 | compare(barSeries1.axisY.min, 0, "AxisY min"); | |
36 | compare(barSeries1.axisY.max, 10, "AxisY max"); |
|
36 | compare(barSeries1.axisY.max, 10, "AxisY max"); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | function test_categories() { |
|
39 | function test_categories() { | |
40 | compare(barSeries1.axisX.count, 6, "AxisX count"); |
|
40 | compare(barSeries1.axisX.count, 6, "AxisX count"); | |
41 | categoriesCountChangedSpy.clear(); |
|
41 | categoriesCountChangedSpy.clear(); | |
42 | categoriesChangedSpy.clear(); |
|
42 | categoriesChangedSpy.clear(); | |
43 |
|
43 | |||
44 | // Replace categories |
|
44 | // Replace categories | |
45 | barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"]; |
|
45 | barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"]; | |
46 | compare(barSeries1.axisX.count, 4, "AxisX count"); |
|
46 | compare(barSeries1.axisX.count, 4, "AxisX count"); | |
47 | compare(categoriesCountChangedSpy.count, 1, "onCountChanged"); |
|
47 | compare(categoriesCountChangedSpy.count, 1, "onCountChanged"); | |
48 | compare(categoriesChangedSpy.count, 1, "onCategoriesChanged"); |
|
48 | compare(categoriesChangedSpy.count, 1, "onCategoriesChanged"); | |
49 |
|
49 | |||
50 | // Reset the original categories |
|
50 | // Reset the original categories | |
51 | barSeries1.axisX.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] |
|
51 | barSeries1.axisX.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] | |
52 | compare(barSeries1.axisX.count, 6, "AxisX count"); |
|
52 | compare(barSeries1.axisX.count, 6, "AxisX count"); | |
53 | compare(categoriesCountChangedSpy.count, 2, "onCountChanged"); |
|
53 | compare(categoriesCountChangedSpy.count, 2, "onCountChanged"); | |
54 | compare(categoriesChangedSpy.count, 2, "onCategoriesChanged"); |
|
54 | compare(categoriesChangedSpy.count, 2, "onCategoriesChanged"); | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | function test_minMaxChanged() { |
|
57 | function test_minMaxChanged() { | |
58 | axisY.min = -1; |
|
58 | axisY.min = -1; | |
59 | compare(minChangedSpy.count, 1, "onMinChanged"); |
|
59 | compare(minChangedSpy.count, 1, "onMinChanged"); | |
60 | compare(maxChangedSpy.count, 0, "onMaxChanged"); |
|
60 | compare(maxChangedSpy.count, 0, "onMaxChanged"); | |
61 | axisY.max = 12; |
|
61 | axisY.max = 12; | |
62 | compare(minChangedSpy.count, 1, "onMinChanged"); |
|
62 | compare(minChangedSpy.count, 1, "onMinChanged"); | |
63 | compare(maxChangedSpy.count, 1, "onMaxChanged"); |
|
63 | compare(maxChangedSpy.count, 1, "onMaxChanged"); | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | function test_seriesAxisClear() { |
|
66 | function test_seriesAxisClear() { | |
67 | verify(barSeries1.axisX.min !== "", "barSeries1.axisX.min"); |
|
67 | verify(barSeries1.axisX.min !== "", "barSeries1.axisX.min"); | |
68 | verify(barSeries1.axisX.max !== "", "barSeries1.axisX.max"); |
|
68 | verify(barSeries1.axisX.max !== "", "barSeries1.axisX.max"); | |
69 | verify(barSeries1.axisX.count !== 0, "barSeries1.axisX.count"); // category count |
|
69 | verify(barSeries1.axisX.count !== 0, "barSeries1.axisX.count"); // category count | |
70 | barSeries1.axisX.clear(); |
|
70 | barSeries1.axisX.clear(); | |
71 | verify(barSeries1.axisX.min === "", "barSeries1.axisX.min"); |
|
71 | verify(barSeries1.axisX.min === "", "barSeries1.axisX.min"); | |
72 | verify(barSeries1.axisX.max === "", "barSeries1.axisX.max"); |
|
72 | verify(barSeries1.axisX.max === "", "barSeries1.axisX.max"); | |
73 | verify(barSeries1.axisX.count === 0); |
|
73 | verify(barSeries1.axisX.count === 0); | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | ChartView { |
|
78 | ChartView { | |
79 | id: chartView |
|
79 | id: chartView | |
80 | anchors.fill: parent |
|
80 | anchors.fill: parent | |
81 |
|
81 | |||
82 | BarSeries { |
|
82 | BarSeries { | |
83 | id: barSeries1 |
|
83 | id: barSeries1 | |
84 | axisX: BarCategoryAxis { |
|
84 | axisX: BarCategoryAxis { | |
85 | id: axisX |
|
85 | id: axisX | |
86 | categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun" ] |
|
86 | categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun" ] | |
87 | } |
|
87 | } | |
88 | axisY: ValueAxis { |
|
88 | axisY: ValueAxis { | |
89 | id: axisY |
|
89 | id: axisY | |
90 | min: 0 |
|
90 | min: 0 | |
91 | max: 10 |
|
91 | max: 10 | |
92 | } |
|
92 | } | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | SignalSpy { |
|
95 | SignalSpy { | |
96 | id: categoriesCountChangedSpy |
|
96 | id: categoriesCountChangedSpy | |
97 | target: axisX |
|
97 | target: axisX | |
98 | signalName: "countChanged" |
|
98 | signalName: "countChanged" | |
99 | } |
|
99 | } | |
100 | SignalSpy { |
|
100 | SignalSpy { | |
101 | id: categoriesChangedSpy |
|
101 | id: categoriesChangedSpy | |
102 | target: axisX |
|
102 | target: axisX | |
103 | signalName: "categoriesChanged" |
|
103 | signalName: "categoriesChanged" | |
104 | } |
|
104 | } | |
105 | SignalSpy { |
|
105 | SignalSpy { | |
106 | id: minChangedSpy |
|
106 | id: minChangedSpy | |
107 | target: axisY |
|
107 | target: axisY | |
108 | signalName: "minChanged" |
|
108 | signalName: "minChanged" | |
109 | } |
|
109 | } | |
110 | SignalSpy { |
|
110 | SignalSpy { | |
111 | id: maxChangedSpy |
|
111 | id: maxChangedSpy | |
112 | target: axisY |
|
112 | target: axisY | |
113 | signalName: "maxChanged" |
|
113 | signalName: "maxChanged" | |
114 | } |
|
114 | } | |
115 | } |
|
115 | } | |
116 | } |
|
116 | } |
@@ -1,161 +1,161 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | import QtQuick 2.0 |
|
19 | import QtQuick 2.0 | |
20 | import QtTest 1.0 |
|
20 | import QtTest 1.0 | |
21 |
import QtCharts 2. |
|
21 | import QtCharts 2.1 | |
22 |
|
22 | |||
23 | Rectangle { |
|
23 | Rectangle { | |
24 | width: 400 |
|
24 | width: 400 | |
25 | height: 300 |
|
25 | height: 300 | |
26 |
|
26 | |||
27 | TestCase { |
|
27 | TestCase { | |
28 | id: tc1 |
|
28 | id: tc1 | |
29 | name: "tst_qml-qtquicktest BarSeries" |
|
29 | name: "tst_qml-qtquicktest BarSeries" | |
30 | when: windowShown |
|
30 | when: windowShown | |
31 |
|
31 | |||
32 | function test_properties() { |
|
32 | function test_properties() { | |
33 | compare(barSeries.barWidth, 0.5); |
|
33 | compare(barSeries.barWidth, 0.5); | |
34 | compare(barSeries.labelsVisible, false); |
|
34 | compare(barSeries.labelsVisible, false); | |
35 | compare(barSeries.labelsPosition, BarSeries.LabelsCenter); |
|
35 | compare(barSeries.labelsPosition, BarSeries.LabelsCenter); | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | function test_setproperties() { |
|
38 | function test_setproperties() { | |
39 | var set = barSeries.append("property", [1, 2, 3]) |
|
39 | var set = barSeries.append("property", [1, 2, 3]) | |
40 | compare(set.brushFilename, ""); |
|
40 | compare(set.brushFilename, ""); | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | function test_axes() { |
|
43 | function test_axes() { | |
44 | verify(chartView.axisX() == barSeries.axisX); |
|
44 | verify(chartView.axisX() == barSeries.axisX); | |
45 | verify(chartView.axisY() == barSeries.axisY); |
|
45 | verify(chartView.axisY() == barSeries.axisY); | |
46 |
|
46 | |||
47 | compare(barSeries.axisX, stackedBarSeries.axisX); |
|
47 | compare(barSeries.axisX, stackedBarSeries.axisX); | |
48 | compare(barSeries.axisY, stackedBarSeries.axisY); |
|
48 | compare(barSeries.axisY, stackedBarSeries.axisY); | |
49 |
|
49 | |||
50 | compare(barSeries.axisX, percentBarSeries.axisX); |
|
50 | compare(barSeries.axisX, percentBarSeries.axisX); | |
51 | compare(barSeries.axisY, percentBarSeries.axisY); |
|
51 | compare(barSeries.axisY, percentBarSeries.axisY); | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | function test_append() { |
|
54 | function test_append() { | |
55 | var setCount = 5; |
|
55 | var setCount = 5; | |
56 | var valueCount = 50; |
|
56 | var valueCount = 50; | |
57 | addedSpy.clear(); |
|
57 | addedSpy.clear(); | |
58 | append(setCount, valueCount); |
|
58 | append(setCount, valueCount); | |
59 |
|
59 | |||
60 | compare(barSeries.count, setCount); |
|
60 | compare(barSeries.count, setCount); | |
61 | for (var k = 0; k < setCount; k++) { |
|
61 | for (var k = 0; k < setCount; k++) { | |
62 | compare(barSeries.at(k).count, valueCount); |
|
62 | compare(barSeries.at(k).count, valueCount); | |
63 | compare(barSeries.at(k).label, "barset" + k); |
|
63 | compare(barSeries.at(k).label, "barset" + k); | |
64 | } |
|
64 | } | |
65 | compare(addedSpy.count, setCount); |
|
65 | compare(addedSpy.count, setCount); | |
66 |
|
66 | |||
67 | barSeries.clear(); |
|
67 | barSeries.clear(); | |
68 | compare(barSeries.count, 0); |
|
68 | compare(barSeries.count, 0); | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | function test_insert() { |
|
71 | function test_insert() { | |
72 | var setCount = 5; |
|
72 | var setCount = 5; | |
73 | var valueCount = 50; |
|
73 | var valueCount = 50; | |
74 | addedSpy.clear(); |
|
74 | addedSpy.clear(); | |
75 | append(setCount, valueCount); |
|
75 | append(setCount, valueCount); | |
76 |
|
76 | |||
77 | for (var i = 0; i < setCount; i++) { |
|
77 | for (var i = 0; i < setCount; i++) { | |
78 | var values = []; |
|
78 | var values = []; | |
79 | for (var j = 0; j < valueCount; j++) |
|
79 | for (var j = 0; j < valueCount; j++) | |
80 | values[j] = Math.random() * 10; |
|
80 | values[j] = Math.random() * 10; | |
81 | var set = barSeries.insert(i, "barset" + i, values); |
|
81 | var set = barSeries.insert(i, "barset" + i, values); | |
82 | compare(set.label, "barset" + i); |
|
82 | compare(set.label, "barset" + i); | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | compare(barSeries.count, setCount * 2); |
|
85 | compare(barSeries.count, setCount * 2); | |
86 | for (var k = 0; k < setCount * 2; k++) |
|
86 | for (var k = 0; k < setCount * 2; k++) | |
87 | compare(barSeries.at(k).count, valueCount); |
|
87 | compare(barSeries.at(k).count, valueCount); | |
88 | compare(addedSpy.count, 2 * setCount); |
|
88 | compare(addedSpy.count, 2 * setCount); | |
89 |
|
89 | |||
90 | barSeries.clear(); |
|
90 | barSeries.clear(); | |
91 | compare(barSeries.count, 0); |
|
91 | compare(barSeries.count, 0); | |
92 | } |
|
92 | } | |
93 |
|
93 | |||
94 | function test_signals() { |
|
94 | function test_signals() { | |
95 | labelsPositionSpy.clear(); |
|
95 | labelsPositionSpy.clear(); | |
96 | barSeries.labelsPosition = BarSeries.LabelsOutsideEnd; |
|
96 | barSeries.labelsPosition = BarSeries.LabelsOutsideEnd; | |
97 | compare(labelsPositionSpy.count, 1, "onLabelsPositionChanged") |
|
97 | compare(labelsPositionSpy.count, 1, "onLabelsPositionChanged") | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | function test_remove() { |
|
100 | function test_remove() { | |
101 | var setCount = 5; |
|
101 | var setCount = 5; | |
102 | var valueCount = 50; |
|
102 | var valueCount = 50; | |
103 | removedSpy.clear(); |
|
103 | removedSpy.clear(); | |
104 | append(setCount, valueCount); |
|
104 | append(setCount, valueCount); | |
105 |
|
105 | |||
106 | for (var k = 0; k < setCount; k++) |
|
106 | for (var k = 0; k < setCount; k++) | |
107 | barSeries.remove(barSeries.at(0)); |
|
107 | barSeries.remove(barSeries.at(0)); | |
108 |
|
108 | |||
109 | compare(barSeries.count, 0); |
|
109 | compare(barSeries.count, 0); | |
110 | compare(removedSpy.count, setCount); |
|
110 | compare(removedSpy.count, setCount); | |
111 | } |
|
111 | } | |
112 |
|
112 | |||
113 | // Not a test function, used by one or more test functions |
|
113 | // Not a test function, used by one or more test functions | |
114 | function append(setCount, valueCount) { |
|
114 | function append(setCount, valueCount) { | |
115 | for (var i = 0; i < setCount; i++) { |
|
115 | for (var i = 0; i < setCount; i++) { | |
116 | var values = []; |
|
116 | var values = []; | |
117 | for (var j = 0; j < valueCount; j++) |
|
117 | for (var j = 0; j < valueCount; j++) | |
118 | values[j] = Math.random() * 10; |
|
118 | values[j] = Math.random() * 10; | |
119 | barSeries.append("barset" + i, values); |
|
119 | barSeries.append("barset" + i, values); | |
120 | } |
|
120 | } | |
121 | } |
|
121 | } | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 | ChartView { |
|
124 | ChartView { | |
125 | id: chartView |
|
125 | id: chartView | |
126 | anchors.fill: parent |
|
126 | anchors.fill: parent | |
127 |
|
127 | |||
128 | BarSeries { |
|
128 | BarSeries { | |
129 | id: barSeries |
|
129 | id: barSeries | |
130 | name: "bar" |
|
130 | name: "bar" | |
131 | axisX: BarCategoryAxis {} |
|
131 | axisX: BarCategoryAxis {} | |
132 | axisY: ValueAxis { min: 0; max: 10 } |
|
132 | axisY: ValueAxis { min: 0; max: 10 } | |
133 |
|
133 | |||
134 | SignalSpy { |
|
134 | SignalSpy { | |
135 | id: addedSpy |
|
135 | id: addedSpy | |
136 | target: barSeries |
|
136 | target: barSeries | |
137 | signalName: "barsetsAdded" |
|
137 | signalName: "barsetsAdded" | |
138 | } |
|
138 | } | |
139 | SignalSpy { |
|
139 | SignalSpy { | |
140 | id: removedSpy |
|
140 | id: removedSpy | |
141 | target: barSeries |
|
141 | target: barSeries | |
142 | signalName: "barsetsRemoved" |
|
142 | signalName: "barsetsRemoved" | |
143 | } |
|
143 | } | |
144 | SignalSpy { |
|
144 | SignalSpy { | |
145 | id: labelsPositionSpy |
|
145 | id: labelsPositionSpy | |
146 | target: barSeries |
|
146 | target: barSeries | |
147 | signalName: "labelsPositionChanged" |
|
147 | signalName: "labelsPositionChanged" | |
148 | } |
|
148 | } | |
149 | } |
|
149 | } | |
150 |
|
150 | |||
151 | StackedBarSeries { |
|
151 | StackedBarSeries { | |
152 | id: stackedBarSeries |
|
152 | id: stackedBarSeries | |
153 | name: "stackedBar" |
|
153 | name: "stackedBar" | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 | PercentBarSeries { |
|
156 | PercentBarSeries { | |
157 | id: percentBarSeries |
|
157 | id: percentBarSeries | |
158 | name: "percentBar" |
|
158 | name: "percentBar" | |
159 | } |
|
159 | } | |
160 | } |
|
160 | } | |
161 | } |
|
161 | } |
@@ -1,98 +1,98 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | import QtQuick 2.0 |
|
19 | import QtQuick 2.0 | |
20 | import QtTest 1.0 |
|
20 | import QtTest 1.0 | |
21 |
import QtCharts 2. |
|
21 | import QtCharts 2.1 | |
22 |
|
22 | |||
23 | Rectangle { |
|
23 | Rectangle { | |
24 | width: 400 |
|
24 | width: 400 | |
25 | height: 300 |
|
25 | height: 300 | |
26 |
|
26 | |||
27 | TestCase { |
|
27 | TestCase { | |
28 | id: tc1 |
|
28 | id: tc1 | |
29 | name: "tst_qml-qtquicktest BoxPlotSeries" |
|
29 | name: "tst_qml-qtquicktest BoxPlotSeries" | |
30 | when: windowShown |
|
30 | when: windowShown | |
31 |
|
31 | |||
32 | function test_properties() { |
|
32 | function test_properties() { | |
33 | compare(boxPlotSeries.boxWidth, 0.5); |
|
33 | compare(boxPlotSeries.boxWidth, 0.5); | |
34 | compare(boxPlotSeries.brushFilename, ""); |
|
34 | compare(boxPlotSeries.brushFilename, ""); | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | function test_setproperties() { |
|
37 | function test_setproperties() { | |
38 | var set = boxPlotSeries.append("boxplot", [1, 2, 5, 6, 8]); |
|
38 | var set = boxPlotSeries.append("boxplot", [1, 2, 5, 6, 8]); | |
39 | compare(set.label, "boxplot"); |
|
39 | compare(set.label, "boxplot"); | |
40 | compare(set.count, 5); |
|
40 | compare(set.count, 5); | |
41 | compare(set.brushFilename, ""); |
|
41 | compare(set.brushFilename, ""); | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | function test_append() { |
|
44 | function test_append() { | |
45 | boxPlotSeries.clear(); |
|
45 | boxPlotSeries.clear(); | |
46 | addedSpy.clear(); |
|
46 | addedSpy.clear(); | |
47 | countChangedSpy.clear(); |
|
47 | countChangedSpy.clear(); | |
48 | var count = 50; |
|
48 | var count = 50; | |
49 | for (var i = 0; i < count; i++) |
|
49 | for (var i = 0; i < count; i++) | |
50 | boxPlotSeries.append("boxplot" + i, Math.random()); |
|
50 | boxPlotSeries.append("boxplot" + i, Math.random()); | |
51 | compare(addedSpy.count, count); |
|
51 | compare(addedSpy.count, count); | |
52 | compare(countChangedSpy.count, count); |
|
52 | compare(countChangedSpy.count, count); | |
53 | compare(boxPlotSeries.count, count) |
|
53 | compare(boxPlotSeries.count, count) | |
54 | boxPlotSeries.clear(); |
|
54 | boxPlotSeries.clear(); | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | function test_remove() { |
|
57 | function test_remove() { | |
58 | boxPlotSeries.clear(); |
|
58 | boxPlotSeries.clear(); | |
59 | removedSpy.clear(); |
|
59 | removedSpy.clear(); | |
60 | countChangedSpy.clear(); |
|
60 | countChangedSpy.clear(); | |
61 | var count = 50; |
|
61 | var count = 50; | |
62 | for (var i = 0; i < count; i++) |
|
62 | for (var i = 0; i < count; i++) | |
63 | boxPlotSeries.append("boxplot" + i, Math.random()); |
|
63 | boxPlotSeries.append("boxplot" + i, Math.random()); | |
64 | for (var j = 0; j < count; j++) |
|
64 | for (var j = 0; j < count; j++) | |
65 | boxPlotSeries.remove(boxPlotSeries.at(0)); |
|
65 | boxPlotSeries.remove(boxPlotSeries.at(0)); | |
66 | compare(removedSpy.count, count); |
|
66 | compare(removedSpy.count, count); | |
67 | compare(countChangedSpy.count, 2 * count); |
|
67 | compare(countChangedSpy.count, 2 * count); | |
68 | compare(boxPlotSeries.count, 0) |
|
68 | compare(boxPlotSeries.count, 0) | |
69 | } |
|
69 | } | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 | ChartView { |
|
72 | ChartView { | |
73 | id: chartView |
|
73 | id: chartView | |
74 | anchors.fill: parent |
|
74 | anchors.fill: parent | |
75 |
|
75 | |||
76 | BoxPlotSeries { |
|
76 | BoxPlotSeries { | |
77 | id: boxPlotSeries |
|
77 | id: boxPlotSeries | |
78 | name: "boxplot" |
|
78 | name: "boxplot" | |
79 | BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] } |
|
79 | BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] } | |
80 |
|
80 | |||
81 | SignalSpy { |
|
81 | SignalSpy { | |
82 | id: addedSpy |
|
82 | id: addedSpy | |
83 | target: boxPlotSeries |
|
83 | target: boxPlotSeries | |
84 | signalName: "boxsetsAdded" |
|
84 | signalName: "boxsetsAdded" | |
85 | } |
|
85 | } | |
86 | SignalSpy { |
|
86 | SignalSpy { | |
87 | id: removedSpy |
|
87 | id: removedSpy | |
88 | target: boxPlotSeries |
|
88 | target: boxPlotSeries | |
89 | signalName: "boxsetsRemoved" |
|
89 | signalName: "boxsetsRemoved" | |
90 | } |
|
90 | } | |
91 | SignalSpy { |
|
91 | SignalSpy { | |
92 | id: countChangedSpy |
|
92 | id: countChangedSpy | |
93 | target: boxPlotSeries |
|
93 | target: boxPlotSeries | |
94 | signalName: "countChanged" |
|
94 | signalName: "countChanged" | |
95 | } |
|
95 | } | |
96 | } |
|
96 | } | |
97 | } |
|
97 | } | |
98 | } |
|
98 | } |
@@ -1,93 +1,93 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | import QtQuick 2.0 |
|
19 | import QtQuick 2.0 | |
20 | import QtTest 1.0 |
|
20 | import QtTest 1.0 | |
21 | import QtCharts 2.0 |
|
21 | import QtCharts 2.0 | |
22 |
|
22 | |||
23 | Rectangle { |
|
23 | Rectangle { | |
24 | width: 400 |
|
24 | width: 400 | |
25 | height: 300 |
|
25 | height: 300 | |
26 |
|
26 | |||
27 | TestCase { |
|
27 | TestCase { | |
28 | id: tc1 |
|
28 | id: tc1 | |
29 | name: "tst_qml-qtquicktest CategoryAxis" |
|
29 | name: "tst_qml-qtquicktest CategoryAxis 2.0" | |
30 | when: windowShown |
|
30 | when: windowShown | |
31 |
|
31 | |||
32 | function test_minMax() { |
|
32 | function test_minMax() { | |
33 | compare(lineSeries1.axisX.min, 0, "AxisX min"); |
|
33 | compare(lineSeries1.axisX.min, 0, "AxisX min"); | |
34 | compare(lineSeries1.axisX.max, 10, "AxisX max"); |
|
34 | compare(lineSeries1.axisX.max, 10, "AxisX max"); | |
35 | compare(lineSeries1.axisY.min, 0, "AxisY min"); |
|
35 | compare(lineSeries1.axisY.min, 0, "AxisY min"); | |
36 | compare(lineSeries1.axisY.max, 10, "AxisY max"); |
|
36 | compare(lineSeries1.axisY.max, 10, "AxisY max"); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | function test_categories() { |
|
39 | function test_categories() { | |
40 | compare(lineSeries1.axisY.startValue, 0, "AxisY start value"); |
|
40 | compare(lineSeries1.axisY.startValue, 0, "AxisY start value"); | |
41 | compare(lineSeries1.axisY.count, 3, "AxisY count"); |
|
41 | compare(lineSeries1.axisY.count, 3, "AxisY count"); | |
42 | compare(lineSeries1.axisY.categoriesLabels[0], "label0", "AxisY categories labels"); |
|
42 | compare(lineSeries1.axisY.categoriesLabels[0], "label0", "AxisY categories labels"); | |
43 | compare(lineSeries1.axisY.categoriesLabels[1], "label1", "AxisY categories labels"); |
|
43 | compare(lineSeries1.axisY.categoriesLabels[1], "label1", "AxisY categories labels"); | |
44 | compare(lineSeries1.axisY.categoriesLabels[2], "label2", "AxisY categories labels"); |
|
44 | compare(lineSeries1.axisY.categoriesLabels[2], "label2", "AxisY categories labels"); | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | function test_signals() { |
|
47 | function test_signals() { | |
48 | axisLabelsPositionSpy.clear(); |
|
48 | axisLabelsPositionSpy.clear(); | |
49 | lineSeries1.axisY.labelsPosition = CategoryAxis.AxisLabelsPositionOnValue; |
|
49 | lineSeries1.axisY.labelsPosition = CategoryAxis.AxisLabelsPositionOnValue; | |
50 | compare(axisLabelsPositionSpy.count, 1, "onLabelsPositionChanged"); |
|
50 | compare(axisLabelsPositionSpy.count, 1, "onLabelsPositionChanged"); | |
51 | } |
|
51 | } | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | ChartView { |
|
54 | ChartView { | |
55 | id: chartView |
|
55 | id: chartView | |
56 | anchors.fill: parent |
|
56 | anchors.fill: parent | |
57 |
|
57 | |||
58 | LineSeries { |
|
58 | LineSeries { | |
59 | id: lineSeries1 |
|
59 | id: lineSeries1 | |
60 | axisX: ValueAxis { |
|
60 | axisX: ValueAxis { | |
61 | id: axisX |
|
61 | id: axisX | |
62 | min: 0 |
|
62 | min: 0 | |
63 | max: 10 |
|
63 | max: 10 | |
64 | } |
|
64 | } | |
65 | axisY: CategoryAxis { |
|
65 | axisY: CategoryAxis { | |
66 | id: axisY |
|
66 | id: axisY | |
67 | min: 0 |
|
67 | min: 0 | |
68 | max: 10 |
|
68 | max: 10 | |
69 | startValue: 0 |
|
69 | startValue: 0 | |
70 | CategoryRange { |
|
70 | CategoryRange { | |
71 | label: "label0" |
|
71 | label: "label0" | |
72 | endValue: 1 |
|
72 | endValue: 1 | |
73 | } |
|
73 | } | |
74 | CategoryRange { |
|
74 | CategoryRange { | |
75 | label: "label1" |
|
75 | label: "label1" | |
76 | endValue: 3 |
|
76 | endValue: 3 | |
77 | } |
|
77 | } | |
78 | CategoryRange { |
|
78 | CategoryRange { | |
79 | label: "label2" |
|
79 | label: "label2" | |
80 | endValue: 10 |
|
80 | endValue: 10 | |
81 | } |
|
81 | } | |
82 | SignalSpy { |
|
82 | SignalSpy { | |
83 | id: axisLabelsPositionSpy |
|
83 | id: axisLabelsPositionSpy | |
84 | target: axisY |
|
84 | target: axisY | |
85 | signalName: "labelsPositionChanged" |
|
85 | signalName: "labelsPositionChanged" | |
86 | } |
|
86 | } | |
87 | } |
|
87 | } | |
88 | XYPoint { x: -1; y: -1 } |
|
88 | XYPoint { x: -1; y: -1 } | |
89 | XYPoint { x: 0; y: 0 } |
|
89 | XYPoint { x: 0; y: 0 } | |
90 | XYPoint { x: 5; y: 5 } |
|
90 | XYPoint { x: 5; y: 5 } | |
91 | } |
|
91 | } | |
92 | } |
|
92 | } | |
93 | } |
|
93 | } |
@@ -1,78 +1,78 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | import QtQuick 2.0 |
|
19 | import QtQuick 2.0 | |
20 | import QtTest 1.0 |
|
20 | import QtTest 1.0 | |
21 | import QtCharts 2.0 |
|
21 | import QtCharts 2.0 | |
22 |
|
22 | |||
23 | Rectangle { |
|
23 | Rectangle { | |
24 | width: 400 |
|
24 | width: 400 | |
25 | height: 300 |
|
25 | height: 300 | |
26 |
|
26 | |||
27 | TestCase { |
|
27 | TestCase { | |
28 | id: tc1 |
|
28 | id: tc1 | |
29 | name: "tst_qml-qtquicktest ChartView Properties" |
|
29 | name: "tst_qml-qtquicktest ChartView Properties 2.0" | |
30 | when: windowShown |
|
30 | when: windowShown | |
31 |
|
31 | |||
32 | function test_chartViewProperties() { |
|
32 | function test_chartViewProperties() { | |
33 | compare(chartView.animationOptions, ChartView.NoAnimation, "ChartView.animationOptions"); |
|
33 | compare(chartView.animationOptions, ChartView.NoAnimation, "ChartView.animationOptions"); | |
34 | verify(chartView.backgroundColor != undefined); |
|
34 | verify(chartView.backgroundColor != undefined); | |
35 | verify(chartView.margins.bottom > 0, "ChartView.margins.bottom"); |
|
35 | verify(chartView.margins.bottom > 0, "ChartView.margins.bottom"); | |
36 | verify(chartView.margins.top > 0, "ChartView.margins.top"); |
|
36 | verify(chartView.margins.top > 0, "ChartView.margins.top"); | |
37 | verify(chartView.margins.left > 0, "ChartView.margins.left"); |
|
37 | verify(chartView.margins.left > 0, "ChartView.margins.left"); | |
38 | verify(chartView.margins.right > 0, "ChartView.margins.right"); |
|
38 | verify(chartView.margins.right > 0, "ChartView.margins.right"); | |
39 | compare(chartView.count, 0, "ChartView.count"); |
|
39 | compare(chartView.count, 0, "ChartView.count"); | |
40 | compare(chartView.dropShadowEnabled, false, "ChartView.dropShadowEnabled"); |
|
40 | compare(chartView.dropShadowEnabled, false, "ChartView.dropShadowEnabled"); | |
41 | verify(chartView.plotArea.height > 0, "ChartView.plotArea.height"); |
|
41 | verify(chartView.plotArea.height > 0, "ChartView.plotArea.height"); | |
42 | verify(chartView.plotArea.width > 0, "ChartView.plotArea.width"); |
|
42 | verify(chartView.plotArea.width > 0, "ChartView.plotArea.width"); | |
43 | verify(chartView.plotArea.x > 0, "ChartView.plotArea.x"); |
|
43 | verify(chartView.plotArea.x > 0, "ChartView.plotArea.x"); | |
44 | verify(chartView.plotArea.y > 0, "ChartView.plotArea.y"); |
|
44 | verify(chartView.plotArea.y > 0, "ChartView.plotArea.y"); | |
45 | compare(chartView.theme, ChartView.ChartThemeLight, "ChartView.theme"); |
|
45 | compare(chartView.theme, ChartView.ChartThemeLight, "ChartView.theme"); | |
46 | compare(chartView.title, "", "ChartView.title"); |
|
46 | compare(chartView.title, "", "ChartView.title"); | |
47 | compare(chartView.title, "", "ChartView.title"); |
|
47 | compare(chartView.title, "", "ChartView.title"); | |
48 | verify(chartView.titleColor != undefined, "ChartView.titleColor"); |
|
48 | verify(chartView.titleColor != undefined, "ChartView.titleColor"); | |
49 | compare(chartView.titleFont.bold, false, "ChartView.titleFont.bold"); |
|
49 | compare(chartView.titleFont.bold, false, "ChartView.titleFont.bold"); | |
50 | // Legend |
|
50 | // Legend | |
51 | compare(chartView.legend.visible, true, "ChartView.legend.visible"); |
|
51 | compare(chartView.legend.visible, true, "ChartView.legend.visible"); | |
52 | compare(chartView.legend.alignment, Qt.AlignTop, "ChartView.legend.alignment"); |
|
52 | compare(chartView.legend.alignment, Qt.AlignTop, "ChartView.legend.alignment"); | |
53 | compare(chartView.legend.backgroundVisible, false, "ChartView.legend.backgroundVisible"); |
|
53 | compare(chartView.legend.backgroundVisible, false, "ChartView.legend.backgroundVisible"); | |
54 | verify(chartView.legend.borderColor != undefined, "ChartView.legend.borderColor"); |
|
54 | verify(chartView.legend.borderColor != undefined, "ChartView.legend.borderColor"); | |
55 | verify(chartView.legend.color != undefined, "ChartView.legend.color"); |
|
55 | verify(chartView.legend.color != undefined, "ChartView.legend.color"); | |
56 | compare(chartView.legend.reverseMarkers, false, "ChartView.legend.reverseMarkers"); |
|
56 | compare(chartView.legend.reverseMarkers, false, "ChartView.legend.reverseMarkers"); | |
57 | // Legend font |
|
57 | // Legend font | |
58 | compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold"); |
|
58 | compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold"); | |
59 | compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization"); |
|
59 | compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization"); | |
60 | verify(chartView.legend.font.family != "", "ChartView.legend.font.family"); |
|
60 | verify(chartView.legend.font.family != "", "ChartView.legend.font.family"); | |
61 | compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic"); |
|
61 | compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic"); | |
62 | compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing"); |
|
62 | compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing"); | |
63 | verify(chartView.legend.font.pixelSize > 0 |
|
63 | verify(chartView.legend.font.pixelSize > 0 | |
64 | && chartView.legend.font.pixelSize < 50, "ChartView.legend.font.pixelSize"); |
|
64 | && chartView.legend.font.pixelSize < 50, "ChartView.legend.font.pixelSize"); | |
65 | verify(chartView.legend.font.pointSize > 0 |
|
65 | verify(chartView.legend.font.pointSize > 0 | |
66 | && chartView.legend.font.pointSize < 50, "ChartView.legend.font.pointSize"); |
|
66 | && chartView.legend.font.pointSize < 50, "ChartView.legend.font.pointSize"); | |
67 | compare(chartView.legend.font.strikeout, false, "ChartView.legend.font.strikeout"); |
|
67 | compare(chartView.legend.font.strikeout, false, "ChartView.legend.font.strikeout"); | |
68 | compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline"); |
|
68 | compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline"); | |
69 | compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight"); |
|
69 | compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight"); | |
70 | compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing"); |
|
70 | compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing"); | |
71 | } |
|
71 | } | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | ChartView { |
|
74 | ChartView { | |
75 | id: chartView |
|
75 | id: chartView | |
76 | anchors.fill: parent |
|
76 | anchors.fill: parent | |
77 | } |
|
77 | } | |
78 | } |
|
78 | } |
@@ -1,158 +1,158 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | import QtQuick 2.0 |
|
19 | import QtQuick 2.0 | |
20 | import QtTest 1.0 |
|
20 | import QtTest 1.0 | |
21 | import QtCharts 2.0 |
|
21 | import QtCharts 2.0 | |
22 |
|
22 | |||
23 | Rectangle { |
|
23 | Rectangle { | |
24 | width: 400 |
|
24 | width: 400 | |
25 | height: 300 |
|
25 | height: 300 | |
26 |
|
26 | |||
27 | TestCase { |
|
27 | TestCase { | |
28 | id: tc1 |
|
28 | id: tc1 | |
29 | name: "tst_qml-qtquicktest ChartView Functions" |
|
29 | name: "tst_qml-qtquicktest ChartView Functions 2.0" | |
30 | when: windowShown |
|
30 | when: windowShown | |
31 |
|
31 | |||
32 | function test_chartViewSeriesAndAxes() { |
|
32 | function test_chartViewSeriesAndAxes() { | |
33 | // Create XY series |
|
33 | // Create XY series | |
34 | var line = chartView.createSeries(ChartView.SeriesTypeLine, "line"); |
|
34 | var line = chartView.createSeries(ChartView.SeriesTypeLine, "line"); | |
35 | verify(line != null && line != undefined); |
|
35 | verify(line != null && line != undefined); | |
36 | var spline = chartView.createSeries(ChartView.SeriesTypeSpline, "spline"); |
|
36 | var spline = chartView.createSeries(ChartView.SeriesTypeSpline, "spline"); | |
37 | verify(spline != null && spline != undefined); |
|
37 | verify(spline != null && spline != undefined); | |
38 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter"); |
|
38 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter"); | |
39 | verify(scatter != null && scatter != undefined); |
|
39 | verify(scatter != null && scatter != undefined); | |
40 |
|
40 | |||
41 | // Create a series with specific axes |
|
41 | // Create a series with specific axes | |
42 | var line2 = chartView.createSeries(ChartView.SeriesTypeLine, "line2", chartView.axisX(line), chartView.axisY(line)); |
|
42 | var line2 = chartView.createSeries(ChartView.SeriesTypeLine, "line2", chartView.axisX(line), chartView.axisY(line)); | |
43 |
|
43 | |||
44 | // Check that all the XY series use the same axes |
|
44 | // Check that all the XY series use the same axes | |
45 | verify(chartView.axisX(line) != null); |
|
45 | verify(chartView.axisX(line) != null); | |
46 | verify(chartView.axisY(line) != null); |
|
46 | verify(chartView.axisY(line) != null); | |
47 | compare(chartView.axisX(line), chartView.axisX(line2)); |
|
47 | compare(chartView.axisX(line), chartView.axisX(line2)); | |
48 | compare(chartView.axisY(line), chartView.axisY(line2)); |
|
48 | compare(chartView.axisY(line), chartView.axisY(line2)); | |
49 | compare(chartView.axisX(line), chartView.axisX(spline)); |
|
49 | compare(chartView.axisX(line), chartView.axisX(spline)); | |
50 | compare(chartView.axisY(line), chartView.axisY(spline)); |
|
50 | compare(chartView.axisY(line), chartView.axisY(spline)); | |
51 | compare(chartView.axisX(line), chartView.axisX(scatter)); |
|
51 | compare(chartView.axisX(line), chartView.axisX(scatter)); | |
52 | compare(chartView.axisY(line), chartView.axisY(scatter)); |
|
52 | compare(chartView.axisY(line), chartView.axisY(scatter)); | |
53 |
|
53 | |||
54 | var bar = chartView.createSeries(ChartView.SeriesTypeBar, "bar"); |
|
54 | var bar = chartView.createSeries(ChartView.SeriesTypeBar, "bar"); | |
55 | verify(bar != null && bar != undefined); |
|
55 | verify(bar != null && bar != undefined); | |
56 | var stackedbar = chartView.createSeries(ChartView.SeriesTypeStackedBar, "stackedbar"); |
|
56 | var stackedbar = chartView.createSeries(ChartView.SeriesTypeStackedBar, "stackedbar"); | |
57 | verify(stackedbar != null && stackedbar != undefined); |
|
57 | verify(stackedbar != null && stackedbar != undefined); | |
58 | var percentbar = chartView.createSeries(ChartView.SeriesTypePercentBar, "percentbar"); |
|
58 | var percentbar = chartView.createSeries(ChartView.SeriesTypePercentBar, "percentbar"); | |
59 | verify(percentbar != null && percentbar != undefined); |
|
59 | verify(percentbar != null && percentbar != undefined); | |
60 | var horizontalbar = chartView.createSeries(ChartView.SeriesTypeHorizontalBar, "horizontalbar"); |
|
60 | var horizontalbar = chartView.createSeries(ChartView.SeriesTypeHorizontalBar, "horizontalbar"); | |
61 | verify(horizontalbar != null && horizontalbar != undefined); |
|
61 | verify(horizontalbar != null && horizontalbar != undefined); | |
62 | var horizontalstackedbar = chartView.createSeries(ChartView.SeriesTypeHorizontalStackedBar, "horizontalstackedbar"); |
|
62 | var horizontalstackedbar = chartView.createSeries(ChartView.SeriesTypeHorizontalStackedBar, "horizontalstackedbar"); | |
63 | verify(horizontalstackedbar != null && horizontalstackedbar != undefined); |
|
63 | verify(horizontalstackedbar != null && horizontalstackedbar != undefined); | |
64 | var horizontalpercentbar = chartView.createSeries(ChartView.SeriesTypeHorizontalPercentBar, "horizontalpercentbar"); |
|
64 | var horizontalpercentbar = chartView.createSeries(ChartView.SeriesTypeHorizontalPercentBar, "horizontalpercentbar"); | |
65 | verify(horizontalpercentbar != null && horizontalpercentbar != undefined); |
|
65 | verify(horizontalpercentbar != null && horizontalpercentbar != undefined); | |
66 | var area = chartView.createSeries(ChartView.SeriesTypeArea, "area"); |
|
66 | var area = chartView.createSeries(ChartView.SeriesTypeArea, "area"); | |
67 | verify(area != null && area != undefined); |
|
67 | verify(area != null && area != undefined); | |
68 |
|
68 | |||
69 | // Remove all series |
|
69 | // Remove all series | |
70 | chartView.removeAllSeries(); |
|
70 | chartView.removeAllSeries(); | |
71 | compare(chartView.count, 0); |
|
71 | compare(chartView.count, 0); | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | function test_chartViewRange() { |
|
74 | function test_chartViewRange() { | |
75 | // Set initial values |
|
75 | // Set initial values | |
76 | chartView.createSeries(ChartView.SeriesTypeLine, "line"); |
|
76 | chartView.createSeries(ChartView.SeriesTypeLine, "line"); | |
77 | verify(chartView.axisX() != null); |
|
77 | verify(chartView.axisX() != null); | |
78 | verify(chartView.axisY() != null); |
|
78 | verify(chartView.axisY() != null); | |
79 | chartView.axisX().min = 1.0; |
|
79 | chartView.axisX().min = 1.0; | |
80 | chartView.axisX().max = 2.0; |
|
80 | chartView.axisX().max = 2.0; | |
81 | chartView.axisY().min = 1.0; |
|
81 | chartView.axisY().min = 1.0; | |
82 | chartView.axisY().max = 2.0; |
|
82 | chartView.axisY().max = 2.0; | |
83 |
|
83 | |||
84 | var xMax = chartView.axisX().max; |
|
84 | var xMax = chartView.axisX().max; | |
85 | var xMin = chartView.axisX().min; |
|
85 | var xMin = chartView.axisX().min; | |
86 | var yMax = chartView.axisY().max; |
|
86 | var yMax = chartView.axisY().max; | |
87 | var yMin = chartView.axisY().min; |
|
87 | var yMin = chartView.axisY().min; | |
88 |
|
88 | |||
89 | // zoom x 2.5 |
|
89 | // zoom x 2.5 | |
90 | chartView.zoom(1.5); |
|
90 | chartView.zoom(1.5); | |
91 | verify(chartView.axisX().max < xMax); |
|
91 | verify(chartView.axisX().max < xMax); | |
92 | verify(chartView.axisX().min > xMin); |
|
92 | verify(chartView.axisX().min > xMin); | |
93 | verify(chartView.axisY().max < yMax); |
|
93 | verify(chartView.axisY().max < yMax); | |
94 | verify(chartView.axisY().min > yMin); |
|
94 | verify(chartView.axisY().min > yMin); | |
95 | xMax = chartView.axisX().max; |
|
95 | xMax = chartView.axisX().max; | |
96 | xMin = chartView.axisX().min; |
|
96 | xMin = chartView.axisX().min; | |
97 | yMax = chartView.axisY().max; |
|
97 | yMax = chartView.axisY().max; | |
98 | yMin = chartView.axisY().min; |
|
98 | yMin = chartView.axisY().min; | |
99 |
|
99 | |||
100 | // zoom x 0.5 |
|
100 | // zoom x 0.5 | |
101 | chartView.zoom(0.5); |
|
101 | chartView.zoom(0.5); | |
102 | verify(chartView.axisX().max > xMax); |
|
102 | verify(chartView.axisX().max > xMax); | |
103 | verify(chartView.axisX().min < xMin); |
|
103 | verify(chartView.axisX().min < xMin); | |
104 | verify(chartView.axisY().max > yMax); |
|
104 | verify(chartView.axisY().max > yMax); | |
105 | verify(chartView.axisY().min < yMin); |
|
105 | verify(chartView.axisY().min < yMin); | |
106 | xMax = chartView.axisX().max; |
|
106 | xMax = chartView.axisX().max; | |
107 | xMin = chartView.axisX().min; |
|
107 | xMin = chartView.axisX().min; | |
108 | yMax = chartView.axisY().max; |
|
108 | yMax = chartView.axisY().max; | |
109 | yMin = chartView.axisY().min; |
|
109 | yMin = chartView.axisY().min; | |
110 |
|
110 | |||
111 | // Scroll up |
|
111 | // Scroll up | |
112 | chartView.scrollUp(10); |
|
112 | chartView.scrollUp(10); | |
113 | compare(chartView.axisX().max, xMax); |
|
113 | compare(chartView.axisX().max, xMax); | |
114 | compare(chartView.axisX().min, xMin); |
|
114 | compare(chartView.axisX().min, xMin); | |
115 | verify(chartView.axisY().max > yMax); |
|
115 | verify(chartView.axisY().max > yMax); | |
116 | verify(chartView.axisY().min > yMin); |
|
116 | verify(chartView.axisY().min > yMin); | |
117 | xMax = chartView.axisX().max; |
|
117 | xMax = chartView.axisX().max; | |
118 | xMin = chartView.axisX().min; |
|
118 | xMin = chartView.axisX().min; | |
119 | yMax = chartView.axisY().max; |
|
119 | yMax = chartView.axisY().max; | |
120 | yMin = chartView.axisY().min; |
|
120 | yMin = chartView.axisY().min; | |
121 |
|
121 | |||
122 | // Scroll down |
|
122 | // Scroll down | |
123 | chartView.scrollDown(10); |
|
123 | chartView.scrollDown(10); | |
124 | compare(chartView.axisX().max, xMax); |
|
124 | compare(chartView.axisX().max, xMax); | |
125 | compare(chartView.axisX().min, xMin); |
|
125 | compare(chartView.axisX().min, xMin); | |
126 | verify(chartView.axisY().max < yMax); |
|
126 | verify(chartView.axisY().max < yMax); | |
127 | verify(chartView.axisY().min < yMin); |
|
127 | verify(chartView.axisY().min < yMin); | |
128 | xMax = chartView.axisX().max; |
|
128 | xMax = chartView.axisX().max; | |
129 | xMin = chartView.axisX().min; |
|
129 | xMin = chartView.axisX().min; | |
130 | yMax = chartView.axisY().max; |
|
130 | yMax = chartView.axisY().max; | |
131 | yMin = chartView.axisY().min; |
|
131 | yMin = chartView.axisY().min; | |
132 |
|
132 | |||
133 | // Scroll left |
|
133 | // Scroll left | |
134 | chartView.scrollLeft(10); |
|
134 | chartView.scrollLeft(10); | |
135 | verify(chartView.axisX().max < xMax); |
|
135 | verify(chartView.axisX().max < xMax); | |
136 | verify(chartView.axisX().min < xMin); |
|
136 | verify(chartView.axisX().min < xMin); | |
137 | compare(chartView.axisY().max, yMax); |
|
137 | compare(chartView.axisY().max, yMax); | |
138 | compare(chartView.axisY().min, yMin); |
|
138 | compare(chartView.axisY().min, yMin); | |
139 | xMax = chartView.axisX().max; |
|
139 | xMax = chartView.axisX().max; | |
140 | xMin = chartView.axisX().min; |
|
140 | xMin = chartView.axisX().min; | |
141 | yMax = chartView.axisY().max; |
|
141 | yMax = chartView.axisY().max; | |
142 | yMin = chartView.axisY().min; |
|
142 | yMin = chartView.axisY().min; | |
143 |
|
143 | |||
144 | // Scroll right |
|
144 | // Scroll right | |
145 | chartView.scrollRight(10); |
|
145 | chartView.scrollRight(10); | |
146 | verify(chartView.axisX().max > xMax); |
|
146 | verify(chartView.axisX().max > xMax); | |
147 | verify(chartView.axisX().min > xMin); |
|
147 | verify(chartView.axisX().min > xMin); | |
148 | compare(chartView.axisY().max, yMax); |
|
148 | compare(chartView.axisY().max, yMax); | |
149 | compare(chartView.axisY().min, yMin); |
|
149 | compare(chartView.axisY().min, yMin); | |
150 | } |
|
150 | } | |
151 | } |
|
151 | } | |
152 |
|
152 | |||
153 | ChartView { |
|
153 | ChartView { | |
154 | id: chartView |
|
154 | id: chartView | |
155 | anchors.fill: parent |
|
155 | anchors.fill: parent | |
156 | title: "Chart" |
|
156 | title: "Chart" | |
157 | } |
|
157 | } | |
158 | } |
|
158 | } |
@@ -1,71 +1,71 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | import QtQuick 2.0 |
|
19 | import QtQuick 2.0 | |
20 | import QtTest 1.0 |
|
20 | import QtTest 1.0 | |
21 |
import QtCharts 2. |
|
21 | import QtCharts 2.1 | |
22 |
|
22 | |||
23 | Rectangle { |
|
23 | Rectangle { | |
24 | width: 400 |
|
24 | width: 400 | |
25 | height: 300 |
|
25 | height: 300 | |
26 |
|
26 | |||
27 | TestCase { |
|
27 | TestCase { | |
28 | id: tc1 |
|
28 | id: tc1 | |
29 | name: "tst_qml-qtquicktest ChartView Signals" |
|
29 | name: "tst_qml-qtquicktest ChartView Signals" | |
30 | when: windowShown |
|
30 | when: windowShown | |
31 |
|
31 | |||
32 | // Verify onSeriesAdded and onSeriesRemoved signals |
|
32 | // Verify onSeriesAdded and onSeriesRemoved signals | |
33 | function test_chartView() { |
|
33 | function test_chartView() { | |
34 | var series = chartView.createSeries(ChartView.SeriesTypeLine, "line"); |
|
34 | var series = chartView.createSeries(ChartView.SeriesTypeLine, "line"); | |
35 | seriesAddedSpy.wait(); |
|
35 | seriesAddedSpy.wait(); | |
36 | compare(seriesAddedSpy.count, 1, "ChartView.onSeriesAdded"); |
|
36 | compare(seriesAddedSpy.count, 1, "ChartView.onSeriesAdded"); | |
37 |
|
37 | |||
38 | // Modifying layout triggers more than one plotAreaChanged signal |
|
38 | // Modifying layout triggers more than one plotAreaChanged signal | |
39 | chartView.titleFont.pixelSize = 50; |
|
39 | chartView.titleFont.pixelSize = 50; | |
40 | verify(plotAreaChangedSpy.count > 0, "ChartView.onPlotAreaChanged"); |
|
40 | verify(plotAreaChangedSpy.count > 0, "ChartView.onPlotAreaChanged"); | |
41 |
|
41 | |||
42 | chartView.removeSeries(series); |
|
42 | chartView.removeSeries(series); | |
43 | seriesRemovedSpy.wait(); |
|
43 | seriesRemovedSpy.wait(); | |
44 | compare(seriesRemovedSpy.count, 1, "ChartView.onSeriesAdded"); |
|
44 | compare(seriesRemovedSpy.count, 1, "ChartView.onSeriesAdded"); | |
45 | } |
|
45 | } | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | ChartView { |
|
48 | ChartView { | |
49 | id: chartView |
|
49 | id: chartView | |
50 | anchors.fill: parent |
|
50 | anchors.fill: parent | |
51 | title: "Chart" |
|
51 | title: "Chart" | |
52 |
|
52 | |||
53 | SignalSpy { |
|
53 | SignalSpy { | |
54 | id: plotAreaChangedSpy |
|
54 | id: plotAreaChangedSpy | |
55 | target: chartView |
|
55 | target: chartView | |
56 | signalName: "plotAreaChanged" |
|
56 | signalName: "plotAreaChanged" | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | SignalSpy { |
|
59 | SignalSpy { | |
60 | id: seriesAddedSpy |
|
60 | id: seriesAddedSpy | |
61 | target: chartView |
|
61 | target: chartView | |
62 | signalName: "seriesAdded" |
|
62 | signalName: "seriesAdded" | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | SignalSpy { |
|
65 | SignalSpy { | |
66 | id: seriesRemovedSpy |
|
66 | id: seriesRemovedSpy | |
67 | target: chartView |
|
67 | target: chartView | |
68 | signalName: "seriesRemoved" |
|
68 | signalName: "seriesRemoved" | |
69 | } |
|
69 | } | |
70 | } |
|
70 | } | |
71 | } |
|
71 | } |
@@ -1,133 +1,133 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | import QtQuick 2.0 |
|
19 | import QtQuick 2.0 | |
20 | import QtTest 1.0 |
|
20 | import QtTest 1.0 | |
21 |
import QtCharts 2. |
|
21 | import QtCharts 2.1 | |
22 |
|
22 | |||
23 | Rectangle { |
|
23 | Rectangle { | |
24 | width: 400 |
|
24 | width: 400 | |
25 | height: 300 |
|
25 | height: 300 | |
26 |
|
26 | |||
27 | TestCase { |
|
27 | TestCase { | |
28 | id: tc1 |
|
28 | id: tc1 | |
29 | name: "tst_qml-qtquicktest PieSeries" |
|
29 | name: "tst_qml-qtquicktest PieSeries" | |
30 | when: windowShown |
|
30 | when: windowShown | |
31 |
|
31 | |||
32 | function test_properties() { |
|
32 | function test_properties() { | |
33 | compare(pieSeries.endAngle, 360); |
|
33 | compare(pieSeries.endAngle, 360); | |
34 | compare(pieSeries.holeSize, 0); |
|
34 | compare(pieSeries.holeSize, 0); | |
35 | compare(pieSeries.horizontalPosition, 0.5); |
|
35 | compare(pieSeries.horizontalPosition, 0.5); | |
36 | compare(pieSeries.size, 0.7); |
|
36 | compare(pieSeries.size, 0.7); | |
37 | compare(pieSeries.startAngle, 0); |
|
37 | compare(pieSeries.startAngle, 0); | |
38 | compare(pieSeries.sum, 0); |
|
38 | compare(pieSeries.sum, 0); | |
39 | compare(pieSeries.verticalPosition, 0.5); |
|
39 | compare(pieSeries.verticalPosition, 0.5); | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | function test_sliceproperties() { |
|
42 | function test_sliceproperties() { | |
43 | var slice = pieSeries.append("slice", 10); |
|
43 | var slice = pieSeries.append("slice", 10); | |
44 | compare(slice.angleSpan, 360.0); |
|
44 | compare(slice.angleSpan, 360.0); | |
45 | verify(slice.borderColor != undefined); |
|
45 | verify(slice.borderColor != undefined); | |
46 | compare(slice.borderWidth, 1); |
|
46 | compare(slice.borderWidth, 1); | |
47 | verify(slice.color != undefined); |
|
47 | verify(slice.color != undefined); | |
48 | compare(slice.explodeDistanceFactor, 0.15); |
|
48 | compare(slice.explodeDistanceFactor, 0.15); | |
49 | compare(slice.exploded, false); |
|
49 | compare(slice.exploded, false); | |
50 | compare(slice.label, "slice"); |
|
50 | compare(slice.label, "slice"); | |
51 | compare(slice.labelArmLengthFactor, 0.15); |
|
51 | compare(slice.labelArmLengthFactor, 0.15); | |
52 | verify(slice.labelColor != undefined); |
|
52 | verify(slice.labelColor != undefined); | |
53 | compare(slice.labelFont.bold, false); |
|
53 | compare(slice.labelFont.bold, false); | |
54 | compare(slice.labelPosition, PieSlice.LabelOutside); |
|
54 | compare(slice.labelPosition, PieSlice.LabelOutside); | |
55 | compare(slice.labelVisible, false); |
|
55 | compare(slice.labelVisible, false); | |
56 | compare(slice.percentage, 1.0); |
|
56 | compare(slice.percentage, 1.0); | |
57 | compare(slice.startAngle, 0.0); |
|
57 | compare(slice.startAngle, 0.0); | |
58 | compare(slice.value, 10.0); |
|
58 | compare(slice.value, 10.0); | |
59 | compare(slice.brushFilename, ""); |
|
59 | compare(slice.brushFilename, ""); | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | function test_append() { |
|
62 | function test_append() { | |
63 | addedSpy.clear(); |
|
63 | addedSpy.clear(); | |
64 | countChangedSpy.clear(); |
|
64 | countChangedSpy.clear(); | |
65 | sumChangedSpy.clear(); |
|
65 | sumChangedSpy.clear(); | |
66 | var count = 50; |
|
66 | var count = 50; | |
67 | for (var i = 0; i < count; i++) |
|
67 | for (var i = 0; i < count; i++) | |
68 | pieSeries.append("slice" + i, Math.random()); |
|
68 | pieSeries.append("slice" + i, Math.random()); | |
69 | compare(addedSpy.count, count); |
|
69 | compare(addedSpy.count, count); | |
70 | compare(countChangedSpy.count, count); |
|
70 | compare(countChangedSpy.count, count); | |
71 | compare(sumChangedSpy.count, count); |
|
71 | compare(sumChangedSpy.count, count); | |
72 | pieSeries.clear(); |
|
72 | pieSeries.clear(); | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | function test_remove() { |
|
75 | function test_remove() { | |
76 | removedSpy.clear(); |
|
76 | removedSpy.clear(); | |
77 | countChangedSpy.clear(); |
|
77 | countChangedSpy.clear(); | |
78 | sumChangedSpy.clear(); |
|
78 | sumChangedSpy.clear(); | |
79 | var count = 50; |
|
79 | var count = 50; | |
80 | for (var i = 0; i < count; i++) |
|
80 | for (var i = 0; i < count; i++) | |
81 | pieSeries.append("slice" + i, Math.random()); |
|
81 | pieSeries.append("slice" + i, Math.random()); | |
82 | for (var j = 0; j < count; j++) |
|
82 | for (var j = 0; j < count; j++) | |
83 | pieSeries.remove(pieSeries.at(0)); |
|
83 | pieSeries.remove(pieSeries.at(0)); | |
84 | compare(removedSpy.count, count); |
|
84 | compare(removedSpy.count, count); | |
85 | compare(countChangedSpy.count, 2 * count); |
|
85 | compare(countChangedSpy.count, 2 * count); | |
86 | compare(sumChangedSpy.count, 2 * count); |
|
86 | compare(sumChangedSpy.count, 2 * count); | |
87 | compare(pieSeries.count, 0); |
|
87 | compare(pieSeries.count, 0); | |
88 | } |
|
88 | } | |
89 |
|
89 | |||
90 | function test_find_and_at() { |
|
90 | function test_find_and_at() { | |
91 | var count = 50; |
|
91 | var count = 50; | |
92 | for (var i = 0; i < count; i++) |
|
92 | for (var i = 0; i < count; i++) | |
93 | pieSeries.append("slice" + i, Math.random()); |
|
93 | pieSeries.append("slice" + i, Math.random()); | |
94 | for (var j = 0; j < count; j++) { |
|
94 | for (var j = 0; j < count; j++) { | |
95 | compare(pieSeries.find("slice" + j).label, "slice" + j); |
|
95 | compare(pieSeries.find("slice" + j).label, "slice" + j); | |
96 | compare(pieSeries.find("slice" + j).brushFilename, ""); |
|
96 | compare(pieSeries.find("slice" + j).brushFilename, ""); | |
97 | } |
|
97 | } | |
98 | compare(pieSeries.at(3).brushFilename,""); |
|
98 | compare(pieSeries.at(3).brushFilename,""); | |
99 | pieSeries.clear(); |
|
99 | pieSeries.clear(); | |
100 | } |
|
100 | } | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | ChartView { |
|
103 | ChartView { | |
104 | id: chartView |
|
104 | id: chartView | |
105 | anchors.fill: parent |
|
105 | anchors.fill: parent | |
106 |
|
106 | |||
107 | PieSeries { |
|
107 | PieSeries { | |
108 | id: pieSeries |
|
108 | id: pieSeries | |
109 | name: "pie" |
|
109 | name: "pie" | |
110 |
|
110 | |||
111 | SignalSpy { |
|
111 | SignalSpy { | |
112 | id: addedSpy |
|
112 | id: addedSpy | |
113 | target: pieSeries |
|
113 | target: pieSeries | |
114 | signalName: "added" |
|
114 | signalName: "added" | |
115 | } |
|
115 | } | |
116 | SignalSpy { |
|
116 | SignalSpy { | |
117 | id: removedSpy |
|
117 | id: removedSpy | |
118 | target: pieSeries |
|
118 | target: pieSeries | |
119 | signalName: "removed" |
|
119 | signalName: "removed" | |
120 | } |
|
120 | } | |
121 | SignalSpy { |
|
121 | SignalSpy { | |
122 | id: sumChangedSpy |
|
122 | id: sumChangedSpy | |
123 | target: pieSeries |
|
123 | target: pieSeries | |
124 | signalName: "sumChanged" |
|
124 | signalName: "sumChanged" | |
125 | } |
|
125 | } | |
126 | SignalSpy { |
|
126 | SignalSpy { | |
127 | id: countChangedSpy |
|
127 | id: countChangedSpy | |
128 | target: pieSeries |
|
128 | target: pieSeries | |
129 | signalName: "countChanged" |
|
129 | signalName: "countChanged" | |
130 | } |
|
130 | } | |
131 | } |
|
131 | } | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } |
@@ -1,115 +1,115 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | import QtQuick 2.0 |
|
19 | import QtQuick 2.0 | |
20 | import QtTest 1.0 |
|
20 | import QtTest 1.0 | |
21 | import QtCharts 2.0 |
|
21 | import QtCharts 2.0 | |
22 |
|
22 | |||
23 | Rectangle { |
|
23 | Rectangle { | |
24 | width: 400 |
|
24 | width: 400 | |
25 | height: 300 |
|
25 | height: 300 | |
26 |
|
26 | |||
27 | TestCase { |
|
27 | TestCase { | |
28 | id: tc1 |
|
28 | id: tc1 | |
29 | name: "tst_qml-qtquicktest ValueAxis" |
|
29 | name: "tst_qml-qtquicktest ValueAxis 2.0" | |
30 | when: windowShown |
|
30 | when: windowShown | |
31 |
|
31 | |||
32 | // test functions are run in alphabetical order, the name has 'a' so that it |
|
32 | // test functions are run in alphabetical order, the name has 'a' so that it | |
33 | // will be the first function to execute. |
|
33 | // will be the first function to execute. | |
34 | function test_a_properties() { |
|
34 | function test_a_properties() { | |
35 | // Default properties |
|
35 | // Default properties | |
36 | verify(axisX.min < 0, "AxisX min"); |
|
36 | verify(axisX.min < 0, "AxisX min"); | |
37 | verify(axisX.max > 0, "AxisX max"); |
|
37 | verify(axisX.max > 0, "AxisX max"); | |
38 | verify(axisY.min < 0, "AxisY min"); |
|
38 | verify(axisY.min < 0, "AxisY min"); | |
39 | verify(axisY.max > 0, "AxisY max"); |
|
39 | verify(axisY.max > 0, "AxisY max"); | |
40 | verify(axisX.tickCount == 5, "AxisX tick count"); |
|
40 | verify(axisX.tickCount == 5, "AxisX tick count"); | |
41 | verify(axisY.tickCount == 5, "AxisY tick count"); |
|
41 | verify(axisY.tickCount == 5, "AxisY tick count"); | |
42 | verify(axisX.labelFormat == "", "label format"); |
|
42 | verify(axisX.labelFormat == "", "label format"); | |
43 |
|
43 | |||
44 | // Modify properties |
|
44 | // Modify properties | |
45 | axisX.tickCount = 3; |
|
45 | axisX.tickCount = 3; | |
46 | verify(axisX.tickCount == 3, "set tick count"); |
|
46 | verify(axisX.tickCount == 3, "set tick count"); | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | function test_functions() { |
|
49 | function test_functions() { | |
50 | // Set the axis ranges to not "nice" ones... |
|
50 | // Set the axis ranges to not "nice" ones... | |
51 | var min = 0.032456456; |
|
51 | var min = 0.032456456; | |
52 | var max = 10.67845634; |
|
52 | var max = 10.67845634; | |
53 | axisX.min = min; |
|
53 | axisX.min = min; | |
54 | axisX.max = max; |
|
54 | axisX.max = max; | |
55 | axisY.min = min; |
|
55 | axisY.min = min; | |
56 | axisY.max = max; |
|
56 | axisY.max = max; | |
57 |
|
57 | |||
58 | // ...And then apply nice numbers and verify the range was changed |
|
58 | // ...And then apply nice numbers and verify the range was changed | |
59 | axisX.applyNiceNumbers(); |
|
59 | axisX.applyNiceNumbers(); | |
60 | axisY.applyNiceNumbers(); |
|
60 | axisY.applyNiceNumbers(); | |
61 | verify(axisX.min != min); |
|
61 | verify(axisX.min != min); | |
62 | verify(axisX.max != max); |
|
62 | verify(axisX.max != max); | |
63 | verify(axisY.min != min); |
|
63 | verify(axisY.min != min); | |
64 | verify(axisY.max != max); |
|
64 | verify(axisY.max != max); | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | function test_signals() { |
|
67 | function test_signals() { | |
68 | minChangedSpy.clear(); |
|
68 | minChangedSpy.clear(); | |
69 | maxChangedSpy.clear(); |
|
69 | maxChangedSpy.clear(); | |
70 |
|
70 | |||
71 | axisX.min = 2; |
|
71 | axisX.min = 2; | |
72 | compare(minChangedSpy.count, 1, "onMinChanged"); |
|
72 | compare(minChangedSpy.count, 1, "onMinChanged"); | |
73 | compare(maxChangedSpy.count, 0, "onMaxChanged"); |
|
73 | compare(maxChangedSpy.count, 0, "onMaxChanged"); | |
74 |
|
74 | |||
75 | axisX.max = 8; |
|
75 | axisX.max = 8; | |
76 | compare(minChangedSpy.count, 1, "onMinChanged"); |
|
76 | compare(minChangedSpy.count, 1, "onMinChanged"); | |
77 | compare(maxChangedSpy.count, 1, "onMaxChanged"); |
|
77 | compare(maxChangedSpy.count, 1, "onMaxChanged"); | |
78 |
|
78 | |||
79 | // restore original values |
|
79 | // restore original values | |
80 | axisX.min = 0; |
|
80 | axisX.min = 0; | |
81 | axisX.max = 10; |
|
81 | axisX.max = 10; | |
82 | compare(minChangedSpy.count, 2, "onMinChanged"); |
|
82 | compare(minChangedSpy.count, 2, "onMinChanged"); | |
83 | compare(maxChangedSpy.count, 2, "onMaxChanged"); |
|
83 | compare(maxChangedSpy.count, 2, "onMaxChanged"); | |
84 | } |
|
84 | } | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | ChartView { |
|
87 | ChartView { | |
88 | id: chartView |
|
88 | id: chartView | |
89 | anchors.fill: parent |
|
89 | anchors.fill: parent | |
90 |
|
90 | |||
91 | LineSeries { |
|
91 | LineSeries { | |
92 | id: lineSeries1 |
|
92 | id: lineSeries1 | |
93 | axisX: ValueAxis { |
|
93 | axisX: ValueAxis { | |
94 | id: axisX |
|
94 | id: axisX | |
95 | } |
|
95 | } | |
96 | axisY: ValueAxis { |
|
96 | axisY: ValueAxis { | |
97 | id: axisY |
|
97 | id: axisY | |
98 | } |
|
98 | } | |
99 | XYPoint { x: -1; y: -1 } |
|
99 | XYPoint { x: -1; y: -1 } | |
100 | XYPoint { x: 0; y: 0 } |
|
100 | XYPoint { x: 0; y: 0 } | |
101 | XYPoint { x: 5; y: 5 } |
|
101 | XYPoint { x: 5; y: 5 } | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 | SignalSpy { |
|
104 | SignalSpy { | |
105 | id: minChangedSpy |
|
105 | id: minChangedSpy | |
106 | target: axisX |
|
106 | target: axisX | |
107 | signalName: "minChanged" |
|
107 | signalName: "minChanged" | |
108 | } |
|
108 | } | |
109 | SignalSpy { |
|
109 | SignalSpy { | |
110 | id: maxChangedSpy |
|
110 | id: maxChangedSpy | |
111 | target: axisX |
|
111 | target: axisX | |
112 | signalName: "maxChanged" |
|
112 | signalName: "maxChanged" | |
113 | } |
|
113 | } | |
114 | } |
|
114 | } | |
115 | } |
|
115 | } |
@@ -1,260 +1,260 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | import QtQuick 2.0 |
|
19 | import QtQuick 2.0 | |
20 | import QtTest 1.0 |
|
20 | import QtTest 1.0 | |
21 | import QtCharts 2.0 |
|
21 | import QtCharts 2.0 | |
22 |
|
22 | |||
23 | Rectangle { |
|
23 | Rectangle { | |
24 | width: 400 |
|
24 | width: 400 | |
25 | height: 300 |
|
25 | height: 300 | |
26 |
|
26 | |||
27 | TestCase { |
|
27 | TestCase { | |
28 | id: tc1 |
|
28 | id: tc1 | |
29 | name: "tst_qml-qtquicktest XY Series" |
|
29 | name: "tst_qml-qtquicktest XY Series 2.0" | |
30 | when: windowShown |
|
30 | when: windowShown | |
31 |
|
31 | |||
32 | function test_properties() { |
|
32 | function test_properties() { | |
33 | verify(lineSeries.color != undefined); |
|
33 | verify(lineSeries.color != undefined); | |
34 | compare(lineSeries.pointsVisible, false); |
|
34 | compare(lineSeries.pointsVisible, false); | |
35 | compare(lineSeries.capStyle, Qt.SquareCap); |
|
35 | compare(lineSeries.capStyle, Qt.SquareCap); | |
36 | compare(lineSeries.style, Qt.SolidLine); |
|
36 | compare(lineSeries.style, Qt.SolidLine); | |
37 | compare(lineSeries.width, 2.0); |
|
37 | compare(lineSeries.width, 2.0); | |
38 |
|
38 | |||
39 | verify(splineSeries.color != undefined); |
|
39 | verify(splineSeries.color != undefined); | |
40 | compare(splineSeries.pointsVisible, false); |
|
40 | compare(splineSeries.pointsVisible, false); | |
41 | compare(splineSeries.capStyle, Qt.SquareCap); |
|
41 | compare(splineSeries.capStyle, Qt.SquareCap); | |
42 | compare(splineSeries.style, Qt.SolidLine); |
|
42 | compare(splineSeries.style, Qt.SolidLine); | |
43 | compare(splineSeries.width, 2.0); |
|
43 | compare(splineSeries.width, 2.0); | |
44 |
|
44 | |||
45 | verify(scatterSeries.color != undefined); |
|
45 | verify(scatterSeries.color != undefined); | |
46 | verify(scatterSeries.borderColor != undefined); |
|
46 | verify(scatterSeries.borderColor != undefined); | |
47 | compare(scatterSeries.borderWidth, 2.0); |
|
47 | compare(scatterSeries.borderWidth, 2.0); | |
48 | compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle); |
|
48 | compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle); | |
49 | compare(scatterSeries.markerSize, 15.0); |
|
49 | compare(scatterSeries.markerSize, 15.0); | |
50 | compare(scatterSeries.brushFilename, ""); |
|
50 | compare(scatterSeries.brushFilename, ""); | |
51 |
|
51 | |||
52 | verify(areaSeries.color != undefined); |
|
52 | verify(areaSeries.color != undefined); | |
53 | verify(areaSeries.borderColor != undefined); |
|
53 | verify(areaSeries.borderColor != undefined); | |
54 | compare(areaSeries.borderWidth, 2.0); |
|
54 | compare(areaSeries.borderWidth, 2.0); | |
55 | compare(areaSeries.brushFilename, ""); |
|
55 | compare(areaSeries.brushFilename, ""); | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | function test_axes() { |
|
58 | function test_axes() { | |
59 | // Axis initialization |
|
59 | // Axis initialization | |
60 | compare(chartView.axisX(), lineSeries.axisX); |
|
60 | compare(chartView.axisX(), lineSeries.axisX); | |
61 | compare(chartView.axisY(), lineSeries.axisY); |
|
61 | compare(chartView.axisY(), lineSeries.axisY); | |
62 | compare(lineSeries.axisX, splineSeries.axisX); |
|
62 | compare(lineSeries.axisX, splineSeries.axisX); | |
63 | compare(lineSeries.axisY, splineSeries.axisY); |
|
63 | compare(lineSeries.axisY, splineSeries.axisY); | |
64 | compare(lineSeries.axisX, areaSeries.axisX); |
|
64 | compare(lineSeries.axisX, areaSeries.axisX); | |
65 | compare(lineSeries.axisY, areaSeries.axisY); |
|
65 | compare(lineSeries.axisY, areaSeries.axisY); | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | function test_append() { |
|
68 | function test_append() { | |
69 | lineSeriesPointAddedSpy.clear(); |
|
69 | lineSeriesPointAddedSpy.clear(); | |
70 | splineSeriesPointAddedSpy.clear(); |
|
70 | splineSeriesPointAddedSpy.clear(); | |
71 | scatterSeriesPointAddedSpy.clear(); |
|
71 | scatterSeriesPointAddedSpy.clear(); | |
72 | var count = append(); |
|
72 | var count = append(); | |
73 | compare(lineSeries.count, count); |
|
73 | compare(lineSeries.count, count); | |
74 | compare(splineSeries.count, count); |
|
74 | compare(splineSeries.count, count); | |
75 | compare(scatterSeries.count, count); |
|
75 | compare(scatterSeries.count, count); | |
76 | compare(lineSeriesPointAddedSpy.count, count); |
|
76 | compare(lineSeriesPointAddedSpy.count, count); | |
77 | compare(splineSeriesPointAddedSpy.count, count); |
|
77 | compare(splineSeriesPointAddedSpy.count, count); | |
78 | compare(scatterSeriesPointAddedSpy.count, count); |
|
78 | compare(scatterSeriesPointAddedSpy.count, count); | |
79 | clear(); |
|
79 | clear(); | |
80 | compare(lineSeries.count, 0); |
|
80 | compare(lineSeries.count, 0); | |
81 | compare(splineSeries.count, 0); |
|
81 | compare(splineSeries.count, 0); | |
82 | compare(scatterSeries.count, 0); |
|
82 | compare(scatterSeries.count, 0); | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | function test_replace() { |
|
85 | function test_replace() { | |
86 | var count = append(); |
|
86 | var count = append(); | |
87 | for (var i = 0; i < count; i++) { |
|
87 | for (var i = 0; i < count; i++) { | |
88 | lineSeries.replace(lineSeries.at(i).x, lineSeries.at(i).y, i, Math.random()); |
|
88 | lineSeries.replace(lineSeries.at(i).x, lineSeries.at(i).y, i, Math.random()); | |
89 | splineSeries.replace(splineSeries.at(i).x, splineSeries.at(i).y, i, Math.random()); |
|
89 | splineSeries.replace(splineSeries.at(i).x, splineSeries.at(i).y, i, Math.random()); | |
90 | scatterSeries.replace(scatterSeries.at(i).x, scatterSeries.at(i).y, i, Math.random()); |
|
90 | scatterSeries.replace(scatterSeries.at(i).x, scatterSeries.at(i).y, i, Math.random()); | |
91 | } |
|
91 | } | |
92 | compare(lineSeries.count, count); |
|
92 | compare(lineSeries.count, count); | |
93 | compare(splineSeries.count, count); |
|
93 | compare(splineSeries.count, count); | |
94 | compare(scatterSeries.count, count); |
|
94 | compare(scatterSeries.count, count); | |
95 | compare(lineSeriesPointReplacedSpy.count, count); |
|
95 | compare(lineSeriesPointReplacedSpy.count, count); | |
96 | compare(splineSeriesPointReplacedSpy.count, count); |
|
96 | compare(splineSeriesPointReplacedSpy.count, count); | |
97 | compare(scatterSeriesPointReplacedSpy.count, count); |
|
97 | compare(scatterSeriesPointReplacedSpy.count, count); | |
98 | clear(); |
|
98 | clear(); | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 | function test_insert() { |
|
101 | function test_insert() { | |
102 | var count = append(); |
|
102 | var count = append(); | |
103 | lineSeriesPointAddedSpy.clear(); |
|
103 | lineSeriesPointAddedSpy.clear(); | |
104 | splineSeriesPointAddedSpy.clear(); |
|
104 | splineSeriesPointAddedSpy.clear(); | |
105 | scatterSeriesPointAddedSpy.clear(); |
|
105 | scatterSeriesPointAddedSpy.clear(); | |
106 | for (var i = 0; i < count; i++) { |
|
106 | for (var i = 0; i < count; i++) { | |
107 | lineSeries.insert(i * 2, i, Math.random()); |
|
107 | lineSeries.insert(i * 2, i, Math.random()); | |
108 | splineSeries.insert(i * 2, i, Math.random()); |
|
108 | splineSeries.insert(i * 2, i, Math.random()); | |
109 | scatterSeries.insert(i * 2, i, Math.random()); |
|
109 | scatterSeries.insert(i * 2, i, Math.random()); | |
110 | } |
|
110 | } | |
111 | compare(lineSeries.count, count * 2); |
|
111 | compare(lineSeries.count, count * 2); | |
112 | compare(splineSeries.count, count * 2); |
|
112 | compare(splineSeries.count, count * 2); | |
113 | compare(scatterSeries.count, count * 2); |
|
113 | compare(scatterSeries.count, count * 2); | |
114 | compare(lineSeriesPointAddedSpy.count, count); |
|
114 | compare(lineSeriesPointAddedSpy.count, count); | |
115 | compare(splineSeriesPointAddedSpy.count, count); |
|
115 | compare(splineSeriesPointAddedSpy.count, count); | |
116 | compare(scatterSeriesPointAddedSpy.count, count); |
|
116 | compare(scatterSeriesPointAddedSpy.count, count); | |
117 | clear(); |
|
117 | clear(); | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | function test_remove() { |
|
120 | function test_remove() { | |
121 | lineSeriesPointRemovedSpy.clear(); |
|
121 | lineSeriesPointRemovedSpy.clear(); | |
122 | splineSeriesPointRemovedSpy.clear(); |
|
122 | splineSeriesPointRemovedSpy.clear(); | |
123 | scatterSeriesPointRemovedSpy.clear(); |
|
123 | scatterSeriesPointRemovedSpy.clear(); | |
124 | var count = append(); |
|
124 | var count = append(); | |
125 | for (var i = 0; i < count; i++) { |
|
125 | for (var i = 0; i < count; i++) { | |
126 | lineSeries.remove(lineSeries.at(0).x, lineSeries.at(0).y); |
|
126 | lineSeries.remove(lineSeries.at(0).x, lineSeries.at(0).y); | |
127 | splineSeries.remove(splineSeries.at(0).x, splineSeries.at(0).y); |
|
127 | splineSeries.remove(splineSeries.at(0).x, splineSeries.at(0).y); | |
128 | scatterSeries.remove(scatterSeries.at(0).x, scatterSeries.at(0).y); |
|
128 | scatterSeries.remove(scatterSeries.at(0).x, scatterSeries.at(0).y); | |
129 | } |
|
129 | } | |
130 | compare(lineSeries.count, 0); |
|
130 | compare(lineSeries.count, 0); | |
131 | compare(splineSeries.count, 0); |
|
131 | compare(splineSeries.count, 0); | |
132 | compare(scatterSeries.count, 0); |
|
132 | compare(scatterSeries.count, 0); | |
133 | compare(lineSeriesPointRemovedSpy.count, count); |
|
133 | compare(lineSeriesPointRemovedSpy.count, count); | |
134 | compare(splineSeriesPointRemovedSpy.count, count); |
|
134 | compare(splineSeriesPointRemovedSpy.count, count); | |
135 | compare(scatterSeriesPointRemovedSpy.count, count); |
|
135 | compare(scatterSeriesPointRemovedSpy.count, count); | |
136 | } |
|
136 | } | |
137 |
|
137 | |||
138 | // Not a test function, called from test functions |
|
138 | // Not a test function, called from test functions | |
139 | function append() { |
|
139 | function append() { | |
140 | var count = 100; |
|
140 | var count = 100; | |
141 | chartView.axisX().min = 0; |
|
141 | chartView.axisX().min = 0; | |
142 | chartView.axisX().max = 100; |
|
142 | chartView.axisX().max = 100; | |
143 | chartView.axisY().min = 0; |
|
143 | chartView.axisY().min = 0; | |
144 | chartView.axisY().max = 1; |
|
144 | chartView.axisY().max = 1; | |
145 |
|
145 | |||
146 | for (var i = 0; i < count; i++) { |
|
146 | for (var i = 0; i < count; i++) { | |
147 | lineSeries.append(i, Math.random()); |
|
147 | lineSeries.append(i, Math.random()); | |
148 | splineSeries.append(i, Math.random()); |
|
148 | splineSeries.append(i, Math.random()); | |
149 | scatterSeries.append(i, Math.random()); |
|
149 | scatterSeries.append(i, Math.random()); | |
150 | } |
|
150 | } | |
151 |
|
151 | |||
152 | return count; |
|
152 | return count; | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | // Not a test function, called from test functions |
|
155 | // Not a test function, called from test functions | |
156 | function clear() { |
|
156 | function clear() { | |
157 | lineSeries.clear(); |
|
157 | lineSeries.clear(); | |
158 | splineSeries.clear(); |
|
158 | splineSeries.clear(); | |
159 | scatterSeries.clear(); |
|
159 | scatterSeries.clear(); | |
160 | } |
|
160 | } | |
161 | } |
|
161 | } | |
162 |
|
162 | |||
163 | ChartView { |
|
163 | ChartView { | |
164 | id: chartView |
|
164 | id: chartView | |
165 | anchors.fill: parent |
|
165 | anchors.fill: parent | |
166 |
|
166 | |||
167 | LineSeries { |
|
167 | LineSeries { | |
168 | id: lineSeries |
|
168 | id: lineSeries | |
169 | name: "line" |
|
169 | name: "line" | |
170 |
|
170 | |||
171 | SignalSpy { |
|
171 | SignalSpy { | |
172 | id: lineSeriesPointAddedSpy |
|
172 | id: lineSeriesPointAddedSpy | |
173 | target: lineSeries |
|
173 | target: lineSeries | |
174 | signalName: "pointAdded" |
|
174 | signalName: "pointAdded" | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | SignalSpy { |
|
177 | SignalSpy { | |
178 | id: lineSeriesPointReplacedSpy |
|
178 | id: lineSeriesPointReplacedSpy | |
179 | target: lineSeries |
|
179 | target: lineSeries | |
180 | signalName: "pointReplaced" |
|
180 | signalName: "pointReplaced" | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | SignalSpy { |
|
183 | SignalSpy { | |
184 | id: lineSeriesPointsReplacedSpy |
|
184 | id: lineSeriesPointsReplacedSpy | |
185 | target: lineSeries |
|
185 | target: lineSeries | |
186 | signalName: "pointsReplaced" |
|
186 | signalName: "pointsReplaced" | |
187 | } |
|
187 | } | |
188 |
|
188 | |||
189 | SignalSpy { |
|
189 | SignalSpy { | |
190 | id: lineSeriesPointRemovedSpy |
|
190 | id: lineSeriesPointRemovedSpy | |
191 | target: lineSeries |
|
191 | target: lineSeries | |
192 | signalName: "pointRemoved" |
|
192 | signalName: "pointRemoved" | |
193 | } |
|
193 | } | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | AreaSeries { |
|
196 | AreaSeries { | |
197 | id: areaSeries |
|
197 | id: areaSeries | |
198 | name: "area" |
|
198 | name: "area" | |
199 | upperSeries: lineSeries |
|
199 | upperSeries: lineSeries | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | SplineSeries { |
|
202 | SplineSeries { | |
203 | id: splineSeries |
|
203 | id: splineSeries | |
204 | name: "spline" |
|
204 | name: "spline" | |
205 |
|
205 | |||
206 | SignalSpy { |
|
206 | SignalSpy { | |
207 | id: splineSeriesPointAddedSpy |
|
207 | id: splineSeriesPointAddedSpy | |
208 | target: splineSeries |
|
208 | target: splineSeries | |
209 | signalName: "pointAdded" |
|
209 | signalName: "pointAdded" | |
210 | } |
|
210 | } | |
211 |
|
211 | |||
212 | SignalSpy { |
|
212 | SignalSpy { | |
213 | id: splineSeriesPointReplacedSpy |
|
213 | id: splineSeriesPointReplacedSpy | |
214 | target: splineSeries |
|
214 | target: splineSeries | |
215 | signalName: "pointReplaced" |
|
215 | signalName: "pointReplaced" | |
216 | } |
|
216 | } | |
217 |
|
217 | |||
218 | SignalSpy { |
|
218 | SignalSpy { | |
219 | id: splineSeriesPointsReplacedSpy |
|
219 | id: splineSeriesPointsReplacedSpy | |
220 | target: splineSeries |
|
220 | target: splineSeries | |
221 | signalName: "pointsReplaced" |
|
221 | signalName: "pointsReplaced" | |
222 | } |
|
222 | } | |
223 |
|
223 | |||
224 | SignalSpy { |
|
224 | SignalSpy { | |
225 | id: splineSeriesPointRemovedSpy |
|
225 | id: splineSeriesPointRemovedSpy | |
226 | target: splineSeries |
|
226 | target: splineSeries | |
227 | signalName: "pointRemoved" |
|
227 | signalName: "pointRemoved" | |
228 | } |
|
228 | } | |
229 | } |
|
229 | } | |
230 |
|
230 | |||
231 | ScatterSeries { |
|
231 | ScatterSeries { | |
232 | id: scatterSeries |
|
232 | id: scatterSeries | |
233 | name: "scatter" |
|
233 | name: "scatter" | |
234 |
|
234 | |||
235 | SignalSpy { |
|
235 | SignalSpy { | |
236 | id: scatterSeriesPointAddedSpy |
|
236 | id: scatterSeriesPointAddedSpy | |
237 | target: scatterSeries |
|
237 | target: scatterSeries | |
238 | signalName: "pointAdded" |
|
238 | signalName: "pointAdded" | |
239 | } |
|
239 | } | |
240 |
|
240 | |||
241 | SignalSpy { |
|
241 | SignalSpy { | |
242 | id: scatterSeriesPointReplacedSpy |
|
242 | id: scatterSeriesPointReplacedSpy | |
243 | target: scatterSeries |
|
243 | target: scatterSeries | |
244 | signalName: "pointReplaced" |
|
244 | signalName: "pointReplaced" | |
245 | } |
|
245 | } | |
246 |
|
246 | |||
247 | SignalSpy { |
|
247 | SignalSpy { | |
248 | id: scatterSeriesPointsReplacedSpy |
|
248 | id: scatterSeriesPointsReplacedSpy | |
249 | target: scatterSeries |
|
249 | target: scatterSeries | |
250 | signalName: "pointsReplaced" |
|
250 | signalName: "pointsReplaced" | |
251 | } |
|
251 | } | |
252 |
|
252 | |||
253 | SignalSpy { |
|
253 | SignalSpy { | |
254 | id: scatterSeriesPointRemovedSpy |
|
254 | id: scatterSeriesPointRemovedSpy | |
255 | target: scatterSeries |
|
255 | target: scatterSeries | |
256 | signalName: "pointRemoved" |
|
256 | signalName: "pointRemoved" | |
257 | } |
|
257 | } | |
258 | } |
|
258 | } | |
259 | } |
|
259 | } | |
260 | } |
|
260 | } |
General Comments 0
You need to be logged in to leave comments.
Login now