@@ -0,0 +1,22 | |||||
|
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 | #include <QtQuickTest/quicktest.h> | |||
|
22 | QUICK_TEST_MAIN(example) |
@@ -0,0 +1,8 | |||||
|
1 | !include( ../auto.pri ) { | |||
|
2 | error( "Couldn't find the auto.pri file!" ) | |||
|
3 | } | |||
|
4 | ||||
|
5 | TEMPLATE = app | |||
|
6 | CONFIG += warn_on qmltestcase | |||
|
7 | SOURCES += main.cpp | |||
|
8 | DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" |
@@ -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: "ChartView Properties" | |||
|
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: "ChartView Functions" | |||
|
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: "ChartView Signals" | |||
|
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: "PieSeries" | |||
|
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,259 | |||||
|
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: "XY Series" | |||
|
32 | when: windowShown | |||
|
33 | ||||
|
34 | function test_properties() { | |||
|
35 | verify(lineSeries.color != undefined); | |||
|
36 | compare(lineSeries.pointsVisible, false); | |||
|
37 | // TODO: Should the properties be set or not? | |||
|
38 | // verify(lineSeries.axisX != null); | |||
|
39 | // verify(lineSeries.axisY != null); | |||
|
40 | compare(lineSeries.capStyle, Qt.SquareCap); | |||
|
41 | compare(lineSeries.style, Qt.SolidLine); | |||
|
42 | compare(lineSeries.width, 2.0); | |||
|
43 | ||||
|
44 | verify(splineSeries.color != undefined); | |||
|
45 | compare(splineSeries.pointsVisible, false); | |||
|
46 | // TODO: Should the properties be set or not? | |||
|
47 | // verify(splineSeries.axisX != null); | |||
|
48 | // verify(splineSeries.axisY != null); | |||
|
49 | compare(splineSeries.capStyle, Qt.SquareCap); | |||
|
50 | compare(splineSeries.style, Qt.SolidLine); | |||
|
51 | compare(splineSeries.width, 2.0); | |||
|
52 | ||||
|
53 | verify(scatterSeries.color != undefined); | |||
|
54 | // TODO: Should the properties be set or not? | |||
|
55 | // verify(scatterSeries.axisX != null); | |||
|
56 | // verify(scatterSeries.axisY != null); | |||
|
57 | verify(scatterSeries.borderColor != undefined); | |||
|
58 | compare(scatterSeries.borderWidth, 2.0); | |||
|
59 | compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle); | |||
|
60 | compare(scatterSeries.markerSize, 15.0); | |||
|
61 | ||||
|
62 | verify(areaSeries.color != undefined); | |||
|
63 | verify(areaSeries.borderColor != undefined); | |||
|
64 | compare(areaSeries.borderWidth, 2.0); | |||
|
65 | } | |||
|
66 | ||||
|
67 | function test_append() { | |||
|
68 | lineSeriesPointAddedSpy.clear(); | |||
|
69 | splineSeriesPointAddedSpy.clear(); | |||
|
70 | scatterSeriesPointAddedSpy.clear(); | |||
|
71 | var count = append(); | |||
|
72 | compare(lineSeries.count, count); | |||
|
73 | compare(splineSeries.count, count); | |||
|
74 | compare(scatterSeries.count, count); | |||
|
75 | tryCompare(lineSeriesPointAddedSpy.count, count); | |||
|
76 | tryCompare(splineSeriesPointAddedSpy.count, count); | |||
|
77 | tryCompare(scatterSeriesPointAddedSpy.count, count); | |||
|
78 | clear(); | |||
|
79 | compare(lineSeries.count, 0); | |||
|
80 | compare(splineSeries.count, 0); | |||
|
81 | compare(scatterSeries.count, 0); | |||
|
82 | } | |||
|
83 | ||||
|
84 | function test_replace() { | |||
|
85 | var count = append(); | |||
|
86 | for (var i = 0; i < count; i++) { | |||
|
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()); | |||
|
89 | scatterSeries.replace(scatterSeries.at(i).x, scatterSeries.at(i).y, i, Math.random()); | |||
|
90 | } | |||
|
91 | compare(lineSeries.count, count); | |||
|
92 | compare(splineSeries.count, count); | |||
|
93 | compare(scatterSeries.count, count); | |||
|
94 | tryCompare(lineSeriesPointReplacedSpy.count, count); | |||
|
95 | tryCompare(splineSeriesPointReplacedSpy.count, count); | |||
|
96 | tryCompare(scatterSeriesPointReplacedSpy.count, count); | |||
|
97 | clear(); | |||
|
98 | } | |||
|
99 | ||||
|
100 | function test_insert() { | |||
|
101 | var count = append(); | |||
|
102 | lineSeriesPointAddedSpy.clear(); | |||
|
103 | splineSeriesPointAddedSpy.clear(); | |||
|
104 | scatterSeriesPointAddedSpy.clear(); | |||
|
105 | for (var i = 0; i < count; i++) { | |||
|
106 | lineSeries.insert(i * 2, i, Math.random()); | |||
|
107 | splineSeries.insert(i * 2, i, Math.random()); | |||
|
108 | scatterSeries.insert(i * 2, i, Math.random()); | |||
|
109 | } | |||
|
110 | compare(lineSeries.count, count * 2); | |||
|
111 | compare(splineSeries.count, count * 2); | |||
|
112 | compare(scatterSeries.count, count * 2); | |||
|
113 | tryCompare(lineSeriesPointAddedSpy.count, count); | |||
|
114 | tryCompare(splineSeriesPointAddedSpy.count, count); | |||
|
115 | tryCompare(scatterSeriesPointAddedSpy.count, count); | |||
|
116 | clear(); | |||
|
117 | } | |||
|
118 | ||||
|
119 | function test_remove() { | |||
|
120 | lineSeriesPointRemovedSpy.clear(); | |||
|
121 | splineSeriesPointRemovedSpy.clear(); | |||
|
122 | scatterSeriesPointRemovedSpy.clear(); | |||
|
123 | var count = append(); | |||
|
124 | for (var i = 0; i < count; i++) { | |||
|
125 | lineSeries.remove(lineSeries.at(0).x, lineSeries.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); | |||
|
128 | } | |||
|
129 | compare(lineSeries.count, 0); | |||
|
130 | compare(splineSeries.count, 0); | |||
|
131 | compare(scatterSeries.count, 0); | |||
|
132 | tryCompare(lineSeriesPointRemovedSpy.count, count); | |||
|
133 | tryCompare(splineSeriesPointRemovedSpy.count, count); | |||
|
134 | tryCompare(scatterSeriesPointRemovedSpy.count, count); | |||
|
135 | } | |||
|
136 | ||||
|
137 | // Not a test function, called from test functions | |||
|
138 | function append() { | |||
|
139 | var count = 100; | |||
|
140 | chartView.axisX().min = 0; | |||
|
141 | chartView.axisX().max = 100; | |||
|
142 | chartView.axisY().min = 0; | |||
|
143 | chartView.axisY().max = 1; | |||
|
144 | ||||
|
145 | for (var i = 0; i < count; i++) { | |||
|
146 | lineSeries.append(i, Math.random()); | |||
|
147 | splineSeries.append(i, Math.random()); | |||
|
148 | scatterSeries.append(i, Math.random()); | |||
|
149 | } | |||
|
150 | ||||
|
151 | return count; | |||
|
152 | } | |||
|
153 | ||||
|
154 | // Not a test function, called from test functions | |||
|
155 | function clear() { | |||
|
156 | lineSeries.clear(); | |||
|
157 | splineSeries.clear(); | |||
|
158 | scatterSeries.clear(); | |||
|
159 | } | |||
|
160 | } | |||
|
161 | ||||
|
162 | ChartView { | |||
|
163 | id: chartView | |||
|
164 | anchors.fill: parent | |||
|
165 | ||||
|
166 | LineSeries { | |||
|
167 | id: lineSeries | |||
|
168 | name: "line" | |||
|
169 | ||||
|
170 | SignalSpy { | |||
|
171 | id: lineSeriesPointAddedSpy | |||
|
172 | target: lineSeries | |||
|
173 | signalName: "pointAdded" | |||
|
174 | } | |||
|
175 | ||||
|
176 | SignalSpy { | |||
|
177 | id: lineSeriesPointReplacedSpy | |||
|
178 | target: lineSeries | |||
|
179 | signalName: "pointReplaced" | |||
|
180 | } | |||
|
181 | ||||
|
182 | SignalSpy { | |||
|
183 | id: lineSeriesPointsReplacedSpy | |||
|
184 | target: lineSeries | |||
|
185 | signalName: "pointsReplaced" | |||
|
186 | } | |||
|
187 | ||||
|
188 | SignalSpy { | |||
|
189 | id: lineSeriesPointRemovedSpy | |||
|
190 | target: lineSeries | |||
|
191 | signalName: "pointRemoved" | |||
|
192 | } | |||
|
193 | } | |||
|
194 | ||||
|
195 | AreaSeries { | |||
|
196 | id: areaSeries | |||
|
197 | name: "area" | |||
|
198 | upperSeries: lineSeries | |||
|
199 | } | |||
|
200 | ||||
|
201 | SplineSeries { | |||
|
202 | id: splineSeries | |||
|
203 | name: "spline" | |||
|
204 | ||||
|
205 | SignalSpy { | |||
|
206 | id: splineSeriesPointAddedSpy | |||
|
207 | target: splineSeries | |||
|
208 | signalName: "pointAdded" | |||
|
209 | } | |||
|
210 | ||||
|
211 | SignalSpy { | |||
|
212 | id: splineSeriesPointReplacedSpy | |||
|
213 | target: splineSeries | |||
|
214 | signalName: "pointReplaced" | |||
|
215 | } | |||
|
216 | ||||
|
217 | SignalSpy { | |||
|
218 | id: splineSeriesPointsReplacedSpy | |||
|
219 | target: splineSeries | |||
|
220 | signalName: "pointsReplaced" | |||
|
221 | } | |||
|
222 | ||||
|
223 | SignalSpy { | |||
|
224 | id: splineSeriesPointRemovedSpy | |||
|
225 | target: splineSeries | |||
|
226 | signalName: "pointRemoved" | |||
|
227 | } | |||
|
228 | } | |||
|
229 | ||||
|
230 | ScatterSeries { | |||
|
231 | id: scatterSeries | |||
|
232 | name: "scatter" | |||
|
233 | ||||
|
234 | SignalSpy { | |||
|
235 | id: scatterSeriesPointAddedSpy | |||
|
236 | target: scatterSeries | |||
|
237 | signalName: "pointAdded" | |||
|
238 | } | |||
|
239 | ||||
|
240 | SignalSpy { | |||
|
241 | id: scatterSeriesPointReplacedSpy | |||
|
242 | target: scatterSeries | |||
|
243 | signalName: "pointReplaced" | |||
|
244 | } | |||
|
245 | ||||
|
246 | SignalSpy { | |||
|
247 | id: scatterSeriesPointsReplacedSpy | |||
|
248 | target: scatterSeries | |||
|
249 | signalName: "pointsReplaced" | |||
|
250 | } | |||
|
251 | ||||
|
252 | SignalSpy { | |||
|
253 | id: scatterSeriesPointRemovedSpy | |||
|
254 | target: scatterSeries | |||
|
255 | signalName: "pointRemoved" | |||
|
256 | } | |||
|
257 | } | |||
|
258 | } | |||
|
259 | } |
@@ -29,8 +29,14 SUBDIRS += \ | |||||
29 | contains(QT_VERSION, ^4\\.[0-7]\\.[0-3]\\s*$) | contains(QT_VERSION, ^4\\.[0-6]\\..*) { |
|
29 | contains(QT_VERSION, ^4\\.[0-7]\\.[0-3]\\s*$) | contains(QT_VERSION, ^4\\.[0-6]\\..*) { | |
30 | warning("QtCommercial.Charts QML API requires at least Qt 4.7.4. You are using $${QT_VERSION} so the QML API is disabled.") |
|
30 | warning("QtCommercial.Charts QML API requires at least Qt 4.7.4. You are using $${QT_VERSION} so the QML API is disabled.") | |
31 | } else { |
|
31 | } else { | |
32 |
|
||||
33 | SUBDIRS += qml |
|
32 | SUBDIRS += qml | |
|
33 | ||||
|
34 | # Check if QtQuickTest is installed | |||
|
35 | exists($$(QTDIR)/lib/QtQuickTest.lib) { | |||
|
36 | SUBDIRS += qml-qtquicktest | |||
|
37 | } else { | |||
|
38 | warning("QtQuickTest not found; cannot build QML api unit tests") | |||
|
39 | } | |||
34 | } |
|
40 | } | |
35 |
|
41 | |||
36 | !linux-arm*: { |
|
42 | !linux-arm*: { |
General Comments 0
You need to be logged in to leave comments.
Login now