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

Side by Side Diff: chrome/browser/ui/window_sizer/window_sizer_ash_uitest.cc

Issue 1376063005: Cleanup: Pull some browser keep alive functions into its own file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build Created 5 years, 2 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 "ash/shelf/shelf.h" 5 #include "ash/shelf/shelf.h"
6 #include "ash/shelf/shelf_view.h" 6 #include "ash/shelf/shelf_view.h"
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/shelf_test_api.h" 8 #include "ash/test/shelf_test_api.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "chrome/browser/lifetime/application_lifetime.h" 12 #include "chrome/browser/lifetime/application_lifetime.h"
13 #include "chrome/browser/lifetime/browser_keep_alive.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_list.h" 15 #include "chrome/browser/ui/browser_list.h"
15 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
17 #include "ui/aura/window_event_dispatcher.h" 18 #include "ui/aura/window_event_dispatcher.h"
18 #include "ui/base/test/ui_controls.h" 19 #include "ui/base/test/ui_controls.h"
19 #include "ui/events/test/event_generator.h" 20 #include "ui/events/test/event_generator.h"
20 #include "ui/views/controls/menu/menu_controller.h" 21 #include "ui/views/controls/menu/menu_controller.h"
21 #include "ui/views/view.h" 22 #include "ui/views/view.h"
22 #include "ui/views/view_model.h" 23 #include "ui/views/view_model.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #define MAYBE_OpenBrowserUsingShelfOnOtherDisplay DISABLED_OpenBrowserUsingShelf OnOtherDisplay 73 #define MAYBE_OpenBrowserUsingShelfOnOtherDisplay DISABLED_OpenBrowserUsingShelf OnOtherDisplay
73 #define MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay DISABLED_OpenBrowserUsin gContextMenuOnOtherDisplay 74 #define MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay DISABLED_OpenBrowserUsin gContextMenuOnOtherDisplay
74 #else 75 #else
75 #define MAYBE_OpenBrowserUsingShelfOnOtherDisplay OpenBrowserUsingShelfOnOtherDi splay 76 #define MAYBE_OpenBrowserUsingShelfOnOtherDisplay OpenBrowserUsingShelfOnOtherDi splay
76 #define MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay OpenBrowserUsingContextM enuOnOtherDisplay 77 #define MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay OpenBrowserUsingContextM enuOnOtherDisplay
77 #endif 78 #endif
78 79
79 IN_PROC_BROWSER_TEST_F(WindowSizerTest, 80 IN_PROC_BROWSER_TEST_F(WindowSizerTest,
80 MAYBE_OpenBrowserUsingShelfOnOtherDisplay) { 81 MAYBE_OpenBrowserUsingShelfOnOtherDisplay) {
81 // Don't shutdown when closing the last browser window. 82 // Don't shutdown when closing the last browser window.
82 chrome::IncrementKeepAliveCount(); 83 browser_lifetime::IncrementKeepAliveCount();
83 84
84 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); 85 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows();
85 86
86 BrowserList* browser_list = 87 BrowserList* browser_list =
87 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); 88 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
88 89
89 EXPECT_EQ(1u, browser_list->size()); 90 EXPECT_EQ(1u, browser_list->size());
90 // Close the browser window so that clicking icon will create a new window. 91 // Close the browser window so that clicking icon will create a new window.
91 CloseBrowser(browser_list->get(0)); 92 CloseBrowser(browser_list->get(0));
92 EXPECT_EQ(0u, browser_list->size()); 93 EXPECT_EQ(0u, browser_list->size());
(...skipping 12 matching lines...) Expand all
105 EXPECT_EQ(0u, browser_list->size()); 106 EXPECT_EQ(0u, browser_list->size());
106 107
107 OpenBrowserUsingShelfOnRootWindow(root_windows[0]); 108 OpenBrowserUsingShelfOnRootWindow(root_windows[0]);
108 109
109 // A new browser must be created on 1st display. 110 // A new browser must be created on 1st display.
110 EXPECT_EQ(1u, browser_list->size()); 111 EXPECT_EQ(1u, browser_list->size());
111 EXPECT_EQ(root_windows[0], 112 EXPECT_EQ(root_windows[0],
112 browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow()); 113 browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow());
113 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); 114 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow());
114 115
115 // Balanced with the chrome::IncrementKeepAliveCount above. 116 // Balanced with the browser_lifetime::IncrementKeepAliveCount above.
116 chrome::DecrementKeepAliveCount(); 117 browser_lifetime::DecrementKeepAliveCount();
117 } 118 }
118 119
119 namespace { 120 namespace {
120 121
121 class WindowSizerContextMenuTest : public WindowSizerTest { 122 class WindowSizerContextMenuTest : public WindowSizerTest {
122 public: 123 public:
123 WindowSizerContextMenuTest() {} 124 WindowSizerContextMenuTest() {}
124 ~WindowSizerContextMenuTest() override {} 125 ~WindowSizerContextMenuTest() override {}
125 126
126 static void Step1(gfx::Point release_point) { 127 static void Step1(gfx::Point release_point) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 chrome_icon.x(), chrome_icon.y(), 160 chrome_icon.x(), chrome_icon.y(),
160 base::Bind(&WindowSizerContextMenuTest::Step1, release_point)); 161 base::Bind(&WindowSizerContextMenuTest::Step1, release_point));
161 base::MessageLoop::current()->Run(); 162 base::MessageLoop::current()->Run();
162 } 163 }
163 164
164 } // namespace 165 } // namespace
165 166
166 IN_PROC_BROWSER_TEST_F(WindowSizerContextMenuTest, 167 IN_PROC_BROWSER_TEST_F(WindowSizerContextMenuTest,
167 MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay) { 168 MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay) {
168 // Don't shutdown when closing the last browser window. 169 // Don't shutdown when closing the last browser window.
169 chrome::IncrementKeepAliveCount(); 170 browser_lifetime::IncrementKeepAliveCount();
170 171
171 views::MenuController::TurnOffMenuSelectionHoldForTest(); 172 views::MenuController::TurnOffMenuSelectionHoldForTest();
172 173
173 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); 174 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows();
174 175
175 BrowserList* browser_list = 176 BrowserList* browser_list =
176 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); 177 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
177 178
178 ASSERT_EQ(1u, browser_list->size()); 179 ASSERT_EQ(1u, browser_list->size());
179 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); 180 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow());
180 CloseBrowser(browser_list->get(0)); 181 CloseBrowser(browser_list->get(0));
181 182
182 OpenBrowserUsingContextMenuOnRootWindow(root_windows[1]); 183 OpenBrowserUsingContextMenuOnRootWindow(root_windows[1]);
183 184
184 // A new browser must be created on 2nd display. 185 // A new browser must be created on 2nd display.
185 ASSERT_EQ(1u, browser_list->size()); 186 ASSERT_EQ(1u, browser_list->size());
186 EXPECT_EQ(root_windows[1], 187 EXPECT_EQ(root_windows[1],
187 browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow()); 188 browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow());
188 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); 189 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow());
189 190
190 OpenBrowserUsingContextMenuOnRootWindow(root_windows[0]); 191 OpenBrowserUsingContextMenuOnRootWindow(root_windows[0]);
191 192
192 // Next new browser must be created on 1st display. 193 // Next new browser must be created on 1st display.
193 ASSERT_EQ(2u, browser_list->size()); 194 ASSERT_EQ(2u, browser_list->size());
194 EXPECT_EQ(root_windows[0], 195 EXPECT_EQ(root_windows[0],
195 browser_list->get(1)->window()->GetNativeWindow()->GetRootWindow()); 196 browser_list->get(1)->window()->GetNativeWindow()->GetRootWindow());
196 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); 197 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow());
197 198
198 // Balanced with the chrome::IncrementKeepAliveCount above. 199 // Balanced with the browser_lifetime::IncrementKeepAliveCount above.
199 chrome::DecrementKeepAliveCount(); 200 browser_lifetime::DecrementKeepAliveCount();
200 } 201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698