Debian Codegraph @

tests/auto/qml-qtquicktest/data/tst_valueaxis_1_2.qml

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 import QtQuick 2.0
5 import QtTest 1.0
6 import QtCharts 1.2
7
8 Rectangle {
9 width: 400
10 height: 300
11
12 TestCase {
13 id: tc1
14 name: "tst_qml-qtquicktest ValueAxis 1.2"
15 when: windowShown
16
17 // test functions are run in alphabetical order, the name has 'a' so that it
18 // will be the first function to execute.
19 function test_a_properties() {
20 // Default properties
21 verify(axisX.min < 0, "AxisX min");
22 verify(axisX.max > 0, "AxisX max");
23 verify(axisY.min < 0, "AxisY min");
24 verify(axisY.max > 0, "AxisY max");
25 verify(axisX.tickCount == 5, "AxisX tick count");
26 verify(axisY.tickCount == 5, "AxisY tick count");
27 verify(axisX.labelFormat == "", "label format");
28
29 // Modify properties
30 axisX.tickCount = 3;
31 verify(axisX.tickCount == 3, "set tick count");
32 }
33
34 function test_functions() {
35 // Set the axis ranges to not "nice" ones...
36 var min = 0.032456456;
37 var max = 10.67845634;
38 axisX.min = min;
39 axisX.max = max;
40 axisY.min = min;
41 axisY.max = max;
42
43 // ...And then apply nice numbers and verify the range was changed
44 axisX.applyNiceNumbers();
45 axisY.applyNiceNumbers();
46 verify(axisX.min != min);
47 verify(axisX.max != max);
48 verify(axisY.min != min);
49 verify(axisY.max != max);
50 }
51
52 function test_signals() {
53 minChangedSpy.clear();
54 maxChangedSpy.clear();
55 axisX.min = 2;
56 compare(minChangedSpy.count, 1, "onMinChanged");
57 compare(maxChangedSpy.count, 0, "onMaxChanged");
58
59 axisX.max = 8;
60 compare(minChangedSpy.count, 1, "onMinChanged");
61 compare(maxChangedSpy.count, 1, "onMaxChanged");
62
63 // restore original values
64 axisX.min = 0;
65 axisX.max = 10;
66 compare(minChangedSpy.count, 2, "onMinChanged");
67 compare(maxChangedSpy.count, 2, "onMaxChanged");
68 }
69 }
70
71 ChartView {
72 id: chartView
73 anchors.fill: parent
74
75 LineSeries {
76 id: lineSeries1
77 axisX: ValueAxis {
78 id: axisX
79 }
80 axisY: ValueAxis {
81 id: axisY
82 }
83 XYPoint { x: -1; y: -1 }
84 XYPoint { x: 0; y: 0 }
85 XYPoint { x: 5; y: 5 }
86 }
87
88 SignalSpy {
89 id: minChangedSpy
90 target: axisX
91 signalName: "minChanged"
92 }
93 SignalSpy {
94 id: maxChangedSpy
95 target: axisX
96 signalName: "maxChanged"
97 }
98 }
99 }