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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/app_list_controller_unittest.cc
diff --git a/ash/wm/app_list_controller_unittest.cc b/ash/wm/app_list_controller_unittest.cc
index 5d3704893343654223b0521b87fb4b747fe798da..7295c67bf27c01dd096248342cfd5d8936582db0 100644
--- a/ash/wm/app_list_controller_unittest.cc
+++ b/ash/wm/app_list_controller_unittest.cc
@@ -8,6 +8,7 @@
#include "ash/test/test_shell_delegate.h"
#include "ash/wm/window_util.h"
#include "base/memory/scoped_ptr.h"
+#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
@@ -42,4 +43,51 @@ TEST_F(AppListControllerTest, RemainVisibleWhenFocusingToApplistContainer) {
EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility());
}
+// Tests that clicking outside the app-list bubble closes it.
+TEST_F(AppListControllerTest, ClickOutsideBubbleClosesBubble) {
+ Shell* shell = Shell::GetInstance();
+ shell->ToggleAppList(NULL);
+
+ aura::Window* app_window = shell->GetAppListWindow();
+ ASSERT_TRUE(app_window);
+ aura::test::EventGenerator generator(shell->GetPrimaryRootWindow(),
+ app_window);
+ // Click on the bubble itself. The bubble should remain visible.
+ generator.ClickLeftButton();
+ EXPECT_TRUE(shell->GetAppListTargetVisibility());
+
+ // Click outside the bubble. This should close it.
+ gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow();
+ gfx::Point point_outside =
+ gfx::Point(app_window_bounds.right(), app_window_bounds.y()) +
+ gfx::Vector2d(10, 0);
+ EXPECT_TRUE(shell->GetPrimaryRootWindow()->bounds().Contains(point_outside));
+ generator.MoveMouseToInHost(point_outside);
+ generator.ClickLeftButton();
+ EXPECT_FALSE(shell->GetAppListTargetVisibility());
+}
+
+// Tests that clicking outside the app-list bubble closes it.
+TEST_F(AppListControllerTest, TapOutsideBubbleClosesBubble) {
+ Shell* shell = Shell::GetInstance();
+ shell->ToggleAppList(NULL);
+
+ aura::Window* app_window = shell->GetAppListWindow();
+ ASSERT_TRUE(app_window);
+ gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow();
+
+ aura::test::EventGenerator generator(shell->GetPrimaryRootWindow());
+ // Click on the bubble itself. The bubble should remain visible.
+ generator.GestureTapAt(app_window_bounds.CenterPoint());
+ EXPECT_TRUE(shell->GetAppListTargetVisibility());
+
+ // Click outside the bubble. This should close it.
+ gfx::Point point_outside =
+ gfx::Point(app_window_bounds.right(), app_window_bounds.y()) +
+ gfx::Vector2d(10, 0);
+ EXPECT_TRUE(shell->GetPrimaryRootWindow()->bounds().Contains(point_outside));
+ generator.GestureTapAt(point_outside);
+ EXPECT_FALSE(shell->GetAppListTargetVisibility());
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698