| 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/launcher/launcher.h" | 5 #include "ash/launcher/launcher.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/launcher_test_api.h" | 8 #include "ash/test/launcher_test_api.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 DISALLOW_COPY_AND_ASSIGN(WindowSizerTest); | 38 DISALLOW_COPY_AND_ASSIGN(WindowSizerTest); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 void CloseBrowser(Browser* browser) { | 41 void CloseBrowser(Browser* browser) { |
| 42 browser->window()->Close(); | 42 browser->window()->Close(); |
| 43 base::MessageLoop::current()->RunUntilIdle(); | 43 base::MessageLoop::current()->RunUntilIdle(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 gfx::Rect GetChromeIconBoundsForRootWindow(aura::RootWindow* root_window) { | 46 gfx::Rect GetChromeIconBoundsForRootWindow(aura::Window* root_window) { |
| 47 ash::Launcher* launcher = ash::Launcher::ForWindow(root_window); | 47 ash::Launcher* launcher = ash::Launcher::ForWindow(root_window); |
| 48 const ash::internal::ShelfView* shelf_view = | 48 const ash::internal::ShelfView* shelf_view = |
| 49 ash::test::LauncherTestAPI(launcher).shelf_view(); | 49 ash::test::LauncherTestAPI(launcher).shelf_view(); |
| 50 const views::ViewModel* view_model = shelf_view->view_model_for_test(); | 50 const views::ViewModel* view_model = shelf_view->view_model_for_test(); |
| 51 | 51 |
| 52 EXPECT_EQ(2, view_model->view_size()); | 52 EXPECT_EQ(2, view_model->view_size()); |
| 53 return view_model->view_at(1)->GetBoundsInScreen(); | 53 return view_model->view_at(1)->GetBoundsInScreen(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void OpenBrowserUsingShelfOnRootWindow(aura::RootWindow* root_window) { | 56 void OpenBrowserUsingShelfOnRootWindow(aura::Window* root_window) { |
| 57 aura::test::EventGenerator generator(root_window); | 57 aura::test::EventGenerator generator(root_window); |
| 58 gfx::Point center = | 58 gfx::Point center = |
| 59 GetChromeIconBoundsForRootWindow(root_window).CenterPoint(); | 59 GetChromeIconBoundsForRootWindow(root_window).CenterPoint(); |
| 60 gfx::Display display = | 60 gfx::Display display = |
| 61 ash::Shell::GetScreen()->GetDisplayNearestWindow(root_window); | 61 ash::Shell::GetScreen()->GetDisplayNearestWindow(root_window); |
| 62 const gfx::Point& origin = display.bounds().origin(); | 62 const gfx::Point& origin = display.bounds().origin(); |
| 63 center.Offset(- origin.x(), - origin.y()); | 63 center.Offset(- origin.x(), - origin.y()); |
| 64 generator.MoveMouseTo(center); | 64 generator.MoveMouseTo(center); |
| 65 generator.ClickLeftButton(); | 65 generator.ClickLeftButton(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
| 71 #define MAYBE_OpenBrowserUsingShelfOnOtherDisplay DISABLED_OpenBrowserUsingShelf
OnOtherDisplay | 71 #define MAYBE_OpenBrowserUsingShelfOnOtherDisplay DISABLED_OpenBrowserUsingShelf
OnOtherDisplay |
| 72 #define MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay DISABLED_OpenBrowserUsin
gContextMenuOnOtherDisplay | 72 #define MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay DISABLED_OpenBrowserUsin
gContextMenuOnOtherDisplay |
| 73 #else | 73 #else |
| 74 #define MAYBE_OpenBrowserUsingShelfOnOtherDisplay OpenBrowserUsingShelfOnOtherDi
splay | 74 #define MAYBE_OpenBrowserUsingShelfOnOtherDisplay OpenBrowserUsingShelfOnOtherDi
splay |
| 75 #define MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay OpenBrowserUsingContextM
enuOnOtherDisplay | 75 #define MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay OpenBrowserUsingContextM
enuOnOtherDisplay |
| 76 #endif | 76 #endif |
| 77 | 77 |
| 78 IN_PROC_BROWSER_TEST_F(WindowSizerTest, | 78 IN_PROC_BROWSER_TEST_F(WindowSizerTest, |
| 79 MAYBE_OpenBrowserUsingShelfOnOtherDisplay) { | 79 MAYBE_OpenBrowserUsingShelfOnOtherDisplay) { |
| 80 // Don't shutdown when closing the last browser window. | 80 // Don't shutdown when closing the last browser window. |
| 81 chrome::StartKeepAlive(); | 81 chrome::StartKeepAlive(); |
| 82 | 82 |
| 83 ash::Shell::RootWindowList root_windows = ash::Shell::GetAllRootWindows(); | 83 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); |
| 84 | 84 |
| 85 BrowserList* browser_list = | 85 BrowserList* browser_list = |
| 86 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 86 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); |
| 87 | 87 |
| 88 EXPECT_EQ(1u, browser_list->size()); | 88 EXPECT_EQ(1u, browser_list->size()); |
| 89 // Close the browser window so that clicking icon will create a new window. | 89 // Close the browser window so that clicking icon will create a new window. |
| 90 CloseBrowser(browser_list->get(0)); | 90 CloseBrowser(browser_list->get(0)); |
| 91 EXPECT_EQ(0u, browser_list->size()); | 91 EXPECT_EQ(0u, browser_list->size()); |
| 92 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); | 92 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); |
| 93 | 93 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 static void QuitLoop() { | 143 static void QuitLoop() { |
| 144 base::MessageLoop::current()->PostTask( | 144 base::MessageLoop::current()->PostTask( |
| 145 FROM_HERE, | 145 FROM_HERE, |
| 146 base::MessageLoop::QuitWhenIdleClosure()); | 146 base::MessageLoop::QuitWhenIdleClosure()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 private: | 149 private: |
| 150 DISALLOW_COPY_AND_ASSIGN(WindowSizerContextMenuTest); | 150 DISALLOW_COPY_AND_ASSIGN(WindowSizerContextMenuTest); |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 void OpenBrowserUsingContextMenuOnRootWindow(aura::RootWindow* root_window) { | 153 void OpenBrowserUsingContextMenuOnRootWindow(aura::Window* root_window) { |
| 154 gfx::Point chrome_icon = | 154 gfx::Point chrome_icon = |
| 155 GetChromeIconBoundsForRootWindow(root_window).CenterPoint(); | 155 GetChromeIconBoundsForRootWindow(root_window).CenterPoint(); |
| 156 gfx::Point release_point = chrome_icon; | 156 gfx::Point release_point = chrome_icon; |
| 157 release_point.Offset(50, -120); | 157 release_point.Offset(50, -120); |
| 158 ui_controls::SendMouseMoveNotifyWhenDone( | 158 ui_controls::SendMouseMoveNotifyWhenDone( |
| 159 chrome_icon.x(), chrome_icon.y(), | 159 chrome_icon.x(), chrome_icon.y(), |
| 160 base::Bind(&WindowSizerContextMenuTest::Step1, release_point)); | 160 base::Bind(&WindowSizerContextMenuTest::Step1, release_point)); |
| 161 base::MessageLoop::current()->Run(); | 161 base::MessageLoop::current()->Run(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace | 164 } // namespace |
| 165 | 165 |
| 166 IN_PROC_BROWSER_TEST_F(WindowSizerContextMenuTest, | 166 IN_PROC_BROWSER_TEST_F(WindowSizerContextMenuTest, |
| 167 MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay) { | 167 MAYBE_OpenBrowserUsingContextMenuOnOtherDisplay) { |
| 168 // Don't shutdown when closing the last browser window. | 168 // Don't shutdown when closing the last browser window. |
| 169 chrome::StartKeepAlive(); | 169 chrome::StartKeepAlive(); |
| 170 | 170 |
| 171 views::MenuController::TurnOffMenuSelectionHoldForTest(); | 171 views::MenuController::TurnOffMenuSelectionHoldForTest(); |
| 172 | 172 |
| 173 ash::Shell::RootWindowList root_windows = ash::Shell::GetAllRootWindows(); | 173 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); |
| 174 | 174 |
| 175 BrowserList* browser_list = | 175 BrowserList* browser_list = |
| 176 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 176 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); |
| 177 | 177 |
| 178 EXPECT_EQ(1u, browser_list->size()); | 178 EXPECT_EQ(1u, browser_list->size()); |
| 179 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); | 179 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); |
| 180 CloseBrowser(browser_list->get(0)); | 180 CloseBrowser(browser_list->get(0)); |
| 181 | 181 |
| 182 OpenBrowserUsingContextMenuOnRootWindow(root_windows[1]); | 182 OpenBrowserUsingContextMenuOnRootWindow(root_windows[1]); |
| 183 | 183 |
| 184 // A new browser must be created on 2nd display. | 184 // A new browser must be created on 2nd display. |
| 185 EXPECT_EQ(1u, browser_list->size()); | 185 EXPECT_EQ(1u, browser_list->size()); |
| 186 EXPECT_EQ(root_windows[1], | 186 EXPECT_EQ(root_windows[1], |
| 187 browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow()); | 187 browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow()); |
| 188 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); | 188 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); |
| 189 | 189 |
| 190 OpenBrowserUsingContextMenuOnRootWindow(root_windows[0]); | 190 OpenBrowserUsingContextMenuOnRootWindow(root_windows[0]); |
| 191 | 191 |
| 192 // Next new browser must be created on 1st display. | 192 // Next new browser must be created on 1st display. |
| 193 EXPECT_EQ(2u, browser_list->size()); | 193 EXPECT_EQ(2u, browser_list->size()); |
| 194 EXPECT_EQ(root_windows[0], | 194 EXPECT_EQ(root_windows[0], |
| 195 browser_list->get(1)->window()->GetNativeWindow()->GetRootWindow()); | 195 browser_list->get(1)->window()->GetNativeWindow()->GetRootWindow()); |
| 196 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); | 196 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); |
| 197 | 197 |
| 198 // Balanced with the chrome::StartKeepAlive above. | 198 // Balanced with the chrome::StartKeepAlive above. |
| 199 chrome::EndKeepAlive(); | 199 chrome::EndKeepAlive(); |
| 200 } | 200 } |
| OLD | NEW |