32
33 import java.util.Collection;
34
35 /** Zoom tests with two touch points */
36 public class ZoomTest extends ParameterizedTestBase {
37
38 public ZoomTest(TestTouchDevice device) {
39 super(device);
40 }
41
42 @Parameterized.Parameters
43 public static Collection<Object[]> data() {
44 return TestTouchDevices.getTouchDeviceParameters(2);
45 }
46
47 @Before
48 public void verifyZoomEnabled() {
49 Assume.assumeTrue(Boolean.getBoolean("com.sun.javafx.gestures.zoom"));
50 }
51
52 /**
53 * Touch down two fingers,
54 * drag upper finger up in order move but not enough for zooming,
55 * drag again to zoom in (make it twice bigger)
56 */
57 @Ignore("RT-37942")
58 @Test
59 public void testZoomInSmallStepBigStep() throws Exception {
60 int x1 = (int) Math.round(width / 2);
61 int y1 = (int) Math.round(height * 0.3);
62 int x2 = (int) Math.round(width / 2);
63 int y2 = (int) Math.round(height * 0.7);
64 int step = (int) Math.round(height * 0.1);
65 int smallStep = (int) device.getTapRadius() + 1;
66 double threshold = 0;
67 String s = System.getProperty("com.sun.javafx.gestures.zoom.threshold");
68 if (s != null) {
69 threshold = Double.valueOf(s);
70 } else {
71 threshold = 0.1;
72 }
73 Assume.assumeTrue(((y2 - y1) * threshold) > smallStep);
74
75 TestLog.reset();
76 //tap two fingers
77 int p1 = device.addPoint(x1, y1);
125 + ", total factor: " + (factor1 * factor2)
126 + ", inertia value: false");
127
128 //release first finger
129 TestLog.reset();
130 device.removePoint(p1);
131 device.sync();
132 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d", x1, newy1);
133 TestLog.waitForLogContaining("TouchPoint: STATIONARY %d, %d", x2, newy2);
134 TestLog.waitForLogContaining("Zoom finished, factor: " + factor0
135 + ", total factor: " + (factor1 * factor2)
136 + ", inertia value: false");
137 //release second finger
138 TestLog.reset();
139 device.removePoint(p2);
140 device.sync();
141 TestLog.waitForLogContaining("Touch released: %d, %d", x2, newy2);
142 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d", x2, newy2);
143 TestLog.waitForLog("Mouse released: %d, %d", x2, newy2);
144 TestLog.waitForLog("Mouse clicked: %d, %d", x2, newy2);
145 TestLog.waitForLogContainingSubstrings("Zoom", "inertia value: true");
146 Assert.assertEquals(1, TestLog.countLogContaining("Mouse clicked: "
147 + x2 +", " + newy2));
148 }
149
150 /**
151 * Touch down two fingers, zoom in (make it twice bigger)
152 */
153 @Ignore("RT-37942")
154 @Test
155 public void testZoomIn() throws Exception {
156 int x1 = (int) Math.round(width / 2);
157 int y1 = (int) Math.round(height * 0.3);
158 int x2 = (int) Math.round(width / 2);
159 int y2 = (int) Math.round(height * 0.7);
160 int step = (int) Math.round(height * 0.1);
161
162 TestLog.reset();
163 //tap two fingers
164 int p1 = device.addPoint(x1, y1);
165 int p2 = device.addPoint(x2, y2);
166 device.sync();
167
168 //verify pressing two fingers
169 TestLog.waitForLogContaining("TouchPoint: PRESSED %d, %d", x1, y1);
170 TestLog.waitForLogContaining("TouchPoint: PRESSED %d, %d", x2, y2);
171
172 //drag upper finger up and lower down in order to zoom in
173 int newy1 = y1 - step;
205 TestLog.reset();
206 device.removePoint(p1);
207 device.sync();
208 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d",
209 x1, newy1);
210 TestLog.waitForLogContaining("TouchPoint: STATIONARY %d, %d",
211 x2, newy2);
212 TestLog.waitForLogContaining("Zoom finished, factor: " + factor0
213 + ", total factor: " + (factor1 * factor2)
214 + ", inertia value: false");
215
216 //release second finger
217 TestLog.reset();
218 device.removePoint(p2);
219 device.sync();
220 TestLog.waitForLogContaining("Touch released: %d, %d", x2, newy2);
221 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d",
222 x2, newy2);
223 TestLog.waitForLog("Mouse released: %d, %d", x2, newy2);
224 TestLog.waitForLog("Mouse clicked: %d, %d", x2, newy2);
225 TestLog.waitForLogContainingSubstrings("Zoom", "inertia value: true");
226 Assert.assertEquals(1, TestLog.countLogContaining("Mouse clicked: "
227 + x2 +", " + newy2));
228 }
229
230 /**
231 * Touch down two fingers, zoom out (make it quarter of original size)
232 */
233 @Ignore("RT-37942")
234 @Test
235 public void testZoomOut() throws Exception {
236 int x1 = (int) Math.round(width / 2);
237 int y1 = (int) Math.round(height * 0.1);
238 int x2 = (int) Math.round(width / 2);
239 int y2 = (int) Math.round(height * 0.9);
240 int step = (int) Math.round(height * 0.1);
241 double factor0 = 1.0;
242
243 //tap two fingers
244 TestLog.reset();
245 int p1 = device.addPoint(x1, y1);
246 int p2 = device.addPoint(x2, y2);
247 device.sync();
248
249 //verify pressing two fingers
250 TestLog.waitForLogContaining("TouchPoint: PRESSED %d, %d", x1, y1);
251 TestLog.waitForLogContaining("TouchPoint: PRESSED %d, %d", x2, y2);
252
253 //drag upper finger down and lower - up, in order to zoom out
304 TestLog.reset();
305 device.removePoint(p1);
306 device.sync();
307 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d",
308 x1, newy1);
309 TestLog.waitForLogContaining("TouchPoint: STATIONARY %d, %d",
310 x2, newy2);
311 TestLog.waitForLogContaining("Zoom finished, factor: " + factor0
312 + ", total factor: " + (factor1 * factor2 * factor3)
313 + ", inertia value: false");
314
315 //release second finger
316 TestLog.reset();
317 device.removePoint(p2);
318 device.sync();
319 TestLog.waitForLogContaining("Touch released: %d, %d", x2, newy2);
320 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d",
321 x2, newy2);
322 TestLog.waitForLog("Mouse released: %d, %d", x2, newy2);
323 TestLog.waitForLog("Mouse clicked: %d, %d", x2, newy2);
324 TestLog.waitForLogContainingSubstrings("Zoom", "inertia value: true");
325 Assert.assertEquals(1, TestLog.countLogContaining("Mouse clicked: "
326 + x2 +", " + newy2));
327 }
328
329 /**
330 * Touch down two fingers,
331 * drag upper finger down in order move but not enough for zooming,
332 * drag again to zoom out (quarter of original size)
333 */
334 @Ignore("RT-37942")
335 @Test
336 public void testZoomOutSmallStepBigStep() throws Exception {
337 int x1 = (int) Math.round(width / 2);
338 int y1 = (int) Math.round(height * 0.1);
339 int x2 = (int) Math.round(width / 2);
340 int y2 = (int) Math.round(height * 0.9);
341 int step = (int) Math.round(height * 0.1);
342 int smallStep = (int) device.getTapRadius() + 1;
343 double threshold = 0;
344 String s = System.getProperty("com.sun.javafx.gestures.zoom.threshold");
345 if (s != null) {
346 threshold = Double.valueOf(s);
347 } else {
348 threshold = 0.1;
349 }
350 Assume.assumeTrue(((y2 - y1) * threshold) > smallStep);
351 double factor0 = 1.0;
352
353 TestLog.reset();
354 //tap two fingers
423 TestLog.reset();
424 device.removePoint(p1);
425 device.sync();
426 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d",
427 x1, newy1);
428 TestLog.waitForLogContaining("TouchPoint: STATIONARY %d, %d",
429 x2, newy2);
430 TestLog.waitForLogContaining("Zoom finished, factor: " + factor0
431 + ", total factor: " + (factor1 * factor2 * factor3)
432 + ", inertia value: false");
433
434 //release second finger
435 TestLog.reset();
436 device.removePoint(p2);
437 device.sync();
438 TestLog.waitForLogContaining("Touch released: %d, %d", x2, newy2);
439 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d",
440 x2, newy2);
441 TestLog.waitForLog("Mouse released: %d, %d", x2, newy2);
442 TestLog.waitForLog("Mouse clicked: %d, %d", x2, newy2);
443 TestLog.waitForLogContainingSubstrings("Zoom", "inertia value: true");
444 Assert.assertEquals(1, TestLog.countLogContaining("Mouse clicked: "
445 + x2 +", " + newy2));
446 }
447 }
|
32
33 import java.util.Collection;
34
35 /** Zoom tests with two touch points */
36 public class ZoomTest extends ParameterizedTestBase {
37
38 public ZoomTest(TestTouchDevice device) {
39 super(device);
40 }
41
42 @Parameterized.Parameters
43 public static Collection<Object[]> data() {
44 return TestTouchDevices.getTouchDeviceParameters(2);
45 }
46
47 @Before
48 public void verifyZoomEnabled() {
49 Assume.assumeTrue(Boolean.getBoolean("com.sun.javafx.gestures.zoom"));
50 }
51
52 private void tapToStopInertia() throws Exception {
53 int point1X = (int) Math.round(width * 0.1);
54 int point1Y = (int) Math.round(height * 0.3);
55 Assert.assertEquals(0, device.getPressedPoints());
56 TestLog.reset();
57 int p = device.addPoint(point1X, point1Y);
58 device.sync();
59 device.removePoint(p);
60 device.sync();
61 TestLog.waitForLog("Mouse clicked: %d, %d", point1X, point1Y);
62 }
63
64 /**
65 * Touch down two fingers,
66 * drag upper finger up in order move but not enough for zooming,
67 * drag again to zoom in (make it twice bigger)
68 */
69 @Test
70 public void testZoomInSmallStepBigStep() throws Exception {
71 int x1 = (int) Math.round(width / 2);
72 int y1 = (int) Math.round(height * 0.3);
73 int x2 = (int) Math.round(width / 2);
74 int y2 = (int) Math.round(height * 0.7);
75 int step = (int) Math.round(height * 0.1);
76 int smallStep = (int) device.getTapRadius() + 1;
77 double threshold = 0;
78 String s = System.getProperty("com.sun.javafx.gestures.zoom.threshold");
79 if (s != null) {
80 threshold = Double.valueOf(s);
81 } else {
82 threshold = 0.1;
83 }
84 Assume.assumeTrue(((y2 - y1) * threshold) > smallStep);
85
86 TestLog.reset();
87 //tap two fingers
88 int p1 = device.addPoint(x1, y1);
136 + ", total factor: " + (factor1 * factor2)
137 + ", inertia value: false");
138
139 //release first finger
140 TestLog.reset();
141 device.removePoint(p1);
142 device.sync();
143 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d", x1, newy1);
144 TestLog.waitForLogContaining("TouchPoint: STATIONARY %d, %d", x2, newy2);
145 TestLog.waitForLogContaining("Zoom finished, factor: " + factor0
146 + ", total factor: " + (factor1 * factor2)
147 + ", inertia value: false");
148 //release second finger
149 TestLog.reset();
150 device.removePoint(p2);
151 device.sync();
152 TestLog.waitForLogContaining("Touch released: %d, %d", x2, newy2);
153 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d", x2, newy2);
154 TestLog.waitForLog("Mouse released: %d, %d", x2, newy2);
155 TestLog.waitForLog("Mouse clicked: %d, %d", x2, newy2);
156 Assert.assertEquals(1, TestLog.countLogContaining("Mouse clicked: "
157 + x2 +", " + newy2));
158 tapToStopInertia();
159 }
160
161 /**
162 * Touch down two fingers, zoom in (make it twice bigger)
163 */
164 @Test
165 public void testZoomIn() throws Exception {
166 int x1 = (int) Math.round(width / 2);
167 int y1 = (int) Math.round(height * 0.3);
168 int x2 = (int) Math.round(width / 2);
169 int y2 = (int) Math.round(height * 0.7);
170 int step = (int) Math.round(height * 0.1);
171
172 TestLog.reset();
173 //tap two fingers
174 int p1 = device.addPoint(x1, y1);
175 int p2 = device.addPoint(x2, y2);
176 device.sync();
177
178 //verify pressing two fingers
179 TestLog.waitForLogContaining("TouchPoint: PRESSED %d, %d", x1, y1);
180 TestLog.waitForLogContaining("TouchPoint: PRESSED %d, %d", x2, y2);
181
182 //drag upper finger up and lower down in order to zoom in
183 int newy1 = y1 - step;
215 TestLog.reset();
216 device.removePoint(p1);
217 device.sync();
218 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d",
219 x1, newy1);
220 TestLog.waitForLogContaining("TouchPoint: STATIONARY %d, %d",
221 x2, newy2);
222 TestLog.waitForLogContaining("Zoom finished, factor: " + factor0
223 + ", total factor: " + (factor1 * factor2)
224 + ", inertia value: false");
225
226 //release second finger
227 TestLog.reset();
228 device.removePoint(p2);
229 device.sync();
230 TestLog.waitForLogContaining("Touch released: %d, %d", x2, newy2);
231 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d",
232 x2, newy2);
233 TestLog.waitForLog("Mouse released: %d, %d", x2, newy2);
234 TestLog.waitForLog("Mouse clicked: %d, %d", x2, newy2);
235 Assert.assertEquals(1, TestLog.countLogContaining("Mouse clicked: "
236 + x2 +", " + newy2));
237 tapToStopInertia();
238 }
239
240 /**
241 * Touch down two fingers, zoom out (make it quarter of original size)
242 */
243 @Test
244 public void testZoomOut() throws Exception {
245 int x1 = (int) Math.round(width / 2);
246 int y1 = (int) Math.round(height * 0.1);
247 int x2 = (int) Math.round(width / 2);
248 int y2 = (int) Math.round(height * 0.9);
249 int step = (int) Math.round(height * 0.1);
250 double factor0 = 1.0;
251
252 //tap two fingers
253 TestLog.reset();
254 int p1 = device.addPoint(x1, y1);
255 int p2 = device.addPoint(x2, y2);
256 device.sync();
257
258 //verify pressing two fingers
259 TestLog.waitForLogContaining("TouchPoint: PRESSED %d, %d", x1, y1);
260 TestLog.waitForLogContaining("TouchPoint: PRESSED %d, %d", x2, y2);
261
262 //drag upper finger down and lower - up, in order to zoom out
313 TestLog.reset();
314 device.removePoint(p1);
315 device.sync();
316 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d",
317 x1, newy1);
318 TestLog.waitForLogContaining("TouchPoint: STATIONARY %d, %d",
319 x2, newy2);
320 TestLog.waitForLogContaining("Zoom finished, factor: " + factor0
321 + ", total factor: " + (factor1 * factor2 * factor3)
322 + ", inertia value: false");
323
324 //release second finger
325 TestLog.reset();
326 device.removePoint(p2);
327 device.sync();
328 TestLog.waitForLogContaining("Touch released: %d, %d", x2, newy2);
329 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d",
330 x2, newy2);
331 TestLog.waitForLog("Mouse released: %d, %d", x2, newy2);
332 TestLog.waitForLog("Mouse clicked: %d, %d", x2, newy2);
333 Assert.assertEquals(1, TestLog.countLogContaining("Mouse clicked: "
334 + x2 +", " + newy2));
335 tapToStopInertia();
336 }
337
338 /**
339 * Touch down two fingers,
340 * drag upper finger down in order move but not enough for zooming,
341 * drag again to zoom out (quarter of original size)
342 */
343 @Test
344 public void testZoomOutSmallStepBigStep() throws Exception {
345 int x1 = (int) Math.round(width / 2);
346 int y1 = (int) Math.round(height * 0.1);
347 int x2 = (int) Math.round(width / 2);
348 int y2 = (int) Math.round(height * 0.9);
349 int step = (int) Math.round(height * 0.1);
350 int smallStep = (int) device.getTapRadius() + 1;
351 double threshold = 0;
352 String s = System.getProperty("com.sun.javafx.gestures.zoom.threshold");
353 if (s != null) {
354 threshold = Double.valueOf(s);
355 } else {
356 threshold = 0.1;
357 }
358 Assume.assumeTrue(((y2 - y1) * threshold) > smallStep);
359 double factor0 = 1.0;
360
361 TestLog.reset();
362 //tap two fingers
431 TestLog.reset();
432 device.removePoint(p1);
433 device.sync();
434 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d",
435 x1, newy1);
436 TestLog.waitForLogContaining("TouchPoint: STATIONARY %d, %d",
437 x2, newy2);
438 TestLog.waitForLogContaining("Zoom finished, factor: " + factor0
439 + ", total factor: " + (factor1 * factor2 * factor3)
440 + ", inertia value: false");
441
442 //release second finger
443 TestLog.reset();
444 device.removePoint(p2);
445 device.sync();
446 TestLog.waitForLogContaining("Touch released: %d, %d", x2, newy2);
447 TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d",
448 x2, newy2);
449 TestLog.waitForLog("Mouse released: %d, %d", x2, newy2);
450 TestLog.waitForLog("Mouse clicked: %d, %d", x2, newy2);
451 Assert.assertEquals(1, TestLog.countLogContaining("Mouse clicked: "
452 + x2 +", " + newy2));
453 tapToStopInertia();
454 }
455 }
|