aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_dial.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/controls/data/tst_dial.qml')
-rw-r--r--tests/auto/controls/data/tst_dial.qml60
1 files changed, 48 insertions, 12 deletions
diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml
index d0129755..c520aa4c 100644
--- a/tests/auto/controls/data/tst_dial.qml
+++ b/tests/auto/controls/data/tst_dial.qml
@@ -55,6 +55,11 @@ TestCase {
Dial {}
}
+ Component {
+ id: signalSpy
+ SignalSpy {}
+ }
+
property var dial: null
function init() {
@@ -172,9 +177,10 @@ TestCase {
function test_dragging_data() {
return [
- { tag: "default", from: 0, to: 1, leftValue: 0.20, topValue: 0.5, rightValue: 0.8, bottomValue: 1.0 },
- { tag: "scaled2", from: 0, to: 2, leftValue: 0.4, topValue: 1.0, rightValue: 1.6, bottomValue: 2.0 },
- { tag: "scaled1", from: -1, to: 0, leftValue: -0.8, topValue: -0.5, rightValue: -0.2, bottomValue: 0.0 }
+ { tag: "default", from: 0, to: 1, leftValue: 0.20, topValue: 0.5, rightValue: 0.8, bottomValue: 1.0, live: false },
+ { tag: "scaled2", from: 0, to: 2, leftValue: 0.4, topValue: 1.0, rightValue: 1.6, bottomValue: 2.0, live: false },
+ { tag: "scaled1", from: -1, to: 0, leftValue: -0.8, topValue: -0.5, rightValue: -0.2, bottomValue: 0.0, live: false },
+ { tag: "live", from: 0, to: 1, leftValue: 0.20, topValue: 0.5, rightValue: 0.8, bottomValue: 1.0, live: true }
]
}
@@ -183,33 +189,47 @@ TestCase {
verify(dial.wrap);
dial.from = data.from;
dial.to = data.to;
+ dial.live = data.live;
valueSpy.target = dial;
verify(valueSpy.valid);
+ var moveSpy = signalSpy.createObject(testCase, {target: dial, signalName: "moved"});
+ verify(moveSpy.valid);
+
+ var minimumExpectedValueCount = data.live ? 2 : 1;
+
// drag to the left
mouseDrag(dial, dial.width / 2, dial.height / 2, -dial.width / 2, 0, Qt.LeftButton);
fuzzyCompare(dial.value, data.leftValue, 0.1);
- verify(valueSpy.count > 0);
+ verify(valueSpy.count >= minimumExpectedValueCount);
valueSpy.clear();
+ verify(moveSpy.count > 0);
+ moveSpy.clear();
// drag to the top
mouseDrag(dial, dial.width / 2, dial.height / 2, 0, -dial.height / 2, Qt.LeftButton);
fuzzyCompare(dial.value, data.topValue, 0.1);
- verify(valueSpy.count > 0);
+ verify(valueSpy.count >= minimumExpectedValueCount);
valueSpy.clear();
+ verify(moveSpy.count > 0);
+ moveSpy.clear();
// drag to the right
mouseDrag(dial, dial.width / 2, dial.height / 2, dial.width / 2, 0, Qt.LeftButton);
fuzzyCompare(dial.value, data.rightValue, 0.1);
- verify(valueSpy.count > 0);
+ verify(valueSpy.count >= minimumExpectedValueCount);
valueSpy.clear();
+ verify(moveSpy.count > 0);
+ moveSpy.clear();
// drag to the bottom (* 0.6 to ensure we don't go over to the minimum position)
mouseDrag(dial, dial.width / 2, dial.height / 2, 10, dial.height / 2, Qt.LeftButton);
fuzzyCompare(dial.value, data.bottomValue, 0.1);
- verify(valueSpy.count > 0);
+ verify(valueSpy.count >= minimumExpectedValueCount);
valueSpy.clear();
+ verify(moveSpy.count > 0);
+ moveSpy.clear();
}
function test_nonWrapping() {
@@ -267,10 +287,15 @@ TestCase {
var focusScope = focusTest.createObject(testCase);
verify(focusScope);
+ var moveCount = 0;
+
// Tests that we've accepted events that we're interested in.
parentEventSpy.target = focusScope;
parentEventSpy.signalName = "receivedKeyPress";
+ var moveSpy = signalSpy.createObject(testCase, {target: dial, signalName: "moved"});
+ verify(moveSpy.valid);
+
dial.parent = focusScope;
compare(dial.activeFocusOnTab, true);
compare(dial.value, 0);
@@ -281,44 +306,55 @@ TestCase {
keyClick(Qt.Key_Left);
compare(parentEventSpy.count, 0);
+ compare(moveSpy.count, moveCount);
compare(dial.value, 0);
-
+ var oldValue = 0.0;
var keyPairs = [[Qt.Key_Left, Qt.Key_Right], [Qt.Key_Down, Qt.Key_Up]];
for (var keyPairIndex = 0; keyPairIndex < 2; ++keyPairIndex) {
for (var i = 1; i <= 10; ++i) {
+ oldValue = dial.value;
keyClick(keyPairs[keyPairIndex][1]);
compare(parentEventSpy.count, 0);
+ if (oldValue !== dial.value)
+ compare(moveSpy.count, ++moveCount);
compare(dial.value, dial.stepSize * i);
}
compare(dial.value, dial.to);
for (i = 10; i > 0; --i) {
+ oldValue = dial.value;
keyClick(keyPairs[keyPairIndex][0]);
compare(parentEventSpy.count, 0);
+ if (oldValue !== dial.value)
+ compare(moveSpy.count, ++moveCount);
compare(dial.value, dial.stepSize * (i - 1));
}
}
+ dial.value = 0.5;
+
+ keyClick(Qt.Key_Home);
+ compare(parentEventSpy.count, 0);
+ compare(moveSpy.count, ++moveCount);
compare(dial.value, dial.from);
keyClick(Qt.Key_Home);
compare(parentEventSpy.count, 0);
+ compare(moveSpy.count, moveCount);
compare(dial.value, dial.from);
keyClick(Qt.Key_End);
compare(parentEventSpy.count, 0);
+ compare(moveSpy.count, ++moveCount);
compare(dial.value, dial.to);
keyClick(Qt.Key_End);
compare(parentEventSpy.count, 0);
+ compare(moveSpy.count, moveCount);
compare(dial.value, dial.to);
- keyClick(Qt.Key_Home);
- compare(parentEventSpy.count, 0);
- compare(dial.value, dial.from);
-
focusScope.destroy();
}