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