| OLD | NEW |
| 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/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/browser/lifetime/application_lifetime.h" | 14 #include "chrome/browser/lifetime/keep_alive_types.h" |
| 15 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
| 19 #include "ui/aura/window_event_dispatcher.h" | 20 #include "ui/aura/window_event_dispatcher.h" |
| 20 #include "ui/base/test/ui_controls.h" | 21 #include "ui/base/test/ui_controls.h" |
| 21 #include "ui/events/test/event_generator.h" | 22 #include "ui/events/test/event_generator.h" |
| 22 #include "ui/views/controls/menu/menu_controller.h" | 23 #include "ui/views/controls/menu/menu_controller.h" |
| 23 #include "ui/views/view.h" | 24 #include "ui/views/view.h" |
| 24 #include "ui/views/view_model.h" | 25 #include "ui/views/view_model.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 #else | 79 #else |
| 79 #define MAYBE_OpenBrowserUsingShelfOnOtherDisplay \ | 80 #define MAYBE_OpenBrowserUsingShelfOnOtherDisplay \ |
| 80 OpenBrowserUsingShelfOnOtherDisplay | 81 OpenBrowserUsingShelfOnOtherDisplay |
| 81 #define MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay \ | 82 #define MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay \ |
| 82 OpenBrowserUsingContextMenuOnOtherDisplay | 83 OpenBrowserUsingContextMenuOnOtherDisplay |
| 83 #endif | 84 #endif |
| 84 | 85 |
| 85 IN_PROC_BROWSER_TEST_F(WindowSizerTest, | 86 IN_PROC_BROWSER_TEST_F(WindowSizerTest, |
| 86 MAYBE_OpenBrowserUsingShelfOnOtherDisplay) { | 87 MAYBE_OpenBrowserUsingShelfOnOtherDisplay) { |
| 87 // Don't shutdown when closing the last browser window. | 88 // Don't shutdown when closing the last browser window. |
| 88 chrome::IncrementKeepAliveCount(); | 89 ScopedKeepAlive test_keep_alive(KeepAliveOrigin::BROWSER_PROCESS_CHROMEOS, |
| 90 KeepAliveRestartOption::DISABLED); |
| 89 | 91 |
| 90 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); | 92 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); |
| 91 | 93 |
| 92 BrowserList* browser_list = BrowserList::GetInstance(); | 94 BrowserList* browser_list = BrowserList::GetInstance(); |
| 93 | 95 |
| 94 EXPECT_EQ(1u, browser_list->size()); | 96 EXPECT_EQ(1u, browser_list->size()); |
| 95 // Close the browser window so that clicking icon will create a new window. | 97 // Close the browser window so that clicking icon will create a new window. |
| 96 CloseBrowser(browser_list->get(0)); | 98 CloseBrowser(browser_list->get(0)); |
| 97 EXPECT_EQ(0u, browser_list->size()); | 99 EXPECT_EQ(0u, browser_list->size()); |
| 98 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); | 100 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 109 CloseBrowser(browser_list->get(0)); | 111 CloseBrowser(browser_list->get(0)); |
| 110 EXPECT_EQ(0u, browser_list->size()); | 112 EXPECT_EQ(0u, browser_list->size()); |
| 111 | 113 |
| 112 OpenBrowserUsingShelfOnRootWindow(root_windows[0]); | 114 OpenBrowserUsingShelfOnRootWindow(root_windows[0]); |
| 113 | 115 |
| 114 // A new browser must be created on 1st display. | 116 // A new browser must be created on 1st display. |
| 115 EXPECT_EQ(1u, browser_list->size()); | 117 EXPECT_EQ(1u, browser_list->size()); |
| 116 EXPECT_EQ(root_windows[0], | 118 EXPECT_EQ(root_windows[0], |
| 117 browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow()); | 119 browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow()); |
| 118 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); | 120 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); |
| 119 | |
| 120 // Balanced with the chrome::IncrementKeepAliveCount above. | |
| 121 chrome::DecrementKeepAliveCount(); | |
| 122 } | 121 } |
| 123 | 122 |
| 124 namespace { | 123 namespace { |
| 125 | 124 |
| 126 class WindowSizerContextMenuTest : public WindowSizerTest { | 125 class WindowSizerContextMenuTest : public WindowSizerTest { |
| 127 public: | 126 public: |
| 128 WindowSizerContextMenuTest() {} | 127 WindowSizerContextMenuTest() {} |
| 129 ~WindowSizerContextMenuTest() override {} | 128 ~WindowSizerContextMenuTest() override {} |
| 130 | 129 |
| 131 static void Step1(gfx::Point release_point) { | 130 static void Step1(gfx::Point release_point) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 chrome_icon.x(), chrome_icon.y(), | 163 chrome_icon.x(), chrome_icon.y(), |
| 165 base::Bind(&WindowSizerContextMenuTest::Step1, release_point)); | 164 base::Bind(&WindowSizerContextMenuTest::Step1, release_point)); |
| 166 base::MessageLoop::current()->Run(); | 165 base::MessageLoop::current()->Run(); |
| 167 } | 166 } |
| 168 | 167 |
| 169 } // namespace | 168 } // namespace |
| 170 | 169 |
| 171 IN_PROC_BROWSER_TEST_F(WindowSizerContextMenuTest, | 170 IN_PROC_BROWSER_TEST_F(WindowSizerContextMenuTest, |
| 172 MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay) { | 171 MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay) { |
| 173 // Don't shutdown when closing the last browser window. | 172 // Don't shutdown when closing the last browser window. |
| 174 chrome::IncrementKeepAliveCount(); | 173 ScopedKeepAlive test_keep_alive(KeepAliveOrigin::BROWSER_PROCESS_CHROMEOS, |
| 174 KeepAliveRestartOption::DISABLED); |
| 175 | 175 |
| 176 views::MenuController::TurnOffMenuSelectionHoldForTest(); | 176 views::MenuController::TurnOffMenuSelectionHoldForTest(); |
| 177 | 177 |
| 178 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); | 178 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); |
| 179 | 179 |
| 180 BrowserList* browser_list = BrowserList::GetInstance(); | 180 BrowserList* browser_list = BrowserList::GetInstance(); |
| 181 | 181 |
| 182 ASSERT_EQ(1u, browser_list->size()); | 182 ASSERT_EQ(1u, browser_list->size()); |
| 183 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); | 183 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); |
| 184 CloseBrowser(browser_list->get(0)); | 184 CloseBrowser(browser_list->get(0)); |
| 185 | 185 |
| 186 OpenBrowserUsingContextMenuOnRootWindow(root_windows[1]); | 186 OpenBrowserUsingContextMenuOnRootWindow(root_windows[1]); |
| 187 | 187 |
| 188 // A new browser must be created on 2nd display. | 188 // A new browser must be created on 2nd display. |
| 189 ASSERT_EQ(1u, browser_list->size()); | 189 ASSERT_EQ(1u, browser_list->size()); |
| 190 EXPECT_EQ(root_windows[1], | 190 EXPECT_EQ(root_windows[1], |
| 191 browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow()); | 191 browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow()); |
| 192 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); | 192 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); |
| 193 | 193 |
| 194 OpenBrowserUsingContextMenuOnRootWindow(root_windows[0]); | 194 OpenBrowserUsingContextMenuOnRootWindow(root_windows[0]); |
| 195 | 195 |
| 196 // Next new browser must be created on 1st display. | 196 // Next new browser must be created on 1st display. |
| 197 ASSERT_EQ(2u, browser_list->size()); | 197 ASSERT_EQ(2u, browser_list->size()); |
| 198 EXPECT_EQ(root_windows[0], | 198 EXPECT_EQ(root_windows[0], |
| 199 browser_list->get(1)->window()->GetNativeWindow()->GetRootWindow()); | 199 browser_list->get(1)->window()->GetNativeWindow()->GetRootWindow()); |
| 200 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); | 200 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); |
| 201 | |
| 202 // Balanced with the chrome::IncrementKeepAliveCount above. | |
| 203 chrome::DecrementKeepAliveCount(); | |
| 204 } | 201 } |
| OLD | NEW |