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

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: Fixed the mishandled reference that was breaking the build 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
32 void SetFullscreenAppListSwitch() {
33 base::CommandLine::ForCurrentProcess()->AppendSwitch(
34 app_list::switches::kEnableFullscreenAppList);
35 }
36
29 } // namespace 37 } // namespace
30 38
31 class AppListPresenterDelegateTest : public test::AshTestBase { 39 class AppListPresenterDelegateTest : public test::AshTestBase,
40 public testing::WithParamInterface<bool> {
32 public: 41 public:
33 AppListPresenterDelegateTest() {} 42 AppListPresenterDelegateTest() {}
34 ~AppListPresenterDelegateTest() override {} 43 ~AppListPresenterDelegateTest() override {}
35 44
36 app_list::AppListPresenterImpl* app_list_presenter_impl() { 45 app_list::AppListPresenterImpl* app_list_presenter_impl() {
37 return &app_list_presenter_impl_; 46 return &app_list_presenter_impl_;
38 } 47 }
39 48
40 // testing::Test: 49 // testing::Test:
41 void SetUp() override { 50 void SetUp() override {
42 AshTestBase::SetUp(); 51 AshTestBase::SetUp();
43 52
53 // If the current test is parameterized.
54 if (testing::UnitTest::GetInstance()->current_test_info()->value_param()) {
55 test_with_fullscreen_ = GetParam();
56 if (test_with_fullscreen_)
57 SetFullscreenAppListSwitch();
58 }
44 // Make the display big enough to hold the app list. 59 // Make the display big enough to hold the app list.
45 UpdateDisplay("1024x768"); 60 UpdateDisplay("1024x768");
46 } 61 }
47 62
48 private: 63 private:
49 test::TestAppListViewPresenterImpl app_list_presenter_impl_; 64 test::TestAppListViewPresenterImpl app_list_presenter_impl_;
65 bool test_with_fullscreen_;
50 66
51 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest); 67 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest);
52 }; 68 };
53 69
70 // Instantiate the Boolean which is used to toggle the Fullscreen app list in
71 // the parameterized tests.
72 INSTANTIATE_TEST_CASE_P(, AppListPresenterDelegateTest, testing::Bool());
73
54 // Tests that app launcher hides when focus moves to a normal window. 74 // Tests that app launcher hides when focus moves to a normal window.
55 TEST_F(AppListPresenterDelegateTest, HideOnFocusOut) { 75 TEST_P(AppListPresenterDelegateTest, HideOnFocusOut) {
56 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); 76 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
57 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); 77 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
58 78
59 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 79 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
60 wm::ActivateWindow(window.get()); 80 wm::ActivateWindow(window.get());
61 81
62 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); 82 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
63 } 83 }
64 84
65 // Tests that app launcher remains visible when focus is moved to a different 85 // Tests that app launcher remains visible when focus is moved to a different
66 // window in kShellWindowId_AppListContainer. 86 // window in kShellWindowId_AppListContainer.
67 TEST_F(AppListPresenterDelegateTest, 87 TEST_P(AppListPresenterDelegateTest,
68 RemainVisibleWhenFocusingToApplistContainer) { 88 RemainVisibleWhenFocusingToApplistContainer) {
69 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); 89 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
70 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); 90 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
71 91
72 aura::Window* applist_container = Shell::GetContainer( 92 aura::Window* applist_container = Shell::GetContainer(
73 Shell::GetPrimaryRootWindow(), kShellWindowId_AppListContainer); 93 Shell::GetPrimaryRootWindow(), kShellWindowId_AppListContainer);
74 std::unique_ptr<aura::Window> window( 94 std::unique_ptr<aura::Window> window(
75 aura::test::CreateTestWindowWithId(0, applist_container)); 95 aura::test::CreateTestWindowWithId(0, applist_container));
76 wm::ActivateWindow(window.get()); 96 wm::ActivateWindow(window.get());
77 97
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // Click outside the bubble. This should close it. 135 // Click outside the bubble. This should close it.
116 gfx::Point point_outside = 136 gfx::Point point_outside =
117 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + 137 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) +
118 gfx::Vector2d(10, 0); 138 gfx::Vector2d(10, 0);
119 generator.GestureTapAt(point_outside); 139 generator.GestureTapAt(point_outside);
120 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); 140 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
121 } 141 }
122 142
123 // Tests opening the app launcher on a non-primary display, then deleting the 143 // Tests opening the app launcher on a non-primary display, then deleting the
124 // display. 144 // display.
125 TEST_F(AppListPresenterDelegateTest, NonPrimaryDisplay) { 145 TEST_P(AppListPresenterDelegateTest, NonPrimaryDisplay) {
126 // Set up a screen with two displays (horizontally adjacent). 146 // Set up a screen with two displays (horizontally adjacent).
127 UpdateDisplay("1024x768,1024x768"); 147 UpdateDisplay("1024x768,1024x768");
128 148
129 std::vector<WmWindow*> root_windows = ShellPort::Get()->GetAllRootWindows(); 149 std::vector<WmWindow*> root_windows = ShellPort::Get()->GetAllRootWindows();
130 ASSERT_EQ(2u, root_windows.size()); 150 ASSERT_EQ(2u, root_windows.size());
131 WmWindow* secondary_root = root_windows[1]; 151 WmWindow* secondary_root = root_windows[1];
132 EXPECT_EQ("1024,0 1024x768", secondary_root->GetBoundsInScreen().ToString()); 152 EXPECT_EQ("1024,0 1024x768", secondary_root->GetBoundsInScreen().ToString());
133 153
134 app_list_presenter_impl()->Show( 154 app_list_presenter_impl()->Show(
135 secondary_root->GetDisplayNearestWindow().id()); 155 secondary_root->GetDisplayNearestWindow().id());
(...skipping 13 matching lines...) Expand all
149 UpdateDisplay("400x300"); 169 UpdateDisplay("400x300");
150 170
151 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); 171 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
152 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); 172 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
153 173
154 // The top of the app list should be on-screen (even if the bottom is not). 174 // 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 175 // 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 176 // 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 177 // the actual app list position (the widget bounds include the bubble border
158 // which is much bigger than the actual app list size). 178 // which is much bigger than the actual app list size).
179
159 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); 180 app_list::AppListView* app_list = app_list_presenter_impl()->GetView();
160 int app_list_view_top = 181 int app_list_view_top =
161 app_list->anchor_rect().y() - app_list->bounds().height() / 2; 182 app_list->anchor_rect().y() - app_list->bounds().height() / 2;
162 const int kMinimalAppListMargin = 10; 183 const int kMinimalAppListMargin = 10;
184
163 EXPECT_GE(app_list_view_top, kMinimalAppListMargin); 185 EXPECT_GE(app_list_view_top, kMinimalAppListMargin);
164 } 186 }
165 187
166 } // namespace ash 188 } // namespace ash
OLDNEW
« no previous file with comments | « ash/app_list/app_list_presenter_delegate.cc ('k') | chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698