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

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

Issue 2803933003: Adds ash_mus_unittests to FYI bot (Closed)
Patch Set: feedback 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
« no previous file with comments | « no previous file | ash/common/test/ash_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/wm_shell.h" 7 #include "ash/common/wm_shell.h"
8 #include "ash/common/wm_window.h" 8 #include "ash/common/wm_window.h"
9 #include "ash/public/cpp/shell_window_ids.h" 9 #include "ash/public/cpp/shell_window_ids.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
12 #include "ash/test/test_app_list_view_presenter_impl.h" 12 #include "ash/test/test_app_list_view_presenter_impl.h"
13 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "ui/app_list/views/app_list_view.h" 15 #include "ui/app_list/views/app_list_view.h"
16 #include "ui/aura/test/test_windows.h" 16 #include "ui/aura/test/test_windows.h"
17 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
18 #include "ui/display/manager/display_manager.h" 18 #include "ui/display/display.h"
19 #include "ui/display/screen.h"
19 #include "ui/events/test/event_generator.h" 20 #include "ui/events/test/event_generator.h"
20 21
21 namespace ash { 22 namespace ash {
23 namespace {
24
25 int64_t GetPrimaryDisplayId() {
26 return display::Screen::GetScreen()->GetPrimaryDisplay().id();
27 }
28
29 } // namespace
22 30
23 class AppListPresenterDelegateTest : public test::AshTestBase { 31 class AppListPresenterDelegateTest : public test::AshTestBase {
24 public: 32 public:
25 AppListPresenterDelegateTest() {} 33 AppListPresenterDelegateTest() {}
26 ~AppListPresenterDelegateTest() override {} 34 ~AppListPresenterDelegateTest() override {}
27 35
28 app_list::AppListPresenterImpl* app_list_presenter_impl() { 36 app_list::AppListPresenterImpl* app_list_presenter_impl() {
29 return &app_list_presenter_impl_; 37 return &app_list_presenter_impl_;
30 } 38 }
31 39
32 // testing::Test: 40 // testing::Test:
33 void SetUp() override { 41 void SetUp() override {
34 AshTestBase::SetUp(); 42 AshTestBase::SetUp();
35 43
36 // Make the display big enough to hold the app list. 44 // Make the display big enough to hold the app list.
37 UpdateDisplay("1024x768"); 45 UpdateDisplay("1024x768");
38 } 46 }
39 47
40 private: 48 private:
41 test::TestAppListViewPresenterImpl app_list_presenter_impl_; 49 test::TestAppListViewPresenterImpl app_list_presenter_impl_;
42 50
43 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest); 51 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest);
44 }; 52 };
45 53
46 // Tests that app launcher hides when focus moves to a normal window. 54 // Tests that app launcher hides when focus moves to a normal window.
47 TEST_F(AppListPresenterDelegateTest, HideOnFocusOut) { 55 TEST_F(AppListPresenterDelegateTest, HideOnFocusOut) {
48 app_list_presenter_impl()->Show(display_manager()->first_display_id()); 56 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
49 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); 57 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
50 58
51 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 59 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
52 wm::ActivateWindow(window.get()); 60 wm::ActivateWindow(window.get());
53 61
54 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); 62 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
55 } 63 }
56 64
57 // Tests that app launcher remains visible when focus is moved to a different 65 // Tests that app launcher remains visible when focus is moved to a different
58 // window in kShellWindowId_AppListContainer. 66 // window in kShellWindowId_AppListContainer.
59 TEST_F(AppListPresenterDelegateTest, 67 TEST_F(AppListPresenterDelegateTest,
60 RemainVisibleWhenFocusingToApplistContainer) { 68 RemainVisibleWhenFocusingToApplistContainer) {
61 app_list_presenter_impl()->Show(display_manager()->first_display_id()); 69 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
62 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); 70 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
63 71
64 aura::Window* applist_container = Shell::GetContainer( 72 aura::Window* applist_container = Shell::GetContainer(
65 Shell::GetPrimaryRootWindow(), kShellWindowId_AppListContainer); 73 Shell::GetPrimaryRootWindow(), kShellWindowId_AppListContainer);
66 std::unique_ptr<aura::Window> window( 74 std::unique_ptr<aura::Window> window(
67 aura::test::CreateTestWindowWithId(0, applist_container)); 75 aura::test::CreateTestWindowWithId(0, applist_container));
68 wm::ActivateWindow(window.get()); 76 wm::ActivateWindow(window.get());
69 77
70 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); 78 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
71 } 79 }
72 80
73 // Tests that clicking outside the app-list bubble closes it. 81 // Tests that clicking outside the app-list bubble closes it.
74 TEST_F(AppListPresenterDelegateTest, ClickOutsideBubbleClosesBubble) { 82 TEST_F(AppListPresenterDelegateTest, ClickOutsideBubbleClosesBubble) {
75 app_list_presenter_impl()->Show(display_manager()->first_display_id()); 83 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
76 aura::Window* app_window = app_list_presenter_impl()->GetWindow(); 84 aura::Window* app_window = app_list_presenter_impl()->GetWindow();
77 ASSERT_TRUE(app_window); 85 ASSERT_TRUE(app_window);
78 ui::test::EventGenerator& generator = GetEventGenerator(); 86 ui::test::EventGenerator& generator = GetEventGenerator();
79 // Click on the bubble itself. The bubble should remain visible. 87 // Click on the bubble itself. The bubble should remain visible.
80 generator.MoveMouseToCenterOf(app_window); 88 generator.MoveMouseToCenterOf(app_window);
81 generator.ClickLeftButton(); 89 generator.ClickLeftButton();
82 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); 90 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
83 91
84 // Click outside the bubble. This should close it. 92 // Click outside the bubble. This should close it.
85 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); 93 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow();
86 gfx::Point point_outside = 94 gfx::Point point_outside =
87 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + 95 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) +
88 gfx::Vector2d(10, 0); 96 gfx::Vector2d(10, 0);
89 generator.MoveMouseToInHost(point_outside); 97 generator.MoveMouseToInHost(point_outside);
90 generator.ClickLeftButton(); 98 generator.ClickLeftButton();
91 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); 99 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
92 } 100 }
93 101
94 // Tests that clicking outside the app-list bubble closes it. 102 // Tests that clicking outside the app-list bubble closes it.
95 TEST_F(AppListPresenterDelegateTest, TapOutsideBubbleClosesBubble) { 103 TEST_F(AppListPresenterDelegateTest, TapOutsideBubbleClosesBubble) {
96 app_list_presenter_impl()->Show(display_manager()->first_display_id()); 104 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
97 105
98 aura::Window* app_window = app_list_presenter_impl()->GetWindow(); 106 aura::Window* app_window = app_list_presenter_impl()->GetWindow();
99 ASSERT_TRUE(app_window); 107 ASSERT_TRUE(app_window);
100 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); 108 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow();
101 109
102 ui::test::EventGenerator& generator = GetEventGenerator(); 110 ui::test::EventGenerator& generator = GetEventGenerator();
103 // Click on the bubble itself. The bubble should remain visible. 111 // Click on the bubble itself. The bubble should remain visible.
104 generator.GestureTapAt(app_window_bounds.CenterPoint()); 112 generator.GestureTapAt(app_window_bounds.CenterPoint());
105 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); 113 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
106 114
(...skipping 26 matching lines...) Expand all
133 // Updating the displays should close the app list. 141 // Updating the displays should close the app list.
134 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); 142 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
135 } 143 }
136 144
137 // Tests opening the app launcher on a tiny display that is too small to contain 145 // Tests opening the app launcher on a tiny display that is too small to contain
138 // it. 146 // it.
139 TEST_F(AppListPresenterDelegateTest, TinyDisplay) { 147 TEST_F(AppListPresenterDelegateTest, TinyDisplay) {
140 // Set up a screen with a tiny display (height smaller than the app list). 148 // Set up a screen with a tiny display (height smaller than the app list).
141 UpdateDisplay("400x300"); 149 UpdateDisplay("400x300");
142 150
143 app_list_presenter_impl()->Show(display_manager()->first_display_id()); 151 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
144 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); 152 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
145 153
146 // The top of the app list should be on-screen (even if the bottom is not). 154 // The top of the app list should be on-screen (even if the bottom is not).
147 // We need to manually calculate the Y coordinate of the top of the app list 155 // We need to manually calculate the Y coordinate of the top of the app list
148 // from the anchor (center) and height. There isn't a bounds rect that gives 156 // from the anchor (center) and height. There isn't a bounds rect that gives
149 // the actual app list position (the widget bounds include the bubble border 157 // the actual app list position (the widget bounds include the bubble border
150 // which is much bigger than the actual app list size). 158 // which is much bigger than the actual app list size).
151 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); 159 app_list::AppListView* app_list = app_list_presenter_impl()->GetView();
152 int app_list_view_top = 160 int app_list_view_top =
153 app_list->anchor_rect().y() - app_list->bounds().height() / 2; 161 app_list->anchor_rect().y() - app_list->bounds().height() / 2;
154 const int kMinimalAppListMargin = 10; 162 const int kMinimalAppListMargin = 10;
155 EXPECT_GE(app_list_view_top, kMinimalAppListMargin); 163 EXPECT_GE(app_list_view_top, kMinimalAppListMargin);
156 } 164 }
157 165
158 } // namespace ash 166 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/common/test/ash_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698