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

Side by Side Diff: ash/wm/app_list_controller_unittest.cc

Issue 178493003: aura: Make Window::HitTest() a private method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/shell.h" 5 #include "ash/shell.h"
6 #include "ash/shell_window_ids.h" 6 #include "ash/shell_window_ids.h"
7 #include "ash/test/ash_test_base.h" 7 #include "ash/test/ash_test_base.h"
8 #include "ash/test/test_shell_delegate.h" 8 #include "ash/test/test_shell_delegate.h"
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "ui/aura/test/event_generator.h"
11 #include "ui/aura/test/test_windows.h" 12 #include "ui/aura/test/test_windows.h"
12 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
13 14
14 namespace ash { 15 namespace ash {
15 16
16 typedef test::AshTestBase AppListControllerTest; 17 typedef test::AshTestBase AppListControllerTest;
17 18
18 // Tests that app launcher hides when focus moves to a normal window. 19 // Tests that app launcher hides when focus moves to a normal window.
19 TEST_F(AppListControllerTest, HideOnFocusOut) { 20 TEST_F(AppListControllerTest, HideOnFocusOut) {
20 Shell::GetInstance()->ToggleAppList(NULL); 21 Shell::GetInstance()->ToggleAppList(NULL);
(...skipping 14 matching lines...) Expand all
35 aura::Window* applist_container = Shell::GetContainer( 36 aura::Window* applist_container = Shell::GetContainer(
36 Shell::GetPrimaryRootWindow(), 37 Shell::GetPrimaryRootWindow(),
37 internal::kShellWindowId_AppListContainer); 38 internal::kShellWindowId_AppListContainer);
38 scoped_ptr<aura::Window> window( 39 scoped_ptr<aura::Window> window(
39 aura::test::CreateTestWindowWithId(0, applist_container)); 40 aura::test::CreateTestWindowWithId(0, applist_container));
40 wm::ActivateWindow(window.get()); 41 wm::ActivateWindow(window.get());
41 42
42 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); 43 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility());
43 } 44 }
44 45
46 // Tests that clicking outside the app-list bubble closes it.
47 TEST_F(AppListControllerTest, ClickOutsideBubbleClosesBubble) {
48 Shell* shell = Shell::GetInstance();
49 shell->ToggleAppList(NULL);
50
51 aura::Window* app_window = shell->GetAppListWindow();
52 ASSERT_TRUE(app_window);
53 aura::test::EventGenerator generator(shell->GetPrimaryRootWindow(),
54 app_window);
55 // Click on the bubble itself. The bubble should remain visible.
56 generator.ClickLeftButton();
57 EXPECT_TRUE(shell->GetAppListTargetVisibility());
58
59 // Click outside the bubble. This should close it.
60 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow();
61 gfx::Point point_outside =
62 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) +
63 gfx::Vector2d(10, 0);
64 EXPECT_TRUE(shell->GetPrimaryRootWindow()->bounds().Contains(point_outside));
65 generator.MoveMouseToInHost(point_outside);
66 generator.ClickLeftButton();
67 EXPECT_FALSE(shell->GetAppListTargetVisibility());
68 }
69
70 // Tests that clicking outside the app-list bubble closes it.
71 TEST_F(AppListControllerTest, TapOutsideBubbleClosesBubble) {
72 Shell* shell = Shell::GetInstance();
73 shell->ToggleAppList(NULL);
74
75 aura::Window* app_window = shell->GetAppListWindow();
76 ASSERT_TRUE(app_window);
77 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow();
78
79 aura::test::EventGenerator generator(shell->GetPrimaryRootWindow());
80 // Click on the bubble itself. The bubble should remain visible.
81 generator.GestureTapAt(app_window_bounds.CenterPoint());
82 EXPECT_TRUE(shell->GetAppListTargetVisibility());
83
84 // Click outside the bubble. This should close it.
85 gfx::Point point_outside =
86 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) +
87 gfx::Vector2d(10, 0);
88 EXPECT_TRUE(shell->GetPrimaryRootWindow()->bounds().Contains(point_outside));
89 generator.GestureTapAt(point_outside);
90 EXPECT_FALSE(shell->GetAppListTargetVisibility());
91 }
92
45 } // namespace ash 93 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698