Debian Codegraph @

tests/auto/qml-qtquicktest/data/tst_barcategoryaxis_1_1.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.1
7
8 Rectangle {
9 width: 400
10 height: 300
11
12 TestCase {
13 id: tc1
14 name: "tst_qml-qtquicktest BarCategoryAxis 1.1"
15 when: windowShown
16
17 function test_minMax() {
18 compare(barSeries1.axisX.min, "Jan", "AxisX min");
19 compare(barSeries1.axisX.max, "Jun", "AxisX max");
20 compare(barSeries1.axisY.min, 0, "AxisY min");
21 compare(barSeries1.axisY.max, 10, "AxisY max");
22 }
23
24 function test_categories() {
25 compare(barSeries1.axisX.count, 6, "AxisX count");
26 categoriesCountChangedSpy.clear();
27 categoriesChangedSpy.clear();
28
29 // Replace categories
30 barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"];
31 compare(barSeries1.axisX.count, 4, "AxisX count");
32 compare(categoriesCountChangedSpy.count, 1, "onCountChanged");
33 compare(categoriesChangedSpy.count, 1, "onCategoriesChanged");
34
35 // Reset the original categories
36 barSeries1.axisX.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
37 compare(barSeries1.axisX.count, 6, "AxisX count");
38 compare(categoriesCountChangedSpy.count, 2, "onCountChanged");
39 compare(categoriesChangedSpy.count, 2, "onCategoriesChanged");
40 }
41
42 function test_minMaxChanged() {
43 axisY.min = -1;
44 compare(minChangedSpy.count, 1, "onMinChanged");
45 compare(maxChangedSpy.count, 0, "onMaxChanged");
46 axisY.max = 12;
47 compare(minChangedSpy.count, 1, "onMinChanged");
48 compare(maxChangedSpy.count, 1, "onMaxChanged");
49 }
50 }
51
52 ChartView {
53 id: chartView
54 anchors.fill: parent
55
56 BarSeries {
57 id: barSeries1
58 axisX: BarCategoryAxis {
59 id: axisX
60 categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun" ]
61 }
62 axisY: ValuesAxis {
63 id: axisY
64 min: 0
65 max: 10
66 }
67 }
68
69 SignalSpy {
70 id: categoriesCountChangedSpy
71 target: axisX
72 signalName: "countChanged"
73 }
74 SignalSpy {
75 id: categoriesChangedSpy
76 target: axisX
77 signalName: "categoriesChanged"
78 }
79 SignalSpy {
80 id: minChangedSpy
81 target: axisY
82 signalName: "minChanged"
83 }
84 SignalSpy {
85 id: maxChangedSpy
86 target: axisY
87 signalName: "maxChanged"
88 }
89 }
90 }