@@ -0,0 +1,125 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtQuickTest 1.0 | |
|
23 | import QtCommercial.Chart 1.2 | |
|
24 | ||
|
25 | Rectangle { | |
|
26 | width: 400 | |
|
27 | height: 300 | |
|
28 | ||
|
29 | TestCase { | |
|
30 | id: tc1 | |
|
31 | name: "tst_qml-qtquicktest BarSeries" | |
|
32 | when: windowShown | |
|
33 | ||
|
34 | function test_properties() { | |
|
35 | compare(barSeries.barWidth, 0.5); | |
|
36 | compare(barSeries.labelsVisible, false); | |
|
37 | } | |
|
38 | ||
|
39 | function test_append() { | |
|
40 | var setCount = 5; | |
|
41 | var valueCount = 50; | |
|
42 | addedSpy.clear(); | |
|
43 | append(setCount, valueCount); | |
|
44 | ||
|
45 | compare(barSeries.count, setCount); | |
|
46 | for (var k = 0; k < setCount; k++) { | |
|
47 | compare(barSeries.at(k).count, valueCount); | |
|
48 | compare(barSeries.at(k).label, "barset" + k); | |
|
49 | } | |
|
50 | compare(addedSpy.count, setCount); | |
|
51 | ||
|
52 | barSeries.clear(); | |
|
53 | compare(barSeries.count, 0); | |
|
54 | } | |
|
55 | ||
|
56 | function test_insert() { | |
|
57 | var setCount = 5; | |
|
58 | var valueCount = 50; | |
|
59 | addedSpy.clear(); | |
|
60 | append(setCount, valueCount); | |
|
61 | ||
|
62 | for (var i = 0; i < setCount; i++) { | |
|
63 | var values = []; | |
|
64 | for (var j = 0; j < valueCount; j++) | |
|
65 | values[j] = Math.random() * 10; | |
|
66 | var set = barSeries.insert(i, "barset" + i, values); | |
|
67 | compare(set.label, "barset" + i); | |
|
68 | } | |
|
69 | ||
|
70 | compare(barSeries.count, setCount * 2); | |
|
71 | for (var k = 0; k < setCount * 2; k++) | |
|
72 | compare(barSeries.at(k).count, valueCount); | |
|
73 | compare(addedSpy.count, 2 * setCount); | |
|
74 | ||
|
75 | barSeries.clear(); | |
|
76 | compare(barSeries.count, 0); | |
|
77 | } | |
|
78 | ||
|
79 | function test_remove() { | |
|
80 | var setCount = 5; | |
|
81 | var valueCount = 50; | |
|
82 | removedSpy.clear(); | |
|
83 | append(setCount, valueCount); | |
|
84 | ||
|
85 | for (var k = 0; k < setCount; k++) | |
|
86 | barSeries.remove(barSeries.at(0)); | |
|
87 | ||
|
88 | compare(barSeries.count, 0); | |
|
89 | compare(removedSpy.count, setCount); | |
|
90 | } | |
|
91 | ||
|
92 | // Not a test function, used by one or more test functions | |
|
93 | function append(setCount, valueCount) { | |
|
94 | for (var i = 0; i < setCount; i++) { | |
|
95 | var values = []; | |
|
96 | for (var j = 0; j < valueCount; j++) | |
|
97 | values[j] = Math.random() * 10; | |
|
98 | barSeries.append("barset" + i, values); | |
|
99 | } | |
|
100 | } | |
|
101 | } | |
|
102 | ||
|
103 | ChartView { | |
|
104 | id: chartView | |
|
105 | anchors.fill: parent | |
|
106 | ||
|
107 | BarSeries { | |
|
108 | axisX: BarCategoriesAxis {} | |
|
109 | axisY: ValuesAxis { min: 0; max: 10 } | |
|
110 | id: barSeries | |
|
111 | name: "bar" | |
|
112 | ||
|
113 | SignalSpy { | |
|
114 | id: addedSpy | |
|
115 | target: barSeries | |
|
116 | signalName: "barsetsAdded" | |
|
117 | } | |
|
118 | SignalSpy { | |
|
119 | id: removedSpy | |
|
120 | target: barSeries | |
|
121 | signalName: "barsetsRemoved" | |
|
122 | } | |
|
123 | } | |
|
124 | } | |
|
125 | } |
@@ -0,0 +1,125 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtQuickTest 1.0 | |
|
23 | import QtCommercial.Chart 1.1 | |
|
24 | ||
|
25 | Rectangle { | |
|
26 | width: 400 | |
|
27 | height: 300 | |
|
28 | ||
|
29 | TestCase { | |
|
30 | id: tc1 | |
|
31 | name: "tst_qml-qtquicktest BarSeries 1.1" | |
|
32 | when: windowShown | |
|
33 | ||
|
34 | function test_properties() { | |
|
35 | compare(barSeries.barWidth, 0.5); | |
|
36 | compare(barSeries.labelsVisible, false); | |
|
37 | } | |
|
38 | ||
|
39 | function test_append() { | |
|
40 | var setCount = 5; | |
|
41 | var valueCount = 50; | |
|
42 | addedSpy.clear(); | |
|
43 | append(setCount, valueCount); | |
|
44 | ||
|
45 | compare(barSeries.count, setCount); | |
|
46 | for (var k = 0; k < setCount; k++) { | |
|
47 | compare(barSeries.at(k).count, valueCount); | |
|
48 | compare(barSeries.at(k).label, "barset" + k); | |
|
49 | } | |
|
50 | compare(addedSpy.count, setCount); | |
|
51 | ||
|
52 | barSeries.clear(); | |
|
53 | compare(barSeries.count, 0); | |
|
54 | } | |
|
55 | ||
|
56 | function test_insert() { | |
|
57 | var setCount = 5; | |
|
58 | var valueCount = 50; | |
|
59 | addedSpy.clear(); | |
|
60 | append(setCount, valueCount); | |
|
61 | ||
|
62 | for (var i = 0; i < setCount; i++) { | |
|
63 | var values = []; | |
|
64 | for (var j = 0; j < valueCount; j++) | |
|
65 | values[j] = Math.random() * 10; | |
|
66 | var set = barSeries.insert(i, "barset" + i, values); | |
|
67 | compare(set.label, "barset" + i); | |
|
68 | } | |
|
69 | ||
|
70 | compare(barSeries.count, setCount * 2); | |
|
71 | for (var k = 0; k < setCount * 2; k++) | |
|
72 | compare(barSeries.at(k).count, valueCount); | |
|
73 | compare(addedSpy.count, 2 * setCount); | |
|
74 | ||
|
75 | barSeries.clear(); | |
|
76 | compare(barSeries.count, 0); | |
|
77 | } | |
|
78 | ||
|
79 | function test_remove() { | |
|
80 | var setCount = 5; | |
|
81 | var valueCount = 50; | |
|
82 | removedSpy.clear(); | |
|
83 | append(setCount, valueCount); | |
|
84 | ||
|
85 | for (var k = 0; k < setCount; k++) | |
|
86 | barSeries.remove(barSeries.at(0)); | |
|
87 | ||
|
88 | compare(barSeries.count, 0); | |
|
89 | compare(removedSpy.count, setCount); | |
|
90 | } | |
|
91 | ||
|
92 | // Not a test function, used by one or more test functions | |
|
93 | function append(setCount, valueCount) { | |
|
94 | for (var i = 0; i < setCount; i++) { | |
|
95 | var values = []; | |
|
96 | for (var j = 0; j < valueCount; j++) | |
|
97 | values[j] = Math.random() * 10; | |
|
98 | barSeries.append("barset" + i, values); | |
|
99 | } | |
|
100 | } | |
|
101 | } | |
|
102 | ||
|
103 | ChartView { | |
|
104 | id: chartView | |
|
105 | anchors.fill: parent | |
|
106 | ||
|
107 | BarSeries { | |
|
108 | axisX: BarCategoriesAxis {} | |
|
109 | axisY: ValuesAxis { min: 0; max: 10 } | |
|
110 | id: barSeries | |
|
111 | name: "bar" | |
|
112 | ||
|
113 | SignalSpy { | |
|
114 | id: addedSpy | |
|
115 | target: barSeries | |
|
116 | signalName: "barsetsAdded" | |
|
117 | } | |
|
118 | SignalSpy { | |
|
119 | id: removedSpy | |
|
120 | target: barSeries | |
|
121 | signalName: "barsetsRemoved" | |
|
122 | } | |
|
123 | } | |
|
124 | } | |
|
125 | } |
@@ -0,0 +1,79 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtQuickTest 1.0 | |
|
23 | import QtCommercial.Chart 1.1 | |
|
24 | ||
|
25 | Rectangle { | |
|
26 | width: 400 | |
|
27 | height: 300 | |
|
28 | ||
|
29 | TestCase { | |
|
30 | id: tc1 | |
|
31 | name: "tst_qml-qtquicktest ChartView Properties 1.1" | |
|
32 | when: windowShown | |
|
33 | ||
|
34 | function test_chartViewProperties() { | |
|
35 | compare(chartView.animationOptions, ChartView.NoAnimation, "ChartView.animationOptions"); | |
|
36 | verify(chartView.backgroundColor != undefined); | |
|
37 | verify(chartView.bottomMargin > 0, "ChartView.bottomMargin"); | |
|
38 | verify(chartView.topMargin > 0, "ChartView.topMargin"); | |
|
39 | verify(chartView.leftMargin > 0, "ChartView.leftMargin"); | |
|
40 | verify(chartView.rightMargin > 0, "ChartView.rightMargin"); | |
|
41 | compare(chartView.count, 0, "ChartView.count"); | |
|
42 | compare(chartView.dropShadowEnabled, false, "ChartView.dropShadowEnabled"); | |
|
43 | verify(chartView.plotArea.height > 0, "ChartView.plotArea.height"); | |
|
44 | verify(chartView.plotArea.width > 0, "ChartView.plotArea.width"); | |
|
45 | verify(chartView.plotArea.x > 0, "ChartView.plotArea.x"); | |
|
46 | verify(chartView.plotArea.y > 0, "ChartView.plotArea.y"); | |
|
47 | compare(chartView.theme, ChartView.ChartThemeLight, "ChartView.theme"); | |
|
48 | compare(chartView.title, "", "ChartView.title"); | |
|
49 | compare(chartView.title, "", "ChartView.title"); | |
|
50 | verify(chartView.titleColor != undefined, "ChartView.titleColor"); | |
|
51 | compare(chartView.titleFont.bold, false, "ChartView.titleFont.bold"); | |
|
52 | // Legend | |
|
53 | compare(chartView.legend.visible, true, "ChartView.legend.visible"); | |
|
54 | compare(chartView.legend.alignment, Qt.AlignTop, "ChartView.legend.alignment"); | |
|
55 | compare(chartView.legend.backgroundVisible, false, "ChartView.legend.backgroundVisible"); | |
|
56 | verify(chartView.legend.borderColor != undefined, "ChartView.legend.borderColor"); | |
|
57 | verify(chartView.legend.color != undefined, "ChartView.legend.color"); | |
|
58 | // Legend font | |
|
59 | compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold"); | |
|
60 | compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization"); | |
|
61 | compare(chartView.legend.font.family, "arial", "ChartView.legend.font.family"); | |
|
62 | compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic"); | |
|
63 | compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing"); | |
|
64 | verify(chartView.legend.font.pixelSize > 0 | |
|
65 | && chartView.legend.font.pixelSize < 50, "ChartView.legend.font.pixelSize"); | |
|
66 | verify(chartView.legend.font.pointSize > 0 | |
|
67 | && chartView.legend.font.pointSize < 50, "ChartView.legend.font.pointSize"); | |
|
68 | compare(chartView.legend.font.strikeout, false, "ChartView.legend.font.strikeout"); | |
|
69 | compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline"); | |
|
70 | compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight"); | |
|
71 | compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing"); | |
|
72 | } | |
|
73 | } | |
|
74 | ||
|
75 | ChartView { | |
|
76 | id: chartView | |
|
77 | anchors.fill: parent | |
|
78 | } | |
|
79 | } |
@@ -0,0 +1,158 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtQuickTest 1.0 | |
|
23 | import QtCommercial.Chart 1.1 | |
|
24 | ||
|
25 | Rectangle { | |
|
26 | width: 400 | |
|
27 | height: 300 | |
|
28 | ||
|
29 | TestCase { | |
|
30 | id: tc1 | |
|
31 | name: "tst_qml-qtquicktest ChartView Functions 1.1" | |
|
32 | when: windowShown | |
|
33 | ||
|
34 | function test_chartViewSeriesAndAxes() { | |
|
35 | // Create XY series | |
|
36 | var line = chartView.createSeries(ChartView.SeriesTypeLine, "line"); | |
|
37 | verify(line != null && line != undefined); | |
|
38 | var spline = chartView.createSeries(ChartView.SeriesTypeSpline, "spline"); | |
|
39 | verify(spline != null && spline != undefined); | |
|
40 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter"); | |
|
41 | verify(scatter != null && scatter != undefined); | |
|
42 | ||
|
43 | // Create a series with specific axes | |
|
44 | var line2 = chartView.createSeries(ChartView.SeriesTypeLine, "line2", chartView.axisX(line), chartView.axisY(line)); | |
|
45 | ||
|
46 | // Check that all the XY series use the same axes | |
|
47 | verify(chartView.axisX(line) != null); | |
|
48 | verify(chartView.axisY(line) != null); | |
|
49 | compare(chartView.axisX(line), chartView.axisX(line2)); | |
|
50 | compare(chartView.axisY(line), chartView.axisY(line2)); | |
|
51 | compare(chartView.axisX(line), chartView.axisX(spline)); | |
|
52 | compare(chartView.axisY(line), chartView.axisY(spline)); | |
|
53 | compare(chartView.axisX(line), chartView.axisX(scatter)); | |
|
54 | compare(chartView.axisY(line), chartView.axisY(scatter)); | |
|
55 | ||
|
56 | var bar = chartView.createSeries(ChartView.SeriesTypeBar, "bar"); | |
|
57 | verify(bar != null && bar != undefined); | |
|
58 | var stackedbar = chartView.createSeries(ChartView.SeriesTypeStackedBar, "stackedbar"); | |
|
59 | verify(stackedbar != null && stackedbar != undefined); | |
|
60 | var percentbar = chartView.createSeries(ChartView.SeriesTypePercentBar, "percentbar"); | |
|
61 | verify(percentbar != null && percentbar != undefined); | |
|
62 | var horizontalbar = chartView.createSeries(ChartView.SeriesTypeHorizontalBar, "horizontalbar"); | |
|
63 | verify(horizontalbar != null && horizontalbar != undefined); | |
|
64 | var horizontalstackedbar = chartView.createSeries(ChartView.SeriesTypeHorizontalStackedBar, "horizontalstackedbar"); | |
|
65 | verify(horizontalstackedbar != null && horizontalstackedbar != undefined); | |
|
66 | var horizontalpercentbar = chartView.createSeries(ChartView.SeriesTypeHorizontalPercentBar, "horizontalpercentbar"); | |
|
67 | verify(horizontalpercentbar != null && horizontalpercentbar != undefined); | |
|
68 | var area = chartView.createSeries(ChartView.SeriesTypeArea, "area"); | |
|
69 | verify(area != null && area != undefined); | |
|
70 | ||
|
71 | // Remove all series | |
|
72 | chartView.removeAllSeries(); | |
|
73 | compare(chartView.count, 0); | |
|
74 | } | |
|
75 | ||
|
76 | function test_chartViewRange() { | |
|
77 | // Set initial values | |
|
78 | chartView.createSeries(ChartView.SeriesTypeLine, "line"); | |
|
79 | verify(chartView.axisX() != null); | |
|
80 | verify(chartView.axisY() != null); | |
|
81 | chartView.axisX().min = 1.0; | |
|
82 | chartView.axisX().max = 2.0; | |
|
83 | chartView.axisY().min = 1.0; | |
|
84 | chartView.axisY().max = 2.0; | |
|
85 | ||
|
86 | var xMax = chartView.axisX().max; | |
|
87 | var xMin = chartView.axisX().min; | |
|
88 | var yMax = chartView.axisY().max; | |
|
89 | var yMin = chartView.axisY().min; | |
|
90 | ||
|
91 | // zoom x 2.5 | |
|
92 | chartView.zoom(1.5); | |
|
93 | verify(chartView.axisX().max < xMax); | |
|
94 | verify(chartView.axisX().min > xMin); | |
|
95 | verify(chartView.axisY().max < yMax); | |
|
96 | verify(chartView.axisY().min > yMin); | |
|
97 | xMax = chartView.axisX().max; | |
|
98 | xMin = chartView.axisX().min; | |
|
99 | yMax = chartView.axisY().max; | |
|
100 | yMin = chartView.axisY().min; | |
|
101 | ||
|
102 | // zoom x 0.5 | |
|
103 | chartView.zoom(0.5); | |
|
104 | verify(chartView.axisX().max > xMax); | |
|
105 | verify(chartView.axisX().min < xMin); | |
|
106 | verify(chartView.axisY().max > yMax); | |
|
107 | verify(chartView.axisY().min < yMin); | |
|
108 | xMax = chartView.axisX().max; | |
|
109 | xMin = chartView.axisX().min; | |
|
110 | yMax = chartView.axisY().max; | |
|
111 | yMin = chartView.axisY().min; | |
|
112 | ||
|
113 | // Scroll up | |
|
114 | chartView.scrollUp(10); | |
|
115 | compare(chartView.axisX().max, xMax); | |
|
116 | compare(chartView.axisX().min, xMin); | |
|
117 | verify(chartView.axisY().max > yMax); | |
|
118 | verify(chartView.axisY().min > yMin); | |
|
119 | xMax = chartView.axisX().max; | |
|
120 | xMin = chartView.axisX().min; | |
|
121 | yMax = chartView.axisY().max; | |
|
122 | yMin = chartView.axisY().min; | |
|
123 | ||
|
124 | // Scroll down | |
|
125 | chartView.scrollDown(10); | |
|
126 | compare(chartView.axisX().max, xMax); | |
|
127 | compare(chartView.axisX().min, xMin); | |
|
128 | verify(chartView.axisY().max < yMax); | |
|
129 | verify(chartView.axisY().min < yMin); | |
|
130 | xMax = chartView.axisX().max; | |
|
131 | xMin = chartView.axisX().min; | |
|
132 | yMax = chartView.axisY().max; | |
|
133 | yMin = chartView.axisY().min; | |
|
134 | ||
|
135 | chartView.scrollLeft(10); | |
|
136 | verify(chartView.axisX().max < xMax); | |
|
137 | verify(chartView.axisX().min < xMin); | |
|
138 | compare(chartView.axisY().max, yMax); | |
|
139 | compare(chartView.axisY().min, yMin); | |
|
140 | xMax = chartView.axisX().max; | |
|
141 | xMin = chartView.axisX().min; | |
|
142 | yMax = chartView.axisY().max; | |
|
143 | yMin = chartView.axisY().min; | |
|
144 | ||
|
145 | chartView.scrollRight(10); | |
|
146 | verify(chartView.axisX().max > xMax); | |
|
147 | verify(chartView.axisX().min > xMin); | |
|
148 | compare(chartView.axisY().max, yMax); | |
|
149 | compare(chartView.axisY().min, yMin); | |
|
150 | } | |
|
151 | } | |
|
152 | ||
|
153 | ChartView { | |
|
154 | id: chartView | |
|
155 | anchors.fill: parent | |
|
156 | title: "Chart" | |
|
157 | } | |
|
158 | } |
@@ -0,0 +1,73 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtQuickTest 1.0 | |
|
23 | import QtCommercial.Chart 1.1 | |
|
24 | ||
|
25 | Rectangle { | |
|
26 | width: 400 | |
|
27 | height: 300 | |
|
28 | ||
|
29 | TestCase { | |
|
30 | id: tc1 | |
|
31 | name: "tst_qml-qtquicktest ChartView Signals 1.1" | |
|
32 | when: windowShown | |
|
33 | ||
|
34 | // Verify onSeriesAdded and onSeriesRemoved signals | |
|
35 | function test_chartView() { | |
|
36 | var series = chartView.createSeries(ChartView.SeriesTypeLine, "line"); | |
|
37 | seriesAddedSpy.wait(); | |
|
38 | compare(seriesAddedSpy.count, 1, "ChartView.onSeriesAdded"); | |
|
39 | ||
|
40 | // Modifying layout triggers more than one plotAreaChanged signal | |
|
41 | chartView.titleFont.pixelSize = 50; | |
|
42 | verify(plotAreaChangedSpy.count > 0, "ChartView.onPlotAreaChanged"); | |
|
43 | ||
|
44 | chartView.removeSeries(series); | |
|
45 | seriesRemovedSpy.wait(); | |
|
46 | compare(seriesRemovedSpy.count, 1, "ChartView.onSeriesAdded"); | |
|
47 | } | |
|
48 | } | |
|
49 | ||
|
50 | ChartView { | |
|
51 | id: chartView | |
|
52 | anchors.fill: parent | |
|
53 | title: "Chart" | |
|
54 | ||
|
55 | SignalSpy { | |
|
56 | id: plotAreaChangedSpy | |
|
57 | target: chartView | |
|
58 | signalName: "plotAreaChanged" | |
|
59 | } | |
|
60 | ||
|
61 | SignalSpy { | |
|
62 | id: seriesAddedSpy | |
|
63 | target: chartView | |
|
64 | signalName: "seriesAdded" | |
|
65 | } | |
|
66 | ||
|
67 | SignalSpy { | |
|
68 | id: seriesRemovedSpy | |
|
69 | target: chartView | |
|
70 | signalName: "seriesRemoved" | |
|
71 | } | |
|
72 | } | |
|
73 | } |
@@ -0,0 +1,131 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtQuickTest 1.0 | |
|
23 | import QtCommercial.Chart 1.1 | |
|
24 | ||
|
25 | Rectangle { | |
|
26 | width: 400 | |
|
27 | height: 300 | |
|
28 | ||
|
29 | TestCase { | |
|
30 | id: tc1 | |
|
31 | name: "tst_qml-qtquicktest PieSeries 1.1" | |
|
32 | when: windowShown | |
|
33 | ||
|
34 | function test_properties() { | |
|
35 | compare(pieSeries.endAngle, 360); | |
|
36 | compare(pieSeries.holeSize, 0); | |
|
37 | compare(pieSeries.horizontalPosition, 0.5); | |
|
38 | compare(pieSeries.size, 0.7); | |
|
39 | compare(pieSeries.startAngle, 0); | |
|
40 | compare(pieSeries.sum, 0); | |
|
41 | compare(pieSeries.verticalPosition, 0.5); | |
|
42 | } | |
|
43 | ||
|
44 | function test_sliceproperties() { | |
|
45 | var slice = pieSeries.append("slice", 10); | |
|
46 | compare(slice.angleSpan, 360.0); | |
|
47 | verify(slice.borderColor != undefined); | |
|
48 | compare(slice.borderWidth, 0); | |
|
49 | verify(slice.color != undefined); | |
|
50 | compare(slice.explodeDistanceFactor, 0.15); | |
|
51 | compare(slice.exploded, false); | |
|
52 | compare(slice.label, "slice"); | |
|
53 | compare(slice.labelArmLengthFactor, 0.15); | |
|
54 | verify(slice.labelColor != undefined); | |
|
55 | compare(slice.labelFont.bold, false); | |
|
56 | compare(slice.labelPosition, PieSlice.LabelOutside); | |
|
57 | compare(slice.labelVisible, false); | |
|
58 | compare(slice.percentage, 1.0); | |
|
59 | compare(slice.startAngle, 0.0); | |
|
60 | compare(slice.value, 10.0); | |
|
61 | } | |
|
62 | ||
|
63 | function test_append() { | |
|
64 | addedSpy.clear(); | |
|
65 | countChangedSpy.clear(); | |
|
66 | sumChangedSpy.clear(); | |
|
67 | var count = 50; | |
|
68 | for (var i = 0; i < count; i++) | |
|
69 | pieSeries.append("slice" + i, Math.random()); | |
|
70 | compare(addedSpy.count, count); | |
|
71 | compare(countChangedSpy.count, count); | |
|
72 | compare(sumChangedSpy.count, count); | |
|
73 | pieSeries.clear(); | |
|
74 | } | |
|
75 | ||
|
76 | function test_remove() { | |
|
77 | removedSpy.clear(); | |
|
78 | countChangedSpy.clear(); | |
|
79 | sumChangedSpy.clear(); | |
|
80 | var count = 50; | |
|
81 | for (var i = 0; i < count; i++) | |
|
82 | pieSeries.append("slice" + i, Math.random()); | |
|
83 | for (var j = 0; j < count; j++) | |
|
84 | pieSeries.remove(pieSeries.at(0)); | |
|
85 | compare(removedSpy.count, count); | |
|
86 | compare(countChangedSpy.count, 2 * count); | |
|
87 | compare(sumChangedSpy.count, 2 * count); | |
|
88 | compare(pieSeries.count, 0); | |
|
89 | } | |
|
90 | ||
|
91 | function test_find() { | |
|
92 | var count = 50; | |
|
93 | for (var i = 0; i < count; i++) | |
|
94 | pieSeries.append("slice" + i, Math.random()); | |
|
95 | for (var j = 0; j < count; j++) | |
|
96 | compare(pieSeries.find("slice" + j).label, "slice" + j); | |
|
97 | pieSeries.clear(); | |
|
98 | } | |
|
99 | } | |
|
100 | ||
|
101 | ChartView { | |
|
102 | id: chartView | |
|
103 | anchors.fill: parent | |
|
104 | ||
|
105 | PieSeries { | |
|
106 | id: pieSeries | |
|
107 | name: "pie" | |
|
108 | ||
|
109 | SignalSpy { | |
|
110 | id: addedSpy | |
|
111 | target: pieSeries | |
|
112 | signalName: "added" | |
|
113 | } | |
|
114 | SignalSpy { | |
|
115 | id: removedSpy | |
|
116 | target: pieSeries | |
|
117 | signalName: "removed" | |
|
118 | } | |
|
119 | SignalSpy { | |
|
120 | id: sumChangedSpy | |
|
121 | target: pieSeries | |
|
122 | signalName: "sumChanged" | |
|
123 | } | |
|
124 | SignalSpy { | |
|
125 | id: countChangedSpy | |
|
126 | target: pieSeries | |
|
127 | signalName: "countChanged" | |
|
128 | } | |
|
129 | } | |
|
130 | } | |
|
131 | } |
@@ -0,0 +1,250 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtQuickTest 1.0 | |
|
23 | import QtCommercial.Chart 1.1 | |
|
24 | ||
|
25 | Rectangle { | |
|
26 | width: 400 | |
|
27 | height: 300 | |
|
28 | ||
|
29 | TestCase { | |
|
30 | id: tc1 | |
|
31 | name: "tst_qml-qtquicktest XY Series 1.1" | |
|
32 | when: windowShown | |
|
33 | ||
|
34 | function test_properties() { | |
|
35 | verify(lineSeries.color != undefined); | |
|
36 | compare(lineSeries.pointsVisible, false); | |
|
37 | compare(lineSeries.capStyle, Qt.SquareCap); | |
|
38 | compare(lineSeries.style, Qt.SolidLine); | |
|
39 | compare(lineSeries.width, 2.0); | |
|
40 | ||
|
41 | verify(splineSeries.color != undefined); | |
|
42 | compare(splineSeries.pointsVisible, false); | |
|
43 | compare(splineSeries.capStyle, Qt.SquareCap); | |
|
44 | compare(splineSeries.style, Qt.SolidLine); | |
|
45 | compare(splineSeries.width, 2.0); | |
|
46 | ||
|
47 | verify(scatterSeries.color != undefined); | |
|
48 | verify(scatterSeries.borderColor != undefined); | |
|
49 | compare(scatterSeries.borderWidth, 2.0); | |
|
50 | compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle); | |
|
51 | compare(scatterSeries.markerSize, 15.0); | |
|
52 | ||
|
53 | verify(areaSeries.color != undefined); | |
|
54 | verify(areaSeries.borderColor != undefined); | |
|
55 | compare(areaSeries.borderWidth, 2.0); | |
|
56 | } | |
|
57 | ||
|
58 | function test_append() { | |
|
59 | lineSeriesPointAddedSpy.clear(); | |
|
60 | splineSeriesPointAddedSpy.clear(); | |
|
61 | scatterSeriesPointAddedSpy.clear(); | |
|
62 | var count = append(); | |
|
63 | compare(lineSeries.count, count); | |
|
64 | compare(splineSeries.count, count); | |
|
65 | compare(scatterSeries.count, count); | |
|
66 | tryCompare(lineSeriesPointAddedSpy.count, count); | |
|
67 | tryCompare(splineSeriesPointAddedSpy.count, count); | |
|
68 | tryCompare(scatterSeriesPointAddedSpy.count, count); | |
|
69 | clear(); | |
|
70 | compare(lineSeries.count, 0); | |
|
71 | compare(splineSeries.count, 0); | |
|
72 | compare(scatterSeries.count, 0); | |
|
73 | } | |
|
74 | ||
|
75 | function test_replace() { | |
|
76 | var count = append(); | |
|
77 | for (var i = 0; i < count; i++) { | |
|
78 | lineSeries.replace(lineSeries.at(i).x, lineSeries.at(i).y, i, Math.random()); | |
|
79 | splineSeries.replace(splineSeries.at(i).x, splineSeries.at(i).y, i, Math.random()); | |
|
80 | scatterSeries.replace(scatterSeries.at(i).x, scatterSeries.at(i).y, i, Math.random()); | |
|
81 | } | |
|
82 | compare(lineSeries.count, count); | |
|
83 | compare(splineSeries.count, count); | |
|
84 | compare(scatterSeries.count, count); | |
|
85 | tryCompare(lineSeriesPointReplacedSpy.count, count); | |
|
86 | tryCompare(splineSeriesPointReplacedSpy.count, count); | |
|
87 | tryCompare(scatterSeriesPointReplacedSpy.count, count); | |
|
88 | clear(); | |
|
89 | } | |
|
90 | ||
|
91 | function test_insert() { | |
|
92 | var count = append(); | |
|
93 | lineSeriesPointAddedSpy.clear(); | |
|
94 | splineSeriesPointAddedSpy.clear(); | |
|
95 | scatterSeriesPointAddedSpy.clear(); | |
|
96 | for (var i = 0; i < count; i++) { | |
|
97 | lineSeries.insert(i * 2, i, Math.random()); | |
|
98 | splineSeries.insert(i * 2, i, Math.random()); | |
|
99 | scatterSeries.insert(i * 2, i, Math.random()); | |
|
100 | } | |
|
101 | compare(lineSeries.count, count * 2); | |
|
102 | compare(splineSeries.count, count * 2); | |
|
103 | compare(scatterSeries.count, count * 2); | |
|
104 | tryCompare(lineSeriesPointAddedSpy.count, count); | |
|
105 | tryCompare(splineSeriesPointAddedSpy.count, count); | |
|
106 | tryCompare(scatterSeriesPointAddedSpy.count, count); | |
|
107 | clear(); | |
|
108 | } | |
|
109 | ||
|
110 | function test_remove() { | |
|
111 | lineSeriesPointRemovedSpy.clear(); | |
|
112 | splineSeriesPointRemovedSpy.clear(); | |
|
113 | scatterSeriesPointRemovedSpy.clear(); | |
|
114 | var count = append(); | |
|
115 | for (var i = 0; i < count; i++) { | |
|
116 | lineSeries.remove(lineSeries.at(0).x, lineSeries.at(0).y); | |
|
117 | splineSeries.remove(splineSeries.at(0).x, splineSeries.at(0).y); | |
|
118 | scatterSeries.remove(scatterSeries.at(0).x, scatterSeries.at(0).y); | |
|
119 | } | |
|
120 | compare(lineSeries.count, 0); | |
|
121 | compare(splineSeries.count, 0); | |
|
122 | compare(scatterSeries.count, 0); | |
|
123 | tryCompare(lineSeriesPointRemovedSpy.count, count); | |
|
124 | tryCompare(splineSeriesPointRemovedSpy.count, count); | |
|
125 | tryCompare(scatterSeriesPointRemovedSpy.count, count); | |
|
126 | } | |
|
127 | ||
|
128 | // Not a test function, called from test functions | |
|
129 | function append() { | |
|
130 | var count = 100; | |
|
131 | chartView.axisX().min = 0; | |
|
132 | chartView.axisX().max = 100; | |
|
133 | chartView.axisY().min = 0; | |
|
134 | chartView.axisY().max = 1; | |
|
135 | ||
|
136 | for (var i = 0; i < count; i++) { | |
|
137 | lineSeries.append(i, Math.random()); | |
|
138 | splineSeries.append(i, Math.random()); | |
|
139 | scatterSeries.append(i, Math.random()); | |
|
140 | } | |
|
141 | ||
|
142 | return count; | |
|
143 | } | |
|
144 | ||
|
145 | // Not a test function, called from test functions | |
|
146 | function clear() { | |
|
147 | lineSeries.clear(); | |
|
148 | splineSeries.clear(); | |
|
149 | scatterSeries.clear(); | |
|
150 | } | |
|
151 | } | |
|
152 | ||
|
153 | ChartView { | |
|
154 | id: chartView | |
|
155 | anchors.fill: parent | |
|
156 | ||
|
157 | LineSeries { | |
|
158 | id: lineSeries | |
|
159 | name: "line" | |
|
160 | ||
|
161 | SignalSpy { | |
|
162 | id: lineSeriesPointAddedSpy | |
|
163 | target: lineSeries | |
|
164 | signalName: "pointAdded" | |
|
165 | } | |
|
166 | ||
|
167 | SignalSpy { | |
|
168 | id: lineSeriesPointReplacedSpy | |
|
169 | target: lineSeries | |
|
170 | signalName: "pointReplaced" | |
|
171 | } | |
|
172 | ||
|
173 | SignalSpy { | |
|
174 | id: lineSeriesPointsReplacedSpy | |
|
175 | target: lineSeries | |
|
176 | signalName: "pointsReplaced" | |
|
177 | } | |
|
178 | ||
|
179 | SignalSpy { | |
|
180 | id: lineSeriesPointRemovedSpy | |
|
181 | target: lineSeries | |
|
182 | signalName: "pointRemoved" | |
|
183 | } | |
|
184 | } | |
|
185 | ||
|
186 | AreaSeries { | |
|
187 | id: areaSeries | |
|
188 | name: "area" | |
|
189 | upperSeries: lineSeries | |
|
190 | } | |
|
191 | ||
|
192 | SplineSeries { | |
|
193 | id: splineSeries | |
|
194 | name: "spline" | |
|
195 | ||
|
196 | SignalSpy { | |
|
197 | id: splineSeriesPointAddedSpy | |
|
198 | target: splineSeries | |
|
199 | signalName: "pointAdded" | |
|
200 | } | |
|
201 | ||
|
202 | SignalSpy { | |
|
203 | id: splineSeriesPointReplacedSpy | |
|
204 | target: splineSeries | |
|
205 | signalName: "pointReplaced" | |
|
206 | } | |
|
207 | ||
|
208 | SignalSpy { | |
|
209 | id: splineSeriesPointsReplacedSpy | |
|
210 | target: splineSeries | |
|
211 | signalName: "pointsReplaced" | |
|
212 | } | |
|
213 | ||
|
214 | SignalSpy { | |
|
215 | id: splineSeriesPointRemovedSpy | |
|
216 | target: splineSeries | |
|
217 | signalName: "pointRemoved" | |
|
218 | } | |
|
219 | } | |
|
220 | ||
|
221 | ScatterSeries { | |
|
222 | id: scatterSeries | |
|
223 | name: "scatter" | |
|
224 | ||
|
225 | SignalSpy { | |
|
226 | id: scatterSeriesPointAddedSpy | |
|
227 | target: scatterSeries | |
|
228 | signalName: "pointAdded" | |
|
229 | } | |
|
230 | ||
|
231 | SignalSpy { | |
|
232 | id: scatterSeriesPointReplacedSpy | |
|
233 | target: scatterSeries | |
|
234 | signalName: "pointReplaced" | |
|
235 | } | |
|
236 | ||
|
237 | SignalSpy { | |
|
238 | id: scatterSeriesPointsReplacedSpy | |
|
239 | target: scatterSeries | |
|
240 | signalName: "pointsReplaced" | |
|
241 | } | |
|
242 | ||
|
243 | SignalSpy { | |
|
244 | id: scatterSeriesPointRemovedSpy | |
|
245 | target: scatterSeries | |
|
246 | signalName: "pointRemoved" | |
|
247 | } | |
|
248 | } | |
|
249 | } | |
|
250 | } |
@@ -1,79 +1,83 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtQuickTest 1.0 |
|
23 |
import QtCommercial.Chart 1. |
|
|
23 | import QtCommercial.Chart 1.2 | |
|
24 | 24 | |
|
25 | 25 | Rectangle { |
|
26 | 26 | width: 400 |
|
27 | 27 | height: 300 |
|
28 | 28 | |
|
29 | 29 | TestCase { |
|
30 | 30 | id: tc1 |
|
31 | 31 | name: "tst_qml-qtquicktest ChartView Properties" |
|
32 | 32 | when: windowShown |
|
33 | 33 | |
|
34 | 34 | function test_chartViewProperties() { |
|
35 | 35 | compare(chartView.animationOptions, ChartView.NoAnimation, "ChartView.animationOptions"); |
|
36 | 36 | verify(chartView.backgroundColor != undefined); |
|
37 | 37 | verify(chartView.bottomMargin > 0, "ChartView.bottomMargin"); |
|
38 | 38 | verify(chartView.topMargin > 0, "ChartView.topMargin"); |
|
39 | 39 | verify(chartView.leftMargin > 0, "ChartView.leftMargin"); |
|
40 | 40 | verify(chartView.rightMargin > 0, "ChartView.rightMargin"); |
|
41 | verify(chartView.margins.bottom > 0, "ChartView.margins.bottom"); | |
|
42 | verify(chartView.margins.top > 0, "ChartView.margins.top"); | |
|
43 | verify(chartView.margins.left > 0, "ChartView.margins.left"); | |
|
44 | verify(chartView.margins.right > 0, "ChartView.margins.right"); | |
|
41 | 45 | compare(chartView.count, 0, "ChartView.count"); |
|
42 | 46 | compare(chartView.dropShadowEnabled, false, "ChartView.dropShadowEnabled"); |
|
43 | 47 | verify(chartView.plotArea.height > 0, "ChartView.plotArea.height"); |
|
44 | 48 | verify(chartView.plotArea.width > 0, "ChartView.plotArea.width"); |
|
45 | 49 | verify(chartView.plotArea.x > 0, "ChartView.plotArea.x"); |
|
46 | 50 | verify(chartView.plotArea.y > 0, "ChartView.plotArea.y"); |
|
47 | 51 | compare(chartView.theme, ChartView.ChartThemeLight, "ChartView.theme"); |
|
48 | 52 | compare(chartView.title, "", "ChartView.title"); |
|
49 | 53 | compare(chartView.title, "", "ChartView.title"); |
|
50 | 54 | verify(chartView.titleColor != undefined, "ChartView.titleColor"); |
|
51 | 55 | compare(chartView.titleFont.bold, false, "ChartView.titleFont.bold"); |
|
52 | 56 | // Legend |
|
53 | 57 | compare(chartView.legend.visible, true, "ChartView.legend.visible"); |
|
54 | 58 | compare(chartView.legend.alignment, Qt.AlignTop, "ChartView.legend.alignment"); |
|
55 | 59 | compare(chartView.legend.backgroundVisible, false, "ChartView.legend.backgroundVisible"); |
|
56 | 60 | verify(chartView.legend.borderColor != undefined, "ChartView.legend.borderColor"); |
|
57 | 61 | verify(chartView.legend.color != undefined, "ChartView.legend.color"); |
|
58 | 62 | // Legend font |
|
59 | 63 | compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold"); |
|
60 | 64 | compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization"); |
|
61 | 65 | compare(chartView.legend.font.family, "arial", "ChartView.legend.font.family"); |
|
62 | 66 | compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic"); |
|
63 | 67 | compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing"); |
|
64 | 68 | verify(chartView.legend.font.pixelSize > 0 |
|
65 | 69 | && chartView.legend.font.pixelSize < 50, "ChartView.legend.font.pixelSize"); |
|
66 | 70 | verify(chartView.legend.font.pointSize > 0 |
|
67 | 71 | && chartView.legend.font.pointSize < 50, "ChartView.legend.font.pointSize"); |
|
68 | 72 | compare(chartView.legend.font.strikeout, false, "ChartView.legend.font.strikeout"); |
|
69 | 73 | compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline"); |
|
70 | 74 | compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight"); |
|
71 | 75 | compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing"); |
|
72 | 76 | } |
|
73 | 77 | } |
|
74 | 78 | |
|
75 | 79 | ChartView { |
|
76 | 80 | id: chartView |
|
77 | 81 | anchors.fill: parent |
|
78 | 82 | } |
|
79 | 83 | } |
@@ -1,158 +1,158 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtQuickTest 1.0 |
|
23 |
import QtCommercial.Chart 1. |
|
|
23 | import QtCommercial.Chart 1.2 | |
|
24 | 24 | |
|
25 | 25 | Rectangle { |
|
26 | 26 | width: 400 |
|
27 | 27 | height: 300 |
|
28 | 28 | |
|
29 | 29 | TestCase { |
|
30 | 30 | id: tc1 |
|
31 | 31 | name: "tst_qml-qtquicktest ChartView Functions" |
|
32 | 32 | when: windowShown |
|
33 | 33 | |
|
34 | 34 | function test_chartViewSeriesAndAxes() { |
|
35 | 35 | // Create XY series |
|
36 | 36 | var line = chartView.createSeries(ChartView.SeriesTypeLine, "line"); |
|
37 | 37 | verify(line != null && line != undefined); |
|
38 | 38 | var spline = chartView.createSeries(ChartView.SeriesTypeSpline, "spline"); |
|
39 | 39 | verify(spline != null && spline != undefined); |
|
40 | 40 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter"); |
|
41 | 41 | verify(scatter != null && scatter != undefined); |
|
42 | 42 | |
|
43 | 43 | // Create a series with specific axes |
|
44 | 44 | var line2 = chartView.createSeries(ChartView.SeriesTypeLine, "line2", chartView.axisX(line), chartView.axisY(line)); |
|
45 | 45 | |
|
46 | 46 | // Check that all the XY series use the same axes |
|
47 | 47 | verify(chartView.axisX(line) != null); |
|
48 | 48 | verify(chartView.axisY(line) != null); |
|
49 | 49 | compare(chartView.axisX(line), chartView.axisX(line2)); |
|
50 | 50 | compare(chartView.axisY(line), chartView.axisY(line2)); |
|
51 | 51 | compare(chartView.axisX(line), chartView.axisX(spline)); |
|
52 | 52 | compare(chartView.axisY(line), chartView.axisY(spline)); |
|
53 | 53 | compare(chartView.axisX(line), chartView.axisX(scatter)); |
|
54 | 54 | compare(chartView.axisY(line), chartView.axisY(scatter)); |
|
55 | 55 | |
|
56 | 56 | var bar = chartView.createSeries(ChartView.SeriesTypeBar, "bar"); |
|
57 | 57 | verify(bar != null && bar != undefined); |
|
58 | 58 | var stackedbar = chartView.createSeries(ChartView.SeriesTypeStackedBar, "stackedbar"); |
|
59 | 59 | verify(stackedbar != null && stackedbar != undefined); |
|
60 | 60 | var percentbar = chartView.createSeries(ChartView.SeriesTypePercentBar, "percentbar"); |
|
61 | 61 | verify(percentbar != null && percentbar != undefined); |
|
62 | 62 | var horizontalbar = chartView.createSeries(ChartView.SeriesTypeHorizontalBar, "horizontalbar"); |
|
63 | 63 | verify(horizontalbar != null && horizontalbar != undefined); |
|
64 | 64 | var horizontalstackedbar = chartView.createSeries(ChartView.SeriesTypeHorizontalStackedBar, "horizontalstackedbar"); |
|
65 | 65 | verify(horizontalstackedbar != null && horizontalstackedbar != undefined); |
|
66 | 66 | var horizontalpercentbar = chartView.createSeries(ChartView.SeriesTypeHorizontalPercentBar, "horizontalpercentbar"); |
|
67 | 67 | verify(horizontalpercentbar != null && horizontalpercentbar != undefined); |
|
68 | 68 | var area = chartView.createSeries(ChartView.SeriesTypeArea, "area"); |
|
69 | 69 | verify(area != null && area != undefined); |
|
70 | 70 | |
|
71 | 71 | // Remove all series |
|
72 | 72 | chartView.removeAllSeries(); |
|
73 | 73 | compare(chartView.count, 0); |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | 76 | function test_chartViewRange() { |
|
77 | 77 | // Set initial values |
|
78 | 78 | chartView.createSeries(ChartView.SeriesTypeLine, "line"); |
|
79 | 79 | verify(chartView.axisX() != null); |
|
80 | 80 | verify(chartView.axisY() != null); |
|
81 | 81 | chartView.axisX().min = 1.0; |
|
82 | 82 | chartView.axisX().max = 2.0; |
|
83 | 83 | chartView.axisY().min = 1.0; |
|
84 | 84 | chartView.axisY().max = 2.0; |
|
85 | 85 | |
|
86 | 86 | var xMax = chartView.axisX().max; |
|
87 | 87 | var xMin = chartView.axisX().min; |
|
88 | 88 | var yMax = chartView.axisY().max; |
|
89 | 89 | var yMin = chartView.axisY().min; |
|
90 | 90 | |
|
91 | 91 | // zoom x 2.5 |
|
92 | 92 | chartView.zoom(1.5); |
|
93 | 93 | verify(chartView.axisX().max < xMax); |
|
94 | 94 | verify(chartView.axisX().min > xMin); |
|
95 | 95 | verify(chartView.axisY().max < yMax); |
|
96 | 96 | verify(chartView.axisY().min > yMin); |
|
97 | 97 | xMax = chartView.axisX().max; |
|
98 | 98 | xMin = chartView.axisX().min; |
|
99 | 99 | yMax = chartView.axisY().max; |
|
100 | 100 | yMin = chartView.axisY().min; |
|
101 | 101 | |
|
102 | 102 | // zoom x 0.5 |
|
103 | 103 | chartView.zoom(0.5); |
|
104 | 104 | verify(chartView.axisX().max > xMax); |
|
105 | 105 | verify(chartView.axisX().min < xMin); |
|
106 | 106 | verify(chartView.axisY().max > yMax); |
|
107 | 107 | verify(chartView.axisY().min < yMin); |
|
108 | 108 | xMax = chartView.axisX().max; |
|
109 | 109 | xMin = chartView.axisX().min; |
|
110 | 110 | yMax = chartView.axisY().max; |
|
111 | 111 | yMin = chartView.axisY().min; |
|
112 | 112 | |
|
113 | 113 | // Scroll up |
|
114 | 114 | chartView.scrollUp(10); |
|
115 | 115 | compare(chartView.axisX().max, xMax); |
|
116 | 116 | compare(chartView.axisX().min, xMin); |
|
117 | 117 | verify(chartView.axisY().max > yMax); |
|
118 | 118 | verify(chartView.axisY().min > yMin); |
|
119 | 119 | xMax = chartView.axisX().max; |
|
120 | 120 | xMin = chartView.axisX().min; |
|
121 | 121 | yMax = chartView.axisY().max; |
|
122 | 122 | yMin = chartView.axisY().min; |
|
123 | 123 | |
|
124 | 124 | // Scroll down |
|
125 | 125 | chartView.scrollDown(10); |
|
126 | 126 | compare(chartView.axisX().max, xMax); |
|
127 | 127 | compare(chartView.axisX().min, xMin); |
|
128 | 128 | verify(chartView.axisY().max < yMax); |
|
129 | 129 | verify(chartView.axisY().min < yMin); |
|
130 | 130 | xMax = chartView.axisX().max; |
|
131 | 131 | xMin = chartView.axisX().min; |
|
132 | 132 | yMax = chartView.axisY().max; |
|
133 | 133 | yMin = chartView.axisY().min; |
|
134 | 134 | |
|
135 | 135 | chartView.scrollLeft(10); |
|
136 | 136 | verify(chartView.axisX().max < xMax); |
|
137 | 137 | verify(chartView.axisX().min < xMin); |
|
138 | 138 | compare(chartView.axisY().max, yMax); |
|
139 | 139 | compare(chartView.axisY().min, yMin); |
|
140 | 140 | xMax = chartView.axisX().max; |
|
141 | 141 | xMin = chartView.axisX().min; |
|
142 | 142 | yMax = chartView.axisY().max; |
|
143 | 143 | yMin = chartView.axisY().min; |
|
144 | 144 | |
|
145 | 145 | chartView.scrollRight(10); |
|
146 | 146 | verify(chartView.axisX().max > xMax); |
|
147 | 147 | verify(chartView.axisX().min > xMin); |
|
148 | 148 | compare(chartView.axisY().max, yMax); |
|
149 | 149 | compare(chartView.axisY().min, yMin); |
|
150 | 150 | } |
|
151 | 151 | } |
|
152 | 152 | |
|
153 | 153 | ChartView { |
|
154 | 154 | id: chartView |
|
155 | 155 | anchors.fill: parent |
|
156 | 156 | title: "Chart" |
|
157 | 157 | } |
|
158 | 158 | } |
@@ -1,73 +1,73 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtQuickTest 1.0 |
|
23 |
import QtCommercial.Chart 1. |
|
|
23 | import QtCommercial.Chart 1.2 | |
|
24 | 24 | |
|
25 | 25 | Rectangle { |
|
26 | 26 | width: 400 |
|
27 | 27 | height: 300 |
|
28 | 28 | |
|
29 | 29 | TestCase { |
|
30 | 30 | id: tc1 |
|
31 | 31 | name: "tst_qml-qtquicktest ChartView Signals" |
|
32 | 32 | when: windowShown |
|
33 | 33 | |
|
34 | 34 | // Verify onSeriesAdded and onSeriesRemoved signals |
|
35 | 35 | function test_chartView() { |
|
36 | 36 | var series = chartView.createSeries(ChartView.SeriesTypeLine, "line"); |
|
37 | 37 | seriesAddedSpy.wait(); |
|
38 | 38 | compare(seriesAddedSpy.count, 1, "ChartView.onSeriesAdded"); |
|
39 | 39 | |
|
40 | 40 | // Modifying layout triggers more than one plotAreaChanged signal |
|
41 | 41 | chartView.titleFont.pixelSize = 50; |
|
42 | 42 | verify(plotAreaChangedSpy.count > 0, "ChartView.onPlotAreaChanged"); |
|
43 | 43 | |
|
44 | 44 | chartView.removeSeries(series); |
|
45 | 45 | seriesRemovedSpy.wait(); |
|
46 | 46 | compare(seriesRemovedSpy.count, 1, "ChartView.onSeriesAdded"); |
|
47 | 47 | } |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | 50 | ChartView { |
|
51 | 51 | id: chartView |
|
52 | 52 | anchors.fill: parent |
|
53 | 53 | title: "Chart" |
|
54 | 54 | |
|
55 | 55 | SignalSpy { |
|
56 | 56 | id: plotAreaChangedSpy |
|
57 | 57 | target: chartView |
|
58 | 58 | signalName: "plotAreaChanged" |
|
59 | 59 | } |
|
60 | 60 | |
|
61 | 61 | SignalSpy { |
|
62 | 62 | id: seriesAddedSpy |
|
63 | 63 | target: chartView |
|
64 | 64 | signalName: "seriesAdded" |
|
65 | 65 | } |
|
66 | 66 | |
|
67 | 67 | SignalSpy { |
|
68 | 68 | id: seriesRemovedSpy |
|
69 | 69 | target: chartView |
|
70 | 70 | signalName: "seriesRemoved" |
|
71 | 71 | } |
|
72 | 72 | } |
|
73 | 73 | } |
@@ -1,131 +1,131 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtQuickTest 1.0 |
|
23 |
import QtCommercial.Chart 1. |
|
|
23 | import QtCommercial.Chart 1.2 | |
|
24 | 24 | |
|
25 | 25 | Rectangle { |
|
26 | 26 | width: 400 |
|
27 | 27 | height: 300 |
|
28 | 28 | |
|
29 | 29 | TestCase { |
|
30 | 30 | id: tc1 |
|
31 | 31 | name: "tst_qml-qtquicktest PieSeries" |
|
32 | 32 | when: windowShown |
|
33 | 33 | |
|
34 | 34 | function test_properties() { |
|
35 | 35 | compare(pieSeries.endAngle, 360); |
|
36 | 36 | compare(pieSeries.holeSize, 0); |
|
37 | 37 | compare(pieSeries.horizontalPosition, 0.5); |
|
38 | 38 | compare(pieSeries.size, 0.7); |
|
39 | 39 | compare(pieSeries.startAngle, 0); |
|
40 | 40 | compare(pieSeries.sum, 0); |
|
41 | 41 | compare(pieSeries.verticalPosition, 0.5); |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | function test_sliceproperties() { |
|
45 | 45 | var slice = pieSeries.append("slice", 10); |
|
46 | 46 | compare(slice.angleSpan, 360.0); |
|
47 | 47 | verify(slice.borderColor != undefined); |
|
48 | 48 | compare(slice.borderWidth, 0); |
|
49 | 49 | verify(slice.color != undefined); |
|
50 | 50 | compare(slice.explodeDistanceFactor, 0.15); |
|
51 | 51 | compare(slice.exploded, false); |
|
52 | 52 | compare(slice.label, "slice"); |
|
53 | 53 | compare(slice.labelArmLengthFactor, 0.15); |
|
54 | 54 | verify(slice.labelColor != undefined); |
|
55 | 55 | compare(slice.labelFont.bold, false); |
|
56 | 56 | compare(slice.labelPosition, PieSlice.LabelOutside); |
|
57 | 57 | compare(slice.labelVisible, false); |
|
58 | 58 | compare(slice.percentage, 1.0); |
|
59 | 59 | compare(slice.startAngle, 0.0); |
|
60 | 60 | compare(slice.value, 10.0); |
|
61 | 61 | } |
|
62 | 62 | |
|
63 | 63 | function test_append() { |
|
64 | 64 | addedSpy.clear(); |
|
65 | 65 | countChangedSpy.clear(); |
|
66 | 66 | sumChangedSpy.clear(); |
|
67 | 67 | var count = 50; |
|
68 | 68 | for (var i = 0; i < count; i++) |
|
69 | 69 | pieSeries.append("slice" + i, Math.random()); |
|
70 | 70 | compare(addedSpy.count, count); |
|
71 | 71 | compare(countChangedSpy.count, count); |
|
72 | 72 | compare(sumChangedSpy.count, count); |
|
73 | 73 | pieSeries.clear(); |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | 76 | function test_remove() { |
|
77 | 77 | removedSpy.clear(); |
|
78 | 78 | countChangedSpy.clear(); |
|
79 | 79 | sumChangedSpy.clear(); |
|
80 | 80 | var count = 50; |
|
81 | 81 | for (var i = 0; i < count; i++) |
|
82 | 82 | pieSeries.append("slice" + i, Math.random()); |
|
83 | 83 | for (var j = 0; j < count; j++) |
|
84 | 84 | pieSeries.remove(pieSeries.at(0)); |
|
85 | 85 | compare(removedSpy.count, count); |
|
86 | 86 | compare(countChangedSpy.count, 2 * count); |
|
87 | 87 | compare(sumChangedSpy.count, 2 * count); |
|
88 | 88 | compare(pieSeries.count, 0); |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | function test_find() { |
|
92 | 92 | var count = 50; |
|
93 | 93 | for (var i = 0; i < count; i++) |
|
94 | 94 | pieSeries.append("slice" + i, Math.random()); |
|
95 | 95 | for (var j = 0; j < count; j++) |
|
96 | 96 | compare(pieSeries.find("slice" + j).label, "slice" + j); |
|
97 | 97 | pieSeries.clear(); |
|
98 | 98 | } |
|
99 | 99 | } |
|
100 | 100 | |
|
101 | 101 | ChartView { |
|
102 | 102 | id: chartView |
|
103 | 103 | anchors.fill: parent |
|
104 | 104 | |
|
105 | 105 | PieSeries { |
|
106 | 106 | id: pieSeries |
|
107 | 107 | name: "pie" |
|
108 | 108 | |
|
109 | 109 | SignalSpy { |
|
110 | 110 | id: addedSpy |
|
111 | 111 | target: pieSeries |
|
112 | 112 | signalName: "added" |
|
113 | 113 | } |
|
114 | 114 | SignalSpy { |
|
115 | 115 | id: removedSpy |
|
116 | 116 | target: pieSeries |
|
117 | 117 | signalName: "removed" |
|
118 | 118 | } |
|
119 | 119 | SignalSpy { |
|
120 | 120 | id: sumChangedSpy |
|
121 | 121 | target: pieSeries |
|
122 | 122 | signalName: "sumChanged" |
|
123 | 123 | } |
|
124 | 124 | SignalSpy { |
|
125 | 125 | id: countChangedSpy |
|
126 | 126 | target: pieSeries |
|
127 | 127 | signalName: "countChanged" |
|
128 | 128 | } |
|
129 | 129 | } |
|
130 | 130 | } |
|
131 | 131 | } |
@@ -1,259 +1,259 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtQuickTest 1.0 |
|
23 |
import QtCommercial.Chart 1. |
|
|
23 | import QtCommercial.Chart 1.2 | |
|
24 | 24 | |
|
25 | 25 | Rectangle { |
|
26 | 26 | width: 400 |
|
27 | 27 | height: 300 |
|
28 | 28 | |
|
29 | 29 | TestCase { |
|
30 | 30 | id: tc1 |
|
31 | 31 | name: "tst_qml-qtquicktest XY Series" |
|
32 | 32 | when: windowShown |
|
33 | 33 | |
|
34 | 34 | function test_properties() { |
|
35 | 35 | verify(lineSeries.color != undefined); |
|
36 | 36 | compare(lineSeries.pointsVisible, false); |
|
37 | 37 | // TODO: Should the properties be set or not? |
|
38 | 38 | // verify(lineSeries.axisX != null); |
|
39 | 39 | // verify(lineSeries.axisY != null); |
|
40 | 40 | compare(lineSeries.capStyle, Qt.SquareCap); |
|
41 | 41 | compare(lineSeries.style, Qt.SolidLine); |
|
42 | 42 | compare(lineSeries.width, 2.0); |
|
43 | 43 | |
|
44 | 44 | verify(splineSeries.color != undefined); |
|
45 | 45 | compare(splineSeries.pointsVisible, false); |
|
46 | 46 | // TODO: Should the properties be set or not? |
|
47 | 47 | // verify(splineSeries.axisX != null); |
|
48 | 48 | // verify(splineSeries.axisY != null); |
|
49 | 49 | compare(splineSeries.capStyle, Qt.SquareCap); |
|
50 | 50 | compare(splineSeries.style, Qt.SolidLine); |
|
51 | 51 | compare(splineSeries.width, 2.0); |
|
52 | 52 | |
|
53 | 53 | verify(scatterSeries.color != undefined); |
|
54 | 54 | // TODO: Should the properties be set or not? |
|
55 | 55 | // verify(scatterSeries.axisX != null); |
|
56 | 56 | // verify(scatterSeries.axisY != null); |
|
57 | 57 | verify(scatterSeries.borderColor != undefined); |
|
58 | 58 | compare(scatterSeries.borderWidth, 2.0); |
|
59 | 59 | compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle); |
|
60 | 60 | compare(scatterSeries.markerSize, 15.0); |
|
61 | 61 | |
|
62 | 62 | verify(areaSeries.color != undefined); |
|
63 | 63 | verify(areaSeries.borderColor != undefined); |
|
64 | 64 | compare(areaSeries.borderWidth, 2.0); |
|
65 | 65 | } |
|
66 | 66 | |
|
67 | 67 | function test_append() { |
|
68 | 68 | lineSeriesPointAddedSpy.clear(); |
|
69 | 69 | splineSeriesPointAddedSpy.clear(); |
|
70 | 70 | scatterSeriesPointAddedSpy.clear(); |
|
71 | 71 | var count = append(); |
|
72 | 72 | compare(lineSeries.count, count); |
|
73 | 73 | compare(splineSeries.count, count); |
|
74 | 74 | compare(scatterSeries.count, count); |
|
75 | 75 | tryCompare(lineSeriesPointAddedSpy.count, count); |
|
76 | 76 | tryCompare(splineSeriesPointAddedSpy.count, count); |
|
77 | 77 | tryCompare(scatterSeriesPointAddedSpy.count, count); |
|
78 | 78 | clear(); |
|
79 | 79 | compare(lineSeries.count, 0); |
|
80 | 80 | compare(splineSeries.count, 0); |
|
81 | 81 | compare(scatterSeries.count, 0); |
|
82 | 82 | } |
|
83 | 83 | |
|
84 | 84 | function test_replace() { |
|
85 | 85 | var count = append(); |
|
86 | 86 | for (var i = 0; i < count; i++) { |
|
87 | 87 | lineSeries.replace(lineSeries.at(i).x, lineSeries.at(i).y, i, Math.random()); |
|
88 | 88 | splineSeries.replace(splineSeries.at(i).x, splineSeries.at(i).y, i, Math.random()); |
|
89 | 89 | scatterSeries.replace(scatterSeries.at(i).x, scatterSeries.at(i).y, i, Math.random()); |
|
90 | 90 | } |
|
91 | 91 | compare(lineSeries.count, count); |
|
92 | 92 | compare(splineSeries.count, count); |
|
93 | 93 | compare(scatterSeries.count, count); |
|
94 | 94 | tryCompare(lineSeriesPointReplacedSpy.count, count); |
|
95 | 95 | tryCompare(splineSeriesPointReplacedSpy.count, count); |
|
96 | 96 | tryCompare(scatterSeriesPointReplacedSpy.count, count); |
|
97 | 97 | clear(); |
|
98 | 98 | } |
|
99 | 99 | |
|
100 | 100 | function test_insert() { |
|
101 | 101 | var count = append(); |
|
102 | 102 | lineSeriesPointAddedSpy.clear(); |
|
103 | 103 | splineSeriesPointAddedSpy.clear(); |
|
104 | 104 | scatterSeriesPointAddedSpy.clear(); |
|
105 | 105 | for (var i = 0; i < count; i++) { |
|
106 | 106 | lineSeries.insert(i * 2, i, Math.random()); |
|
107 | 107 | splineSeries.insert(i * 2, i, Math.random()); |
|
108 | 108 | scatterSeries.insert(i * 2, i, Math.random()); |
|
109 | 109 | } |
|
110 | 110 | compare(lineSeries.count, count * 2); |
|
111 | 111 | compare(splineSeries.count, count * 2); |
|
112 | 112 | compare(scatterSeries.count, count * 2); |
|
113 | 113 | tryCompare(lineSeriesPointAddedSpy.count, count); |
|
114 | 114 | tryCompare(splineSeriesPointAddedSpy.count, count); |
|
115 | 115 | tryCompare(scatterSeriesPointAddedSpy.count, count); |
|
116 | 116 | clear(); |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | function test_remove() { |
|
120 | 120 | lineSeriesPointRemovedSpy.clear(); |
|
121 | 121 | splineSeriesPointRemovedSpy.clear(); |
|
122 | 122 | scatterSeriesPointRemovedSpy.clear(); |
|
123 | 123 | var count = append(); |
|
124 | 124 | for (var i = 0; i < count; i++) { |
|
125 | 125 | lineSeries.remove(lineSeries.at(0).x, lineSeries.at(0).y); |
|
126 | 126 | splineSeries.remove(splineSeries.at(0).x, splineSeries.at(0).y); |
|
127 | 127 | scatterSeries.remove(scatterSeries.at(0).x, scatterSeries.at(0).y); |
|
128 | 128 | } |
|
129 | 129 | compare(lineSeries.count, 0); |
|
130 | 130 | compare(splineSeries.count, 0); |
|
131 | 131 | compare(scatterSeries.count, 0); |
|
132 | 132 | tryCompare(lineSeriesPointRemovedSpy.count, count); |
|
133 | 133 | tryCompare(splineSeriesPointRemovedSpy.count, count); |
|
134 | 134 | tryCompare(scatterSeriesPointRemovedSpy.count, count); |
|
135 | 135 | } |
|
136 | 136 | |
|
137 | 137 | // Not a test function, called from test functions |
|
138 | 138 | function append() { |
|
139 | 139 | var count = 100; |
|
140 | 140 | chartView.axisX().min = 0; |
|
141 | 141 | chartView.axisX().max = 100; |
|
142 | 142 | chartView.axisY().min = 0; |
|
143 | 143 | chartView.axisY().max = 1; |
|
144 | 144 | |
|
145 | 145 | for (var i = 0; i < count; i++) { |
|
146 | 146 | lineSeries.append(i, Math.random()); |
|
147 | 147 | splineSeries.append(i, Math.random()); |
|
148 | 148 | scatterSeries.append(i, Math.random()); |
|
149 | 149 | } |
|
150 | 150 | |
|
151 | 151 | return count; |
|
152 | 152 | } |
|
153 | 153 | |
|
154 | 154 | // Not a test function, called from test functions |
|
155 | 155 | function clear() { |
|
156 | 156 | lineSeries.clear(); |
|
157 | 157 | splineSeries.clear(); |
|
158 | 158 | scatterSeries.clear(); |
|
159 | 159 | } |
|
160 | 160 | } |
|
161 | 161 | |
|
162 | 162 | ChartView { |
|
163 | 163 | id: chartView |
|
164 | 164 | anchors.fill: parent |
|
165 | 165 | |
|
166 | 166 | LineSeries { |
|
167 | 167 | id: lineSeries |
|
168 | 168 | name: "line" |
|
169 | 169 | |
|
170 | 170 | SignalSpy { |
|
171 | 171 | id: lineSeriesPointAddedSpy |
|
172 | 172 | target: lineSeries |
|
173 | 173 | signalName: "pointAdded" |
|
174 | 174 | } |
|
175 | 175 | |
|
176 | 176 | SignalSpy { |
|
177 | 177 | id: lineSeriesPointReplacedSpy |
|
178 | 178 | target: lineSeries |
|
179 | 179 | signalName: "pointReplaced" |
|
180 | 180 | } |
|
181 | 181 | |
|
182 | 182 | SignalSpy { |
|
183 | 183 | id: lineSeriesPointsReplacedSpy |
|
184 | 184 | target: lineSeries |
|
185 | 185 | signalName: "pointsReplaced" |
|
186 | 186 | } |
|
187 | 187 | |
|
188 | 188 | SignalSpy { |
|
189 | 189 | id: lineSeriesPointRemovedSpy |
|
190 | 190 | target: lineSeries |
|
191 | 191 | signalName: "pointRemoved" |
|
192 | 192 | } |
|
193 | 193 | } |
|
194 | 194 | |
|
195 | 195 | AreaSeries { |
|
196 | 196 | id: areaSeries |
|
197 | 197 | name: "area" |
|
198 | 198 | upperSeries: lineSeries |
|
199 | 199 | } |
|
200 | 200 | |
|
201 | 201 | SplineSeries { |
|
202 | 202 | id: splineSeries |
|
203 | 203 | name: "spline" |
|
204 | 204 | |
|
205 | 205 | SignalSpy { |
|
206 | 206 | id: splineSeriesPointAddedSpy |
|
207 | 207 | target: splineSeries |
|
208 | 208 | signalName: "pointAdded" |
|
209 | 209 | } |
|
210 | 210 | |
|
211 | 211 | SignalSpy { |
|
212 | 212 | id: splineSeriesPointReplacedSpy |
|
213 | 213 | target: splineSeries |
|
214 | 214 | signalName: "pointReplaced" |
|
215 | 215 | } |
|
216 | 216 | |
|
217 | 217 | SignalSpy { |
|
218 | 218 | id: splineSeriesPointsReplacedSpy |
|
219 | 219 | target: splineSeries |
|
220 | 220 | signalName: "pointsReplaced" |
|
221 | 221 | } |
|
222 | 222 | |
|
223 | 223 | SignalSpy { |
|
224 | 224 | id: splineSeriesPointRemovedSpy |
|
225 | 225 | target: splineSeries |
|
226 | 226 | signalName: "pointRemoved" |
|
227 | 227 | } |
|
228 | 228 | } |
|
229 | 229 | |
|
230 | 230 | ScatterSeries { |
|
231 | 231 | id: scatterSeries |
|
232 | 232 | name: "scatter" |
|
233 | 233 | |
|
234 | 234 | SignalSpy { |
|
235 | 235 | id: scatterSeriesPointAddedSpy |
|
236 | 236 | target: scatterSeries |
|
237 | 237 | signalName: "pointAdded" |
|
238 | 238 | } |
|
239 | 239 | |
|
240 | 240 | SignalSpy { |
|
241 | 241 | id: scatterSeriesPointReplacedSpy |
|
242 | 242 | target: scatterSeries |
|
243 | 243 | signalName: "pointReplaced" |
|
244 | 244 | } |
|
245 | 245 | |
|
246 | 246 | SignalSpy { |
|
247 | 247 | id: scatterSeriesPointsReplacedSpy |
|
248 | 248 | target: scatterSeries |
|
249 | 249 | signalName: "pointsReplaced" |
|
250 | 250 | } |
|
251 | 251 | |
|
252 | 252 | SignalSpy { |
|
253 | 253 | id: scatterSeriesPointRemovedSpy |
|
254 | 254 | target: scatterSeries |
|
255 | 255 | signalName: "pointRemoved" |
|
256 | 256 | } |
|
257 | 257 | } |
|
258 | 258 | } |
|
259 | 259 | } |
General Comments 0
You need to be logged in to leave comments.
Login now