Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1397)

Side by Side Diff: ui/events/gestures/motion_event_aura_unittest.cc

Issue 1147083005: Separate motion event touch geometry orientation from stylus orientation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Aura Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/gestures/motion_event_aura.cc ('k') | ui/events/test/motion_event_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 radius_y = 67.89f; 259 radius_y = 67.89f;
260 rotation_angle = 23.f; 260 rotation_angle = 23.f;
261 pressure = 0.123f; 261 pressure = 0.123f;
262 TouchEvent press0 = TouchWithTapParams( 262 TouchEvent press0 = TouchWithTapParams(
263 ET_TOUCH_PRESSED, ids[0], radius_x, radius_y, rotation_angle, pressure); 263 ET_TOUCH_PRESSED, ids[0], radius_x, radius_y, rotation_angle, pressure);
264 EXPECT_TRUE(event.OnTouch(press0)); 264 EXPECT_TRUE(event.OnTouch(press0));
265 265
266 EXPECT_EQ(1U, event.GetPointerCount()); 266 EXPECT_EQ(1U, event.GetPointerCount());
267 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMajor(0) / 2); 267 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMajor(0) / 2);
268 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMinor(0) / 2); 268 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMinor(0) / 2);
269 EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(0) * 180 / M_PI + 90); 269 EXPECT_FLOAT_EQ(rotation_angle,
270 event.GetTouchOrientation(0) * 180 / M_PI + 90);
270 EXPECT_FLOAT_EQ(pressure, event.GetPressure(0)); 271 EXPECT_FLOAT_EQ(pressure, event.GetPressure(0));
271 272
272 // Test case: radius_x < radius_y, rotation_angle < 90 273 // Test case: radius_x < radius_y, rotation_angle < 90
273 radius_x = 67.89f; 274 radius_x = 67.89f;
274 radius_y = 123.45f; 275 radius_y = 123.45f;
275 rotation_angle = 46.f; 276 rotation_angle = 46.f;
276 pressure = 0.456f; 277 pressure = 0.456f;
277 TouchEvent press1 = TouchWithTapParams( 278 TouchEvent press1 = TouchWithTapParams(
278 ET_TOUCH_PRESSED, ids[1], radius_x, radius_y, rotation_angle, pressure); 279 ET_TOUCH_PRESSED, ids[1], radius_x, radius_y, rotation_angle, pressure);
279 EXPECT_TRUE(event.OnTouch(press1)); 280 EXPECT_TRUE(event.OnTouch(press1));
280 281
281 EXPECT_EQ(2U, event.GetPointerCount()); 282 EXPECT_EQ(2U, event.GetPointerCount());
282 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(1) / 2); 283 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(1) / 2);
283 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(1) / 2); 284 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(1) / 2);
284 EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(1) * 180 / M_PI); 285 EXPECT_FLOAT_EQ(rotation_angle, event.GetTouchOrientation(1) * 180 / M_PI);
285 EXPECT_FLOAT_EQ(pressure, event.GetPressure(1)); 286 EXPECT_FLOAT_EQ(pressure, event.GetPressure(1));
286 287
287 // Test cloning of tap params 288 // Test cloning of tap params
288 // TODO(mustaq): Make a separate clone test, crbug.com/450655 289 // TODO(mustaq): Make a separate clone test, crbug.com/450655
289 scoped_ptr<MotionEvent> clone = event.Clone(); 290 scoped_ptr<MotionEvent> clone = event.Clone();
290 EXPECT_EQ(event.GetUniqueEventId(), clone->GetUniqueEventId()); 291 EXPECT_EQ(event.GetUniqueEventId(), clone->GetUniqueEventId());
291 EXPECT_EQ(test::ToString(event), test::ToString(*clone)); 292 EXPECT_EQ(test::ToString(event), test::ToString(*clone));
292 EXPECT_EQ(2U, clone->GetPointerCount()); 293 EXPECT_EQ(2U, clone->GetPointerCount());
293 EXPECT_FLOAT_EQ(radius_y, clone->GetTouchMajor(1) / 2); 294 EXPECT_FLOAT_EQ(radius_y, clone->GetTouchMajor(1) / 2);
294 EXPECT_FLOAT_EQ(radius_x, clone->GetTouchMinor(1) / 2); 295 EXPECT_FLOAT_EQ(radius_x, clone->GetTouchMinor(1) / 2);
295 EXPECT_FLOAT_EQ(rotation_angle, clone->GetOrientation(1) * 180 / M_PI); 296 EXPECT_FLOAT_EQ(rotation_angle, clone->GetTouchOrientation(1) * 180 / M_PI);
296 EXPECT_FLOAT_EQ(pressure, clone->GetPressure(1)); 297 EXPECT_FLOAT_EQ(pressure, clone->GetPressure(1));
297 298
298 // TODO(mustaq): The move test seems out-of-scope here, crbug.com/450655 299 // TODO(mustaq): The move test seems out-of-scope here, crbug.com/450655
299 radius_x = 76.98f; 300 radius_x = 76.98f;
300 radius_y = 321.54f; 301 radius_y = 321.54f;
301 rotation_angle = 64.f; 302 rotation_angle = 64.f;
302 pressure = 0.654f; 303 pressure = 0.654f;
303 TouchEvent move1 = TouchWithTapParams( 304 TouchEvent move1 = TouchWithTapParams(
304 ET_TOUCH_MOVED, ids[1], radius_x, radius_y, rotation_angle, pressure); 305 ET_TOUCH_MOVED, ids[1], radius_x, radius_y, rotation_angle, pressure);
305 move1.set_location(gfx::Point(20, 21)); 306 move1.set_location(gfx::Point(20, 21));
306 EXPECT_TRUE(event.OnTouch(move1)); 307 EXPECT_TRUE(event.OnTouch(move1));
307 308
308 EXPECT_EQ(2U, event.GetPointerCount()); 309 EXPECT_EQ(2U, event.GetPointerCount());
309 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(1) / 2); 310 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(1) / 2);
310 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(1) / 2); 311 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(1) / 2);
311 EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(1) * 180 / M_PI); 312 EXPECT_FLOAT_EQ(rotation_angle, event.GetTouchOrientation(1) * 180 / M_PI);
312 EXPECT_FLOAT_EQ(pressure, event.GetPressure(1)); 313 EXPECT_FLOAT_EQ(pressure, event.GetPressure(1));
313 314
314 // Test case: radius_x > radius_y, rotation_angle > 90 315 // Test case: radius_x > radius_y, rotation_angle > 90
315 radius_x = 123.45f; 316 radius_x = 123.45f;
316 radius_y = 67.89f; 317 radius_y = 67.89f;
317 rotation_angle = 92.f; 318 rotation_angle = 92.f;
318 pressure = 0.789f; 319 pressure = 0.789f;
319 TouchEvent press2 = TouchWithTapParams( 320 TouchEvent press2 = TouchWithTapParams(
320 ET_TOUCH_PRESSED, ids[2], radius_x, radius_y, rotation_angle, pressure); 321 ET_TOUCH_PRESSED, ids[2], radius_x, radius_y, rotation_angle, pressure);
321 EXPECT_TRUE(event.OnTouch(press2)); 322 EXPECT_TRUE(event.OnTouch(press2));
322 323
323 EXPECT_EQ(3U, event.GetPointerCount()); 324 EXPECT_EQ(3U, event.GetPointerCount());
324 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMajor(2) / 2); 325 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMajor(2) / 2);
325 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMinor(2) / 2); 326 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMinor(2) / 2);
326 EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(2) * 180 / M_PI + 90); 327 EXPECT_FLOAT_EQ(rotation_angle,
328 event.GetTouchOrientation(2) * 180 / M_PI + 90);
327 EXPECT_FLOAT_EQ(pressure, event.GetPressure(2)); 329 EXPECT_FLOAT_EQ(pressure, event.GetPressure(2));
328 330
329 // Test case: radius_x < radius_y, rotation_angle > 90 331 // Test case: radius_x < radius_y, rotation_angle > 90
330 radius_x = 67.89f; 332 radius_x = 67.89f;
331 radius_y = 123.45f; 333 radius_y = 123.45f;
332 rotation_angle = 135.f; 334 rotation_angle = 135.f;
333 pressure = 0.012f; 335 pressure = 0.012f;
334 TouchEvent press3 = TouchWithTapParams( 336 TouchEvent press3 = TouchWithTapParams(
335 ET_TOUCH_PRESSED, ids[3], radius_x, radius_y, rotation_angle, pressure); 337 ET_TOUCH_PRESSED, ids[3], radius_x, radius_y, rotation_angle, pressure);
336 EXPECT_TRUE(event.OnTouch(press3)); 338 EXPECT_TRUE(event.OnTouch(press3));
337 339
338 EXPECT_EQ(4U, event.GetPointerCount()); 340 EXPECT_EQ(4U, event.GetPointerCount());
339 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(3) / 2); 341 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(3) / 2);
340 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(3) / 2); 342 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(3) / 2);
341 EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(3) * 180 / M_PI + 180); 343 EXPECT_FLOAT_EQ(rotation_angle,
344 event.GetTouchOrientation(3) * 180 / M_PI + 180);
342 EXPECT_FLOAT_EQ(pressure, event.GetPressure(3)); 345 EXPECT_FLOAT_EQ(pressure, event.GetPressure(3));
343 } 346 }
344 347
345 TEST(MotionEventAuraTest, Timestamps) { 348 TEST(MotionEventAuraTest, Timestamps) {
346 // Test that timestamp information is stored and converted correctly. 349 // Test that timestamp information is stored and converted correctly.
347 MotionEventAura event; 350 MotionEventAura event;
348 int ids[] = {7, 13}; 351 int ids[] = {7, 13};
349 int times_in_ms[] = {59436, 60263, 82175}; 352 int times_in_ms[] = {59436, 60263, 82175};
350 353
351 TouchEvent press0 = TouchWithTime( 354 TouchEvent press0 = TouchWithTime(
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 EXPECT_EQ(event.GetUniqueEventId(), press0.unique_event_id()); 508 EXPECT_EQ(event.GetUniqueEventId(), press0.unique_event_id());
506 509
507 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, 6); 510 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, 6);
508 EXPECT_TRUE(event.OnTouch(press1)); 511 EXPECT_TRUE(event.OnTouch(press1));
509 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, event.GetAction()); 512 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, event.GetAction());
510 EXPECT_EQ(2U, event.GetPointerCount()); 513 EXPECT_EQ(2U, event.GetPointerCount());
511 EXPECT_EQ(event.GetUniqueEventId(), press1.unique_event_id()); 514 EXPECT_EQ(event.GetUniqueEventId(), press1.unique_event_id());
512 } 515 }
513 516
514 } // namespace ui 517 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gestures/motion_event_aura.cc ('k') | ui/events/test/motion_event_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698