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

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

Issue 10566009: app_list: Fix shadow bleeds over launcher button and steals mouse events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix aura_demo compilation Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/window_delegate.h ('k') | ui/views/widget/native_widget_aura.h » ('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>
8
7 #include "base/basictypes.h" 9 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
9 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/aura/client/capture_client.h" 13 #include "ui/aura/client/capture_client.h"
12 #include "ui/aura/client/stacking_client.h" 14 #include "ui/aura/client/stacking_client.h"
13 #include "ui/aura/client/visibility_client.h" 15 #include "ui/aura/client/visibility_client.h"
14 #include "ui/aura/event.h" 16 #include "ui/aura/event.h"
15 #include "ui/aura/layout_manager.h" 17 #include "ui/aura/layout_manager.h"
16 #include "ui/aura/root_window.h" 18 #include "ui/aura/root_window.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 EXPECT_FALSE(w1.HitTest(gfx::Point(-1, -1))); 317 EXPECT_FALSE(w1.HitTest(gfx::Point(-1, -1)));
316 318
317 // We can expand the bounds slightly to track events outside our border. 319 // We can expand the bounds slightly to track events outside our border.
318 w1.set_hit_test_bounds_override_outer(gfx::Insets(-1, -1, -1, -1)); 320 w1.set_hit_test_bounds_override_outer(gfx::Insets(-1, -1, -1, -1));
319 EXPECT_TRUE(w1.HitTest(gfx::Point(-1, -1))); 321 EXPECT_TRUE(w1.HitTest(gfx::Point(-1, -1)));
320 EXPECT_FALSE(w1.HitTest(gfx::Point(-2, -2))); 322 EXPECT_FALSE(w1.HitTest(gfx::Point(-2, -2)));
321 323
322 // TODO(beng): clip Window to parent. 324 // TODO(beng): clip Window to parent.
323 } 325 }
324 326
327 TEST_F(WindowTest, HitTestMask) {
328 Window w1(new MaskedWindowDelegate(gfx::Rect(5, 6, 20, 30)));
329 w1.Init(ui::LAYER_NOT_DRAWN);
330 w1.SetBounds(gfx::Rect(10, 20, 50, 60));
331 w1.Show();
332 w1.SetParent(NULL);
333
334 // Points inside the mask.
335 EXPECT_TRUE(w1.HitTest(gfx::Point(5, 6))); // top-left
336 EXPECT_TRUE(w1.HitTest(gfx::Point(15, 21))); // center
337 EXPECT_TRUE(w1.HitTest(gfx::Point(24, 35))); // bottom-right
338
339 // Points outside the mask.
340 EXPECT_FALSE(w1.HitTest(gfx::Point(0, 0)));
341 EXPECT_FALSE(w1.HitTest(gfx::Point(60, 80)));
342 EXPECT_FALSE(w1.HitTest(gfx::Point(4, 6)));
343 EXPECT_FALSE(w1.HitTest(gfx::Point(5, 5)));
344 EXPECT_FALSE(w1.HitTest(gfx::Point(25, 36)));
345 }
346
325 TEST_F(WindowTest, GetEventHandlerForPoint) { 347 TEST_F(WindowTest, GetEventHandlerForPoint) {
326 scoped_ptr<Window> w1( 348 scoped_ptr<Window> w1(
327 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL)); 349 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL));
328 scoped_ptr<Window> w11( 350 scoped_ptr<Window> w11(
329 CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); 351 CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get()));
330 scoped_ptr<Window> w111( 352 scoped_ptr<Window> w111(
331 CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); 353 CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get()));
332 scoped_ptr<Window> w1111( 354 scoped_ptr<Window> w1111(
333 CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); 355 CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get()));
334 scoped_ptr<Window> w12( 356 scoped_ptr<Window> w12(
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 window13->layer()->set_delegate(NULL); 1695 window13->layer()->set_delegate(NULL);
1674 1696
1675 // Move window1 to the front. All transients should move with it, and their 1697 // Move window1 to the front. All transients should move with it, and their
1676 // order should be preserved. 1698 // order should be preserved.
1677 root->StackChildAtTop(window1.get()); 1699 root->StackChildAtTop(window1.get());
1678 1700
1679 EXPECT_EQ("2 3 1 11 12 13", ChildWindowIDsAsString(root)); 1701 EXPECT_EQ("2 3 1 11 12 13", ChildWindowIDsAsString(root));
1680 } 1702 }
1681 1703
1682 class TestVisibilityClient : public client::VisibilityClient { 1704 class TestVisibilityClient : public client::VisibilityClient {
1683 public: 1705 public:
1684 explicit TestVisibilityClient(RootWindow* root_window) 1706 explicit TestVisibilityClient(RootWindow* root_window)
1685 : ignore_visibility_changes_(false) { 1707 : ignore_visibility_changes_(false) {
1686 client::SetVisibilityClient(root_window, this); 1708 client::SetVisibilityClient(root_window, this);
1687 } 1709 }
1688 virtual ~TestVisibilityClient() { 1710 virtual ~TestVisibilityClient() {
1689 } 1711 }
1690 1712
1691 void set_ignore_visibility_changes(bool ignore_visibility_changes) { 1713 void set_ignore_visibility_changes(bool ignore_visibility_changes) {
1692 ignore_visibility_changes_ = ignore_visibility_changes; 1714 ignore_visibility_changes_ = ignore_visibility_changes;
1693 } 1715 }
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 2311 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
2290 2312
2291 // No bounds changed notification at the end of animation since layer 2313 // No bounds changed notification at the end of animation since layer
2292 // delegate is NULL. 2314 // delegate is NULL.
2293 EXPECT_FALSE(delegate.bounds_changed()); 2315 EXPECT_FALSE(delegate.bounds_changed());
2294 EXPECT_NE("0,0 100x100", window->bounds().ToString()); 2316 EXPECT_NE("0,0 100x100", window->bounds().ToString());
2295 } 2317 }
2296 2318
2297 } // namespace test 2319 } // namespace test
2298 } // namespace aura 2320 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_delegate.h ('k') | ui/views/widget/native_widget_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698