| 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 2.0 |
| 7 |
|
| 8 |
Rectangle { |
| 9 |
width: 400 |
| 10 |
height: 300 |
| 11 |
|
| 12 |
TestCase { |
| 13 |
id: tc1 |
| 14 |
name: "tst_qml-qtquicktest CategoryAxis 2.0" |
| 15 |
when: windowShown |
| 16 |
|
| 17 |
function test_minMax() { |
| 18 |
compare(lineSeries1.axisX.min, 0, "AxisX min"); |
| 19 |
compare(lineSeries1.axisX.max, 10, "AxisX max"); |
| 20 |
compare(lineSeries1.axisY.min, 0, "AxisY min"); |
| 21 |
compare(lineSeries1.axisY.max, 10, "AxisY max"); |
| 22 |
} |
| 23 |
|
| 24 |
function test_categories() { |
| 25 |
compare(lineSeries1.axisY.startValue, 0, "AxisY start value"); |
| 26 |
compare(lineSeries1.axisY.count, 3, "AxisY count"); |
| 27 |
compare(lineSeries1.axisY.categoriesLabels[0], "label0", "AxisY categories labels"); |
| 28 |
compare(lineSeries1.axisY.categoriesLabels[1], "label1", "AxisY categories labels"); |
| 29 |
compare(lineSeries1.axisY.categoriesLabels[2], "label2", "AxisY categories labels"); |
| 30 |
} |
| 31 |
|
| 32 |
function test_signals() { |
| 33 |
axisLabelsPositionSpy.clear(); |
| 34 |
lineSeries1.axisY.labelsPosition = CategoryAxis.AxisLabelsPositionOnValue; |
| 35 |
compare(axisLabelsPositionSpy.count, 1, "onLabelsPositionChanged"); |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
ChartView { |
| 40 |
id: chartView |
| 41 |
anchors.fill: parent |
| 42 |
|
| 43 |
LineSeries { |
| 44 |
id: lineSeries1 |
| 45 |
axisX: ValueAxis { |
| 46 |
id: axisX |
| 47 |
min: 0 |
| 48 |
max: 10 |
| 49 |
} |
| 50 |
axisY: CategoryAxis { |
| 51 |
id: axisY |
| 52 |
min: 0 |
| 53 |
max: 10 |
| 54 |
startValue: 0 |
| 55 |
CategoryRange { |
| 56 |
label: "label0" |
| 57 |
endValue: 1 |
| 58 |
} |
| 59 |
CategoryRange { |
| 60 |
label: "label1" |
| 61 |
endValue: 3 |
| 62 |
} |
| 63 |
CategoryRange { |
| 64 |
label: "label2" |
| 65 |
endValue: 10 |
| 66 |
} |
| 67 |
SignalSpy { |
| 68 |
id: axisLabelsPositionSpy |
| 69 |
target: axisY |
| 70 |
signalName: "labelsPositionChanged" |
| 71 |
} |
| 72 |
} |
| 73 |
XYPoint { x: -1; y: -1 } |
| 74 |
XYPoint { x: 0; y: 0 } |
| 75 |
XYPoint { x: 5; y: 5 } |
| 76 |
} |
| 77 |
} |
| 78 |
} |