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

Side by Side Diff: ash/app_list/app_list_presenter_delegate_unittest.cc

Issue 2802903003: Implementation of a full screen app list and re-alphabetized switches (Closed)
Patch Set: Un-parameterized a bubble test, addressed comments, fixed merge conflicts, and fixed a typo! Created 3 years, 8 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
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 <memory> 5 #include <memory>
6 6
7 #include "ash/ash_switches.h"
7 #include "ash/public/cpp/shell_window_ids.h" 8 #include "ash/public/cpp/shell_window_ids.h"
8 #include "ash/shell.h" 9 #include "ash/shell.h"
9 #include "ash/shell_port.h" 10 #include "ash/shell_port.h"
10 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
11 #include "ash/test/test_app_list_view_presenter_impl.h" 12 #include "ash/test/test_app_list_view_presenter_impl.h"
12 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
13 #include "ash/wm_window.h" 14 #include "ash/wm_window.h"
15 #include "base/command_line.h"
14 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "ui/app_list/app_list_switches.h"
15 #include "ui/app_list/views/app_list_view.h" 18 #include "ui/app_list/views/app_list_view.h"
16 #include "ui/aura/test/test_windows.h" 19 #include "ui/aura/test/test_windows.h"
17 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
18 #include "ui/display/display.h" 21 #include "ui/display/display.h"
19 #include "ui/display/screen.h" 22 #include "ui/display/screen.h"
20 #include "ui/events/test/event_generator.h" 23 #include "ui/events/test/event_generator.h"
21 24
22 namespace ash { 25 namespace ash {
23 namespace { 26 namespace {
24 27
25 int64_t GetPrimaryDisplayId() { 28 int64_t GetPrimaryDisplayId() {
26 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); 29 return display::Screen::GetScreen()->GetPrimaryDisplay().id();
27 } 30 }
28 31
29 } // namespace 32 } // namespace
30 33
31 class AppListPresenterDelegateTest : public test::AshTestBase { 34 class AppListPresenterDelegateTest : public test::AshTestBase,
35 public testing::WithParamInterface<bool> {
32 public: 36 public:
33 AppListPresenterDelegateTest() {} 37 AppListPresenterDelegateTest() {}
34 ~AppListPresenterDelegateTest() override {} 38 ~AppListPresenterDelegateTest() override {}
35 39
36 app_list::AppListPresenterImpl* app_list_presenter_impl() { 40 app_list::AppListPresenterImpl* app_list_presenter_impl() {
37 return &app_list_presenter_impl_; 41 return &app_list_presenter_impl_;
38 } 42 }
39 43
40 // testing::Test: 44 // testing::Test:
41 void SetUp() override { 45 void SetUp() override {
42 AshTestBase::SetUp(); 46 AshTestBase::SetUp();
43 47
48 // If the current test is parameterized.
49 if (testing::UnitTest::GetInstance()->current_test_info()->value_param()) {
50 test_with_fullscreen_ = GetParam();
51 if (test_with_fullscreen_)
52 app_list::switches::SetFullscreenAppListSwitch();
53 }
44 // Make the display big enough to hold the app list. 54 // Make the display big enough to hold the app list.
45 UpdateDisplay("1024x768"); 55 UpdateDisplay("1024x768");
46 } 56 }
47 57
48 private: 58 private:
49 test::TestAppListViewPresenterImpl app_list_presenter_impl_; 59 test::TestAppListViewPresenterImpl app_list_presenter_impl_;
60 bool test_with_fullscreen_;
50 61
51 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest); 62 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest);
52 }; 63 };
53 64
65 // Instantiate the Boolean which is used to toggle the Fullscreen app list in
66 // the parameterized tests.
67 INSTANTIATE_TEST_CASE_P(, AppListPresenterDelegateTest, testing::Bool());
68
54 // Tests that app launcher hides when focus moves to a normal window. 69 // Tests that app launcher hides when focus moves to a normal window.
55 TEST_F(AppListPresenterDelegateTest, HideOnFocusOut) { 70 TEST_P(AppListPresenterDelegateTest, HideOnFocusOut) {
56 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); 71 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
57 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); 72 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
58 73
59 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 74 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
60 wm::ActivateWindow(window.get()); 75 wm::ActivateWindow(window.get());
61 76
62 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); 77 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
63 } 78 }
64 79
65 // Tests that app launcher remains visible when focus is moved to a different 80 // Tests that app launcher remains visible when focus is moved to a different
66 // window in kShellWindowId_AppListContainer. 81 // window in kShellWindowId_AppListContainer.
67 TEST_F(AppListPresenterDelegateTest, 82 TEST_P(AppListPresenterDelegateTest,
68 RemainVisibleWhenFocusingToApplistContainer) { 83 RemainVisibleWhenFocusingToApplistContainer) {
69 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); 84 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
70 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); 85 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
71 86
72 aura::Window* applist_container = Shell::GetContainer( 87 aura::Window* applist_container = Shell::GetContainer(
73 Shell::GetPrimaryRootWindow(), kShellWindowId_AppListContainer); 88 Shell::GetPrimaryRootWindow(), kShellWindowId_AppListContainer);
74 std::unique_ptr<aura::Window> window( 89 std::unique_ptr<aura::Window> window(
75 aura::test::CreateTestWindowWithId(0, applist_container)); 90 aura::test::CreateTestWindowWithId(0, applist_container));
76 wm::ActivateWindow(window.get()); 91 wm::ActivateWindow(window.get());
77 92
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // Click outside the bubble. This should close it. 130 // Click outside the bubble. This should close it.
116 gfx::Point point_outside = 131 gfx::Point point_outside =
117 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + 132 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) +
118 gfx::Vector2d(10, 0); 133 gfx::Vector2d(10, 0);
119 generator.GestureTapAt(point_outside); 134 generator.GestureTapAt(point_outside);
120 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); 135 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
121 } 136 }
122 137
123 // Tests opening the app launcher on a non-primary display, then deleting the 138 // Tests opening the app launcher on a non-primary display, then deleting the
124 // display. 139 // display.
125 TEST_F(AppListPresenterDelegateTest, NonPrimaryDisplay) { 140 TEST_P(AppListPresenterDelegateTest, NonPrimaryDisplay) {
126 // Set up a screen with two displays (horizontally adjacent). 141 // Set up a screen with two displays (horizontally adjacent).
127 UpdateDisplay("1024x768,1024x768"); 142 UpdateDisplay("1024x768,1024x768");
128 143
129 std::vector<WmWindow*> root_windows = ShellPort::Get()->GetAllRootWindows(); 144 std::vector<WmWindow*> root_windows = ShellPort::Get()->GetAllRootWindows();
130 ASSERT_EQ(2u, root_windows.size()); 145 ASSERT_EQ(2u, root_windows.size());
131 WmWindow* secondary_root = root_windows[1]; 146 WmWindow* secondary_root = root_windows[1];
132 EXPECT_EQ("1024,0 1024x768", secondary_root->GetBoundsInScreen().ToString()); 147 EXPECT_EQ("1024,0 1024x768", secondary_root->GetBoundsInScreen().ToString());
133 148
134 app_list_presenter_impl()->Show( 149 app_list_presenter_impl()->Show(
135 secondary_root->GetDisplayNearestWindow().id()); 150 secondary_root->GetDisplayNearestWindow().id());
(...skipping 13 matching lines...) Expand all
149 UpdateDisplay("400x300"); 164 UpdateDisplay("400x300");
150 165
151 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); 166 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
152 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); 167 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
153 168
154 // The top of the app list should be on-screen (even if the bottom is not). 169 // The top of the app list should be on-screen (even if the bottom is not).
155 // We need to manually calculate the Y coordinate of the top of the app list 170 // We need to manually calculate the Y coordinate of the top of the app list
156 // from the anchor (center) and height. There isn't a bounds rect that gives 171 // from the anchor (center) and height. There isn't a bounds rect that gives
157 // the actual app list position (the widget bounds include the bubble border 172 // the actual app list position (the widget bounds include the bubble border
158 // which is much bigger than the actual app list size). 173 // which is much bigger than the actual app list size).
174
159 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); 175 app_list::AppListView* app_list = app_list_presenter_impl()->GetView();
160 int app_list_view_top = 176 int app_list_view_top =
161 app_list->anchor_rect().y() - app_list->bounds().height() / 2; 177 app_list->anchor_rect().y() - app_list->bounds().height() / 2;
162 const int kMinimalAppListMargin = 10; 178 const int kMinimalAppListMargin = 10;
179
163 EXPECT_GE(app_list_view_top, kMinimalAppListMargin); 180 EXPECT_GE(app_list_view_top, kMinimalAppListMargin);
164 } 181 }
165 182
166 } // namespace ash 183 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698