@@ -1,262 +0,0 @@
1−/*
2− * Copyright 2013 Canonical Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.0
18−import QtTest 1.0
19−import Unity.Test 0.1 as UT
20−import ".."
21−
22−/*
23− There's a revealer on each window edge. If you press and hold any edge you
24− should see a black bar appearing from that edge. If you them slide the
25− pointer/finger towards the opposite edge, that black bar should follow
26− the movement up to around the center of the window. Next to the black bar,
27− which represents the "handle" area of the Revealer, You should see a red rectangle,
28− which is the main body of the Showable concrolled by the Revealer (Showable = red
29− + black rects).
30− */
31−Item {
32− width: units.gu(75)
33− height: units.gu(50)
34−
35− RevealingRectangle {
36− id: topRevealingRectangle
37− anchors.fill: parent
38− orientation: Qt.Vertical
39− direction: Qt.LeftToRight
40− }
41−
42− RevealingRectangle {
43− id: bottomRevealingRectangle
44− anchors.fill: parent
45− orientation: Qt.Vertical
46− direction: Qt.RightToLeft
47− }
48−
49− RevealingRectangle {
50− id: leftRevealingRectangle
51− anchors.fill: parent
52− orientation: Qt.Horizontal
53− direction: Qt.LeftToRight
54− }
55−
56− RevealingRectangle {
57− id: rightRevealingRectangle
58− anchors.fill: parent
59− orientation: Qt.Horizontal
60− direction: Qt.RightToLeft
61− }
62−
63− UT.UnityTestCase {
64− name: "Revealer"
65− when: windowShown
66−
67− /*
68− A bit of the showable should be displayed when you press over the
69− handle area of the Revealer.
70−
71− Once released, it should go out of sight again.
72− */
73− function test_showHintOnPress() {
74− var revealer = topRevealingRectangle.revealer
75− var showable = topRevealingRectangle.showable
76−
77− // It starts out of sight
78− compare(showable.y, -showable.height)
79−
80− // (item, x, y, button, modifiers, delay)
81− mousePress(revealer,
82− revealer.width/2,
83− revealer.handleSize/2,
84− Qt.LeftButton, Qt.NoModifier, 0);
85−
86− tryCompare(showable, "y", -showable.height + revealer.handleSize)
87−
88− // (item, x, y, button, modifiers, delay)
89− mouseRelease(revealer,
90− revealer.width/2,
91− revealer.handleSize/2,
92− Qt.LeftButton, Qt.NoModifier, 0);
93−
94− tryCompare(showable, "y", -showable.height)
95− }
96−
97− /*
98− Press over the handle area of the Revealer and drag it to pull
99− its target Showable. Release it half-way and the Showable will
100− continue moving by itself until it's completely shown.
101−
102−
103− Press over the handle area and drag it back to hide the Showable.
104− Release it half-way and it will continue moving by itself until it's
105− completely hidden again.
106− */
107− function test_dragToRevealAndDragBackToHide_top() {
108− var revealer = topRevealingRectangle.revealer
109− var showable = topRevealingRectangle.showable
110− revealer.__dateTime = fakeDateTime
111−
112− // It starts out of sight
113− compare(showable.y, -showable.height)
114−
115− mouseFlick(revealer,
116− revealer.width/2, // from_x
117− revealer.handleSize/2, // from_y
118− revealer.width/2, // to_x
119− showable.height/2); // to_y
120−
121− // Should eventually get fully extended
122− tryCompare(showable, "y", 0)
123−
124− // Now drag it back to get it hidden
125−
126− mouseFlick(revealer,
127− revealer.width/2,
128− showable.height - (revealer.handleSize/2),
129− revealer.width/2,
130− showable.height/2)
131−
132− // Should eventually be completely out of sight
133− tryCompare(showable, "y", -showable.height)
134− }
135−
136− function test_dragToRevealAndDragBackToHide_bottom() {
137− var revealer = bottomRevealingRectangle.revealer
138− var showable = bottomRevealingRectangle.showable
139− var revRect = bottomRevealingRectangle
140− revealer.__dateTime = fakeDateTime
141−
142− // It starts out of sight
143− compare(showable.y, revRect.height)
144−
145− mouseFlick(revealer,
146− revealer.width/2, // from_x
147− revealer.height - revealer.handleSize/2, // from_y
148− revealer.width/2, // to_x
149− revealer.height - showable.height/2); // to_y
150−
151− // Should eventually get fully extended
152− tryCompare(showable, "y", revRect.height - showable.height)
153−
154− // Now drag it back to get it hidden
155−
156− mouseFlick(revealer,
157− revealer.width/2,
158− revealer.handleSize/2,
159− revealer.width/2,
160− revealer.height - showable.height/2)
161−
162− // Should eventually be completely out of sight
163− tryCompare(showable, "y", revRect.height)
164− }
165−
166− function test_dragToRevealAndDragBackToHide_left() {
167− var revealer = leftRevealingRectangle.revealer
168− var showable = leftRevealingRectangle.showable
169− revealer.__dateTime = fakeDateTime
170−
171− // It starts out of sight
172− compare(showable.x, -showable.width)
173−
174− mouseFlick(revealer,
175− revealer.handleSize/2, // from_x
176− revealer.height/2, // from_y
177− showable.width/2, // to_x
178− revealer.height/2) // to_y
179−
180− // Should eventually get fully extended
181− tryCompare(showable, "x", 0)
182−
183− // Now drag it back to get it hidden
184−
185− mouseFlick(revealer,
186− showable.width - (revealer.handleSize/2),
187− revealer.height/2,
188− showable.width/2,
189− revealer.height/2)
190−
191− // Should eventually be completely out of sight
192− tryCompare(showable, "x", -showable.width)
193− }
194−
195− function test_dragToRevealAndDragBackToHide_right() {
196− var revealer = rightRevealingRectangle.revealer
197− var showable = rightRevealingRectangle.showable
198− var revRect = rightRevealingRectangle
199− revealer.__dateTime = fakeDateTime
200−
201− // It starts out of sight
202− compare(showable.x, revRect.width)
203−
204− mouseFlick(revealer,
205− revealer.width - revealer.handleSize/2, // from_x
206− revealer.height/2, // from_y
207− revealer.width - showable.width/2, // to_x
208− revealer.height/2) // to_y
209−
210− // Should eventually get fully extended
211− tryCompare(showable, "x", revRect.width - showable.width)
212−
213− // Now drag it back to get it hidden
214−
215− mouseFlick(revealer,
216− revealer.handleSize/2,
217− revealer.height/2,
218− revealer.width - showable.width/2,
219− revealer.height/2)
220−
221− // Should eventually be completely out of sight
222− tryCompare(showable, "x", revRect.width)
223− }
224−
225− /*
226− Start dragging down (pulling the showable into view) and then,
227− midway, drag a bit upwards and release it.
228− The showable should keep moving away, ending up hidden again.
229− */
230− function test_dragForthAndBackReturnsOriginalState() {
231− var revealer = topRevealingRectangle.revealer
232− var showable = topRevealingRectangle.showable
233− revealer.__dateTime = fakeDateTime
234−
235− // It starts out of sight
236− compare(showable.y, -showable.height)
237−
238− mouseFlick(revealer,
239− revealer.width/2, // from_x
240− revealer.handleSize/2, // from_y
241− revealer.width/2, // to_x
242− showable.height/2, // to_y
243− true /* do press */, false /* don't release */);
244−
245− // Should be about half-extended
246− verify(showable.y > -showable.height*3/4)
247− verify(showable.y < -showable.height*1/4)
248−
249−
250− // Now drag it back a bit
251− mouseFlick(revealer,
252− revealer.width/2, // from_x
253− showable.height/2, // from_y
254− revealer.width/2, // to_x
255− showable.height/4, // to_y
256− false /* don't press */, true /* do release */);
257−
258− // Should eventually be completely out of sight again
259− tryCompare(showable, "y", -showable.height)
260− }
261− }
262−}