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

Side by Side Diff: ui/aura/window_unittest.cc

Issue 10854060: ash: Use different hit-test outer-region for mouse and touch events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: scale Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/window.cc ('k') | ui/oak/oak_aura_window_display.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 w1.Init(ui::LAYER_TEXTURED); 422 w1.Init(ui::LAYER_TEXTURED);
423 w1.SetBounds(gfx::Rect(10, 20, 50, 60)); 423 w1.SetBounds(gfx::Rect(10, 20, 50, 60));
424 w1.Show(); 424 w1.Show();
425 w1.SetParent(NULL); 425 w1.SetParent(NULL);
426 426
427 // Points are in the Window's coordinates. 427 // Points are in the Window's coordinates.
428 EXPECT_TRUE(w1.HitTest(gfx::Point(1, 1))); 428 EXPECT_TRUE(w1.HitTest(gfx::Point(1, 1)));
429 EXPECT_FALSE(w1.HitTest(gfx::Point(-1, -1))); 429 EXPECT_FALSE(w1.HitTest(gfx::Point(-1, -1)));
430 430
431 // We can expand the bounds slightly to track events outside our border. 431 // We can expand the bounds slightly to track events outside our border.
432 w1.set_hit_test_bounds_override_outer(gfx::Insets(-1, -1, -1, -1)); 432 w1.SetHitTestBoundsOverrideOuter(gfx::Insets(-1, -1, -1, -1), 5);
433 EXPECT_TRUE(w1.HitTest(gfx::Point(-1, -1))); 433 EXPECT_TRUE(w1.HitTest(gfx::Point(-1, -1)));
434 EXPECT_FALSE(w1.HitTest(gfx::Point(-2, -2))); 434 EXPECT_FALSE(w1.HitTest(gfx::Point(-2, -2)));
435 435
436 ui::TouchEventImpl pressed(
437 ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 0, getTime());
438 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&pressed);
439 EXPECT_TRUE(w1.HitTest(gfx::Point(-2, -2)));
440 EXPECT_TRUE(w1.HitTest(gfx::Point(-5, -5)));
441 EXPECT_FALSE(w1.HitTest(gfx::Point(-5, -6)));
442 ui::TouchEventImpl released(
443 ui::ET_TOUCH_RELEASED, gfx::Point(50, 50), 0, getTime());
444 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&released);
445 EXPECT_FALSE(w1.HitTest(gfx::Point(-2, -2)));
446
436 // TODO(beng): clip Window to parent. 447 // TODO(beng): clip Window to parent.
437 } 448 }
438 449
439 TEST_F(WindowTest, HitTestMask) { 450 TEST_F(WindowTest, HitTestMask) {
440 Window w1(new MaskedWindowDelegate(gfx::Rect(5, 6, 20, 30))); 451 Window w1(new MaskedWindowDelegate(gfx::Rect(5, 6, 20, 30)));
441 w1.Init(ui::LAYER_NOT_DRAWN); 452 w1.Init(ui::LAYER_NOT_DRAWN);
442 w1.SetBounds(gfx::Rect(10, 20, 50, 60)); 453 w1.SetBounds(gfx::Rect(10, 20, 50, 60));
443 w1.Show(); 454 w1.Show();
444 w1.SetParent(NULL); 455 w1.SetParent(NULL);
445 456
(...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 2456 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
2446 2457
2447 // No bounds changed notification at the end of animation since layer 2458 // No bounds changed notification at the end of animation since layer
2448 // delegate is NULL. 2459 // delegate is NULL.
2449 EXPECT_FALSE(delegate.bounds_changed()); 2460 EXPECT_FALSE(delegate.bounds_changed());
2450 EXPECT_NE("0,0 100x100", window->bounds().ToString()); 2461 EXPECT_NE("0,0 100x100", window->bounds().ToString());
2451 } 2462 }
2452 2463
2453 } // namespace test 2464 } // namespace test
2454 } // namespace aura 2465 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.cc ('k') | ui/oak/oak_aura_window_display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698