24
24
width: units.gu(40)
25
25
height: units.gu(71)
33
text: "Item #" + index
42
anchors.bottom: parent.top
32
49
name: "BottomEdgeHint"
52
// FIXME: the criteria must be adjusted when QSystemInfo will report
53
// attached mouses, till then we stick to the touch presence
54
property bool hasMouseAttached: QuickUtils.mouseAttached
37
58
target: bottomEdgeHint
38
59
signalName: "onClicked"
42
bottomEdgeHint.iconName = "";
43
bottomEdgeHint.state = "Idle";
47
function test_0_default_state() {
62
function initTestCase() {
63
// register test touch device
64
TestExtras.registerTouchDevice();
66
// FIXME: this test case must be adjusted after we get the QInputDeviceInfo
67
// available to detect attached mouse
68
// the test must be executed before we register touch device
69
if (!hasMouseAttached) {
70
// we don't have mouse attached, so we should be able to lock/unlock
71
compare(bottomEdgeHint.status, BottomEdgeHint.Inactive, "Wrong initial status when no mouse attached");
72
bottomEdgeHint.status = BottomEdgeHint.Locked;
73
compare(bottomEdgeHint.status, BottomEdgeHint.Locked, "Could not toggle status");
75
// we have the mouse attached, should not be able to unlock it
76
compare(bottomEdgeHint.status, BottomEdgeHint.Locked, "Wrong initial status when mouse attached");
77
bottomEdgeHint.status = BottomEdgeHint.Inactive;
78
compare(bottomEdgeHint.status, BottomEdgeHint.Locked, "The bottom edge must not be unlockable as long as mouse is attached!");
80
QuickUtils.mouseAttached = !QuickUtils.mouseAttached;
82
// and then turn locked off if possible
83
bottomEdgeHint.status = BottomEdgeHint.Inactive;
84
if (!hasMouseAttached) {
85
compare(bottomEdgeHint.status, BottomEdgeHint.Inactive, "Cannot unlock hint!");
48
89
compare(bottomEdgeHint.iconName, "");
49
90
compare(bottomEdgeHint.text, "");
50
compare(bottomEdgeHint.state, "Idle");
51
91
compare(bottomEdgeHint.width, mainView.width);
52
92
compare(bottomEdgeHint.height, units.gu(4));
53
93
compare(bottomEdgeHint.y, mainView.height - bottomEdgeHint.height);
94
compare(bottomEdgeHint.flickable, null, "No flickable");
54
95
compare(clickSpy.count, 0, "The BottomEdgeHint should not have received a click.");
96
compare(bottomEdgeHint.deactivateTimeout, 800, "default deactivationTimeout");
99
bottomEdgeHint.flickable = listView;
103
listView.positionViewAtBeginning();
104
bottomEdgeHint.visible = true;
105
bottomEdgeHint.iconName = "";
106
bottomEdgeHint.status = BottomEdgeHint.Inactive;
57
111
function test_hiding() {
58
bottomEdgeHint.state = "Hidden";
59
tryCompare(bottomEdgeHint, "opacity", 0.0);
62
function test_clicking() {
63
bottomEdgeHint.state = "Locked";
64
mouseClick(bottomEdgeHint, centerOf(bottomEdgeHint).x, centerOf(bottomEdgeHint).y);
68
function test_no_clicking_while_unlocked() {
69
mouseClick(bottomEdgeHint, centerOf(bottomEdgeHint).x, centerOf(bottomEdgeHint).y);
70
expectFail("", "No click if not Locked");
112
var flickDy = listView.height - units.gu(5);
113
flick(listView, centerOf(listView).x, flickDy, centerOf(listView).x, -flickDy, 0, 6);
114
if (hasMouseAttached) {
115
expectFailContinue("", "No hiding when mouse attached");
117
tryCompare(bottomEdgeHint, "status", BottomEdgeHint.Hidden);
120
function test_no_hiding_when_locked() {
121
var flickDy = listView.height - units.gu(10);
122
bottomEdgeHint.status = BottomEdgeHint.Locked;
123
flick(listView, centerOf(listView).x, flickDy, centerOf(listView).x, -flickDy, 0, 6);
124
expectFailContinue("", "No hiding when Locked");
125
tryCompare(bottomEdgeHint, "status", BottomEdgeHint.Hidden, 500);
128
function test_clicking_data() {
130
{tag: "when Locked", status: BottomEdgeHint.Locked, xfail: false},
131
{tag: "when Active", status: BottomEdgeHint.Active, xfail: hasMouseAttached},
132
{tag: "when Inactive", status: BottomEdgeHint.Inactive, xfail: true},
133
{tag: "when Hidden", status: BottomEdgeHint.Hidden, xfail: true},
136
function test_clicking(data) {
137
bottomEdgeHint.status = data.status;
138
compare(bottomEdgeHint.status, data.status);
139
mouseClick(bottomEdgeHint, centerOf(bottomEdgeHint).x, centerOf(bottomEdgeHint).y);
141
expectFailContinue(data.tag, "No click is expected");
146
function test_alter_deprecated_state_data() {
148
{tag: "Hidden", status: BottomEdgeHint.Hidden},
149
{tag: "Visible", status: BottomEdgeHint.Inactive},
152
function test_alter_deprecated_state(data) {
153
ignoreWarning(warningFormat(37, 5, "QML BottomEdgeHint: Overloaded 'state' property deprecated, will be removed from 1.3 release. Use 'status' instead."));
154
bottomEdgeHint.state = data.tag;
155
compare(bottomEdgeHint.status, data.status, "Wrong component status: " + data.status);
158
function test_anchoring() {
159
compare(floatingHint.anchors.bottom, mainView.top, "Anhors are broken");
160
floatingHint.parent = floatingItem;
161
compare(floatingHint.anchors.bottom, floatingItem.top, "Anhors are broken after reparenting");
164
function test_no_clicking_data() {
166
{tag: "when hidden", property: "visible"},
167
{tag: "when disabled", property: "enabled"},
170
function test_no_clicking(data) {
171
bottomEdgeHint.status = BottomEdgeHint.Locked;
172
bottomEdgeHint[data.property] = false;
173
mouseClick(bottomEdgeHint, centerOf(bottomEdgeHint).x, centerOf(bottomEdgeHint).y);
174
expectFailContinue("", "No click " + data.tag);
178
function test_activate_by_key_data() {
180
{tag: "enter and unlocked", key: Qt.Key_Return, status: BottomEdgeHint.Inactive},
181
{tag: "return and unlocked", key: Qt.Key_Enter, status: BottomEdgeHint.Inactive},
182
{tag: "enter and locked", key: Qt.Key_Return, status: BottomEdgeHint.Locked},
183
{tag: "return and locked", key: Qt.Key_Enter, status: BottomEdgeHint.Locked},
186
function test_activate_by_key(data) {
187
if (hasMouseAttached && !data.locked) {
188
skip(data.tag, "Test requires ability to unlock");
190
bottomEdgeHint.status = data.status;
191
bottomEdgeHint.forceActiveFocus();
193
if (bottomEdgeHint.status != BottomEdgeHint.Locked) {
194
expectFailContinue(data.tag, "should fail");
197
keyRelease(data.key);
200
// FIXME: must be executed before the test_hiding as flick with mouse affects
201
// the touch drag on ListView for some unknown reason
202
function test_touch_gesture() {
203
if (hasMouseAttached) {
204
skip("", "The test requires touch environment");
206
bottomEdgeHint.text = "Touch Activated";
207
var gestureStartPoint = Qt.point(centerOf(bottomEdgeHint).x, bottomEdgeHint.height - 1);
208
TestExtras.touchDrag(0, bottomEdgeHint, gestureStartPoint, Qt.point(0, -units.gu(8)), 6);
209
tryCompare(bottomEdgeHint, "status", BottomEdgeHint.Active, 400);
210
// then wait till we get back to Idle
211
tryCompare(bottomEdgeHint, "status", BottomEdgeHint.Inactive, 1000);