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 7b467dfabfe39fe960a74b4e92e60a2b2a29d556..da663d63517b606f2455eafb554a7bfd0ddece15 100644 |
--- a/ash/wm/app_list_controller_unittest.cc |
+++ b/ash/wm/app_list_controller_unittest.cc |
@@ -10,12 +10,19 @@ |
#include "base/command_line.h" |
#include "base/memory/scoped_ptr.h" |
#include "ui/app_list/app_list_switches.h" |
+#include "ui/app_list/views/app_list_view.h" |
#include "ui/aura/test/event_generator.h" |
#include "ui/aura/test/test_windows.h" |
#include "ui/aura/window.h" |
namespace ash { |
+namespace { |
+ |
+const int kMinimalCenteredAppListMargin = 10; |
+ |
+} |
+ |
// The parameter is true to test the centered app list, false for normal. |
// (The test name ends in "/0" for normal, "/1" for centered.) |
class AppListControllerTest : public test::AshTestBase, |
@@ -24,6 +31,8 @@ class AppListControllerTest : public test::AshTestBase, |
AppListControllerTest(); |
virtual ~AppListControllerTest(); |
virtual void SetUp() OVERRIDE; |
+ |
+ bool IsCentered() const; |
}; |
AppListControllerTest::AppListControllerTest() { |
@@ -34,12 +43,16 @@ AppListControllerTest::~AppListControllerTest() { |
void AppListControllerTest::SetUp() { |
AshTestBase::SetUp(); |
- if (GetParam()) { |
+ if (IsCentered()) { |
CommandLine* command_line = CommandLine::ForCurrentProcess(); |
command_line->AppendSwitch(app_list::switches::kEnableCenteredAppList); |
} |
} |
+bool AppListControllerTest::IsCentered() const { |
+ return GetParam(); |
+} |
+ |
// Tests that app launcher hides when focus moves to a normal window. |
TEST_P(AppListControllerTest, HideOnFocusOut) { |
Shell::GetInstance()->ToggleAppList(NULL); |
@@ -137,6 +150,37 @@ TEST_P(AppListControllerTest, NonPrimaryDisplay) { |
EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); |
} |
+// Tests opening the app launcher on a tiny display that is too small to contain |
+// it. |
+TEST_P(AppListControllerTest, TinyDisplay) { |
+ // Don't test this for the non-centered app list case; it isn't designed for |
+ // small displays. The most common case of a small display --- when the |
+ // virtual keyboard is open --- switches into the centered app list mode, so |
+ // we just want to run this test in that case. |
+ if (!IsCentered()) |
+ return; |
+ |
+ // UpdateDisplay is not supported in this case, so just skip the test. |
+ if (!SupportsHostWindowResize()) |
+ return; |
+ |
+ // Set up a screen with a tiny display (height smaller than the app list). |
+ UpdateDisplay("400x300"); |
+ |
+ Shell::GetInstance()->ToggleAppList(NULL); |
+ EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); |
+ |
+ // The top of the app list should be on-screen (even if the bottom is not). |
+ // We need to manually calculate the Y coordinate of the top of the app list |
+ // from the anchor (center) and height. There isn't a bounds rect that gives |
+ // the actual app list position (the widget bounds include the bubble border |
+ // which is much bigger than the actual app list size). |
+ app_list::AppListView* app_list = Shell::GetInstance()->GetAppListView(); |
+ int app_list_view_top = |
+ app_list->anchor_rect().y() - app_list->bounds().height() / 2; |
+ EXPECT_GE(app_list_view_top, kMinimalCenteredAppListMargin); |
+} |
+ |
INSTANTIATE_TEST_CASE_P(AppListControllerTestInstance, |
AppListControllerTest, |
::testing::Bool()); |