| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/wm/public/window_manager.h" | 5 #include "athena/wm/public/window_manager.h" |
| 6 | 6 |
| 7 #include "athena/screen/public/screen_manager.h" | 7 #include "athena/screen/public/screen_manager.h" |
| 8 #include "athena/test/athena_test_base.h" | 8 #include "athena/test/athena_test_base.h" |
| 9 #include "athena/wm/public/window_list_provider.h" | 9 #include "athena/wm/public/window_list_provider.h" |
| 10 #include "athena/wm/split_view_controller.h" | 10 #include "athena/wm/split_view_controller.h" |
| 11 #include "athena/wm/window_manager_impl.h" | 11 #include "athena/wm/window_manager_impl.h" |
| 12 #include "athena/wm/window_manager_impl_test_api.h" |
| 12 #include "ui/aura/client/window_tree_client.h" | 13 #include "ui/aura/client/window_tree_client.h" |
| 13 #include "ui/aura/test/test_window_delegate.h" | 14 #include "ui/aura/test/test_window_delegate.h" |
| 14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 15 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.h" |
| 16 #include "ui/events/test/event_generator.h" | 17 #include "ui/events/test/event_generator.h" |
| 17 #include "ui/gfx/display.h" | 18 #include "ui/gfx/display.h" |
| 18 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
| 19 #include "ui/wm/core/window_util.h" | 20 #include "ui/wm/core/window_util.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 scoped_ptr<aura::Window> CreateWindow(aura::WindowDelegate* delegate) { | 24 scoped_ptr<aura::Window> CreateWindow(aura::WindowDelegate* delegate) { |
| 24 scoped_ptr<aura::Window> window(new aura::Window(delegate)); | 25 scoped_ptr<aura::Window> window(new aura::Window(delegate)); |
| 25 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 26 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 26 window->Init(aura::WINDOW_LAYER_SOLID_COLOR); | 27 window->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| 27 window->Show(); | 28 window->Show(); |
| 28 return window.Pass(); | 29 return window.Pass(); |
| 29 } | 30 } |
| 30 | 31 |
| 31 } // namespace | 32 } // namespace |
| 32 | 33 |
| 33 namespace athena { | 34 namespace athena { |
| 34 | 35 |
| 35 class WindowManagerImplTestApi { | |
| 36 public: | |
| 37 WindowManagerImplTestApi() | |
| 38 : wm_(static_cast<WindowManagerImpl*>(WindowManager::GetInstance())) {} | |
| 39 ~WindowManagerImplTestApi() {} | |
| 40 | |
| 41 WindowManager* wm() { return wm_; } | |
| 42 | |
| 43 WindowListProvider* window_list_provider() { | |
| 44 return wm_->window_list_provider_.get(); | |
| 45 } | |
| 46 | |
| 47 SplitViewController* split_view_controller() { | |
| 48 return wm_->split_view_controller_.get(); | |
| 49 } | |
| 50 | |
| 51 private: | |
| 52 WindowManagerImpl* wm_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(WindowManagerImplTestApi); | |
| 55 }; | |
| 56 | |
| 57 typedef test::AthenaTestBase WindowManagerTest; | 36 typedef test::AthenaTestBase WindowManagerTest; |
| 58 | 37 |
| 59 TEST_F(WindowManagerTest, Empty) { | 38 TEST_F(WindowManagerTest, Empty) { |
| 60 } | 39 } |
| 61 | 40 |
| 62 TEST_F(WindowManagerTest, OverviewModeBasics) { | 41 TEST_F(WindowManagerTest, OverviewModeBasics) { |
| 63 aura::test::TestWindowDelegate delegate; | 42 aura::test::TestWindowDelegate delegate; |
| 64 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); | 43 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); |
| 65 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); | 44 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); |
| 66 | 45 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Test that going into split-view mode with two-finger gesture selects the | 88 // Test that going into split-view mode with two-finger gesture selects the |
| 110 // correct windows on left and right splits. | 89 // correct windows on left and right splits. |
| 111 ui::test::EventGenerator generator(root_window()); | 90 ui::test::EventGenerator generator(root_window()); |
| 112 const gfx::Point start_points[2] = { | 91 const gfx::Point start_points[2] = { |
| 113 gfx::Point(2, 10), gfx::Point(4, 20), | 92 gfx::Point(2, 10), gfx::Point(4, 20), |
| 114 }; | 93 }; |
| 115 const int kEventTimeSepration = 16; | 94 const int kEventTimeSepration = 16; |
| 116 int x_middle = root_window()->bounds().width() / 2; | 95 int x_middle = root_window()->bounds().width() / 2; |
| 117 generator.GestureMultiFingerScroll( | 96 generator.GestureMultiFingerScroll( |
| 118 2, start_points, kEventTimeSepration, 1, x_middle, 0); | 97 2, start_points, kEventTimeSepration, 1, x_middle, 0); |
| 119 ASSERT_TRUE(wm_api.split_view_controller()->IsSplitViewModeActive()); | 98 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
| 120 EXPECT_EQ(second.get(), wm_api.split_view_controller()->left_window()); | 99 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); |
| 121 EXPECT_EQ(third.get(), wm_api.split_view_controller()->right_window()); | 100 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); |
| 122 EXPECT_EQ(second->bounds().size().ToString(), | 101 EXPECT_EQ(second->bounds().size().ToString(), |
| 123 third->bounds().size().ToString()); | 102 third->bounds().size().ToString()); |
| 124 } | 103 } |
| 125 | 104 |
| 126 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) { | 105 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) { |
| 127 aura::test::TestWindowDelegate delegate; | 106 aura::test::TestWindowDelegate delegate; |
| 128 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); | 107 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); |
| 129 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); | 108 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); |
| 130 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); | 109 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); |
| 131 | 110 |
| 132 WindowManagerImplTestApi wm_api; | 111 WindowManagerImplTestApi wm_api; |
| 133 aura::client::ParentWindowWithContext( | 112 aura::client::ParentWindowWithContext( |
| 134 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); | 113 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| 135 aura::client::ParentWindowWithContext( | 114 aura::client::ParentWindowWithContext( |
| 136 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); | 115 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| 137 aura::client::ParentWindowWithContext( | 116 aura::client::ParentWindowWithContext( |
| 138 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); | 117 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| 139 | 118 |
| 140 EXPECT_EQ(third.get(), wm_api.window_list_provider()->GetWindowList().back()); | 119 EXPECT_EQ(third.get(), |
| 120 wm_api.GetWindowListProvider()->GetWindowList().back()); |
| 141 | 121 |
| 142 // Do a two-finger swipe from the left bezel. | 122 // Do a two-finger swipe from the left bezel. |
| 143 ui::test::EventGenerator generator(root_window()); | 123 ui::test::EventGenerator generator(root_window()); |
| 144 const gfx::Point left_bezel_points[2] = { | 124 const gfx::Point left_bezel_points[2] = { |
| 145 gfx::Point(2, 10), gfx::Point(4, 20), | 125 gfx::Point(2, 10), gfx::Point(4, 20), |
| 146 }; | 126 }; |
| 147 const int kEventTimeSepration = 16; | 127 const int kEventTimeSepration = 16; |
| 148 int width = root_window()->bounds().width(); | 128 int width = root_window()->bounds().width(); |
| 149 generator.GestureMultiFingerScroll( | 129 generator.GestureMultiFingerScroll( |
| 150 2, left_bezel_points, kEventTimeSepration, 1, width, 0); | 130 2, left_bezel_points, kEventTimeSepration, 1, width, 0); |
| 151 EXPECT_TRUE(wm::IsActiveWindow(second.get())); | 131 EXPECT_TRUE(wm::IsActiveWindow(second.get())); |
| 152 EXPECT_EQ(second.get(), | 132 EXPECT_EQ(second.get(), |
| 153 wm_api.window_list_provider()->GetWindowList().back()); | 133 wm_api.GetWindowListProvider()->GetWindowList().back()); |
| 154 } | 134 } |
| 155 | 135 |
| 156 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) { | 136 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) { |
| 157 aura::test::TestWindowDelegate delegate; | 137 aura::test::TestWindowDelegate delegate; |
| 158 delegate.set_window_component(HTCAPTION); | 138 delegate.set_window_component(HTCAPTION); |
| 159 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); | 139 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); |
| 160 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); | 140 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); |
| 161 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); | 141 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); |
| 162 | 142 |
| 163 WindowManagerImplTestApi wm_api; | 143 WindowManagerImplTestApi wm_api; |
| 164 aura::client::ParentWindowWithContext( | 144 aura::client::ParentWindowWithContext( |
| 165 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); | 145 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| 166 aura::client::ParentWindowWithContext( | 146 aura::client::ParentWindowWithContext( |
| 167 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); | 147 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| 168 aura::client::ParentWindowWithContext( | 148 aura::client::ParentWindowWithContext( |
| 169 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); | 149 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| 170 | 150 |
| 171 EXPECT_EQ(third.get(), wm_api.window_list_provider()->GetWindowList().back()); | 151 EXPECT_EQ(third.get(), |
| 152 wm_api.GetWindowListProvider()->GetWindowList().back()); |
| 172 | 153 |
| 173 // Do a title-swipe from the top to switch to the previous window. | 154 // Do a title-swipe from the top to switch to the previous window. |
| 174 ui::test::EventGenerator generator(root_window()); | 155 ui::test::EventGenerator generator(root_window()); |
| 175 generator.GestureScrollSequence(gfx::Point(20, 10), | 156 generator.GestureScrollSequence(gfx::Point(20, 10), |
| 176 gfx::Point(20, 400), | 157 gfx::Point(20, 400), |
| 177 base::TimeDelta::FromMilliseconds(20), | 158 base::TimeDelta::FromMilliseconds(20), |
| 178 5); | 159 5); |
| 179 EXPECT_TRUE(wm::IsActiveWindow(second.get())); | 160 EXPECT_TRUE(wm::IsActiveWindow(second.get())); |
| 180 EXPECT_EQ(second.get(), | 161 EXPECT_EQ(second.get(), |
| 181 wm_api.window_list_provider()->GetWindowList().back()); | 162 wm_api.GetWindowListProvider()->GetWindowList().back()); |
| 182 EXPECT_TRUE(second->IsVisible()); | 163 EXPECT_TRUE(second->IsVisible()); |
| 183 EXPECT_FALSE(third->IsVisible()); | 164 EXPECT_FALSE(third->IsVisible()); |
| 184 | 165 |
| 185 // Performing the same gesture again will switch back to |third|. | 166 // Performing the same gesture again will switch back to |third|. |
| 186 generator.GestureScrollSequence(gfx::Point(20, 10), | 167 generator.GestureScrollSequence(gfx::Point(20, 10), |
| 187 gfx::Point(20, 400), | 168 gfx::Point(20, 400), |
| 188 base::TimeDelta::FromMilliseconds(20), | 169 base::TimeDelta::FromMilliseconds(20), |
| 189 5); | 170 5); |
| 190 EXPECT_TRUE(wm::IsActiveWindow(third.get())); | 171 EXPECT_TRUE(wm::IsActiveWindow(third.get())); |
| 191 EXPECT_EQ(third.get(), wm_api.window_list_provider()->GetWindowList().back()); | 172 EXPECT_EQ(third.get(), |
| 173 wm_api.GetWindowListProvider()->GetWindowList().back()); |
| 192 EXPECT_FALSE(second->IsVisible()); | 174 EXPECT_FALSE(second->IsVisible()); |
| 193 EXPECT_TRUE(third->IsVisible()); | 175 EXPECT_TRUE(third->IsVisible()); |
| 194 | 176 |
| 195 // Perform a swipe that doesn't go enough to perform the window switch. | 177 // Perform a swipe that doesn't go enough to perform the window switch. |
| 196 generator.GestureScrollSequence(gfx::Point(20, 10), | 178 generator.GestureScrollSequence(gfx::Point(20, 10), |
| 197 gfx::Point(20, 90), | 179 gfx::Point(20, 90), |
| 198 base::TimeDelta::FromMilliseconds(20), | 180 base::TimeDelta::FromMilliseconds(20), |
| 199 5); | 181 5); |
| 200 EXPECT_TRUE(wm::IsActiveWindow(third.get())); | 182 EXPECT_TRUE(wm::IsActiveWindow(third.get())); |
| 201 EXPECT_EQ(third.get(), wm_api.window_list_provider()->GetWindowList().back()); | 183 EXPECT_EQ(third.get(), |
| 184 wm_api.GetWindowListProvider()->GetWindowList().back()); |
| 202 EXPECT_FALSE(second->IsVisible()); | 185 EXPECT_FALSE(second->IsVisible()); |
| 203 EXPECT_TRUE(third->IsVisible()); | 186 EXPECT_TRUE(third->IsVisible()); |
| 204 } | 187 } |
| 205 | 188 |
| 206 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) { | 189 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) { |
| 207 aura::test::TestWindowDelegate delegate; | 190 aura::test::TestWindowDelegate delegate; |
| 208 delegate.set_window_component(HTCAPTION); | 191 delegate.set_window_component(HTCAPTION); |
| 209 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); | 192 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); |
| 210 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); | 193 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); |
| 211 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); | 194 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 224 // Test that going into split-view mode with two-finger gesture selects the | 207 // Test that going into split-view mode with two-finger gesture selects the |
| 225 // correct windows on left and right splits. | 208 // correct windows on left and right splits. |
| 226 ui::test::EventGenerator generator(root_window()); | 209 ui::test::EventGenerator generator(root_window()); |
| 227 const gfx::Point start_points[2] = { | 210 const gfx::Point start_points[2] = { |
| 228 gfx::Point(2, 10), gfx::Point(4, 20), | 211 gfx::Point(2, 10), gfx::Point(4, 20), |
| 229 }; | 212 }; |
| 230 const int kEventTimeSepration = 16; | 213 const int kEventTimeSepration = 16; |
| 231 int x_middle = root_window()->bounds().width() / 2; | 214 int x_middle = root_window()->bounds().width() / 2; |
| 232 generator.GestureMultiFingerScroll( | 215 generator.GestureMultiFingerScroll( |
| 233 2, start_points, kEventTimeSepration, 1, x_middle, 0); | 216 2, start_points, kEventTimeSepration, 1, x_middle, 0); |
| 234 ASSERT_TRUE(wm_api.split_view_controller()->IsSplitViewModeActive()); | 217 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
| 235 EXPECT_EQ(third.get(), wm_api.split_view_controller()->left_window()); | 218 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->left_window()); |
| 236 EXPECT_EQ(fourth.get(), wm_api.split_view_controller()->right_window()); | 219 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window()); |
| 237 | 220 |
| 238 // Swipe the title of the left window. It should switch to |second|. | 221 // Swipe the title of the left window. It should switch to |second|. |
| 239 generator.GestureScrollSequence(gfx::Point(20, 10), | 222 generator.GestureScrollSequence(gfx::Point(20, 10), |
| 240 gfx::Point(20, 400), | 223 gfx::Point(20, 400), |
| 241 base::TimeDelta::FromMilliseconds(20), | 224 base::TimeDelta::FromMilliseconds(20), |
| 242 5); | 225 5); |
| 243 EXPECT_EQ(second.get(), wm_api.split_view_controller()->left_window()); | 226 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); |
| 244 EXPECT_EQ(fourth.get(), wm_api.split_view_controller()->right_window()); | 227 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window()); |
| 245 aura::Window::Windows windows = | 228 aura::Window::Windows windows = |
| 246 wm_api.window_list_provider()->GetWindowList(); | 229 wm_api.GetWindowListProvider()->GetWindowList(); |
| 247 ASSERT_EQ(4u, windows.size()); | 230 ASSERT_EQ(4u, windows.size()); |
| 248 EXPECT_EQ(second.get(), windows[3]); | 231 EXPECT_EQ(second.get(), windows[3]); |
| 249 EXPECT_EQ(third.get(), windows[2]); | 232 EXPECT_EQ(third.get(), windows[2]); |
| 250 EXPECT_EQ(fourth.get(), windows[1]); | 233 EXPECT_EQ(fourth.get(), windows[1]); |
| 251 | 234 |
| 252 // Swipe the title of the right window now. It should switch to |third|. | 235 // Swipe the title of the right window now. It should switch to |third|. |
| 253 generator.GestureScrollSequence(gfx::Point(x_middle + 20, 10), | 236 generator.GestureScrollSequence(gfx::Point(x_middle + 20, 10), |
| 254 gfx::Point(x_middle + 20, 400), | 237 gfx::Point(x_middle + 20, 400), |
| 255 base::TimeDelta::FromMilliseconds(20), | 238 base::TimeDelta::FromMilliseconds(20), |
| 256 5); | 239 5); |
| 257 EXPECT_EQ(second.get(), wm_api.split_view_controller()->left_window()); | 240 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); |
| 258 EXPECT_EQ(third.get(), wm_api.split_view_controller()->right_window()); | 241 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); |
| 259 } | 242 } |
| 260 | 243 |
| 261 TEST_F(WindowManagerTest, NewWindowBounds) { | 244 TEST_F(WindowManagerTest, NewWindowBounds) { |
| 262 aura::test::TestWindowDelegate delegate; | 245 aura::test::TestWindowDelegate delegate; |
| 263 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); | 246 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); |
| 264 | 247 |
| 265 WindowManagerImplTestApi wm_api; | 248 WindowManagerImplTestApi wm_api; |
| 266 aura::client::ParentWindowWithContext( | 249 aura::client::ParentWindowWithContext( |
| 267 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); | 250 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| 268 // The window should have the same size as the container. | 251 // The window should have the same size as the container. |
| 269 const gfx::Size work_area = | 252 const gfx::Size work_area = |
| 270 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); | 253 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); |
| 271 EXPECT_EQ(work_area.ToString(), | 254 EXPECT_EQ(work_area.ToString(), |
| 272 first->bounds().size().ToString()); | 255 first->bounds().size().ToString()); |
| 273 EXPECT_TRUE(first->bounds().origin().IsOrigin()); | 256 EXPECT_TRUE(first->bounds().origin().IsOrigin()); |
| 274 | 257 |
| 275 // A second window should have the same bounds as the first one. | 258 // A second window should have the same bounds as the first one. |
| 276 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); | 259 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); |
| 277 aura::client::ParentWindowWithContext( | 260 aura::client::ParentWindowWithContext( |
| 278 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); | 261 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| 279 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); | 262 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); |
| 280 | 263 |
| 281 // Get into split view. | 264 // Get into split view. |
| 282 wm_api.split_view_controller()->ActivateSplitMode(NULL, NULL); | 265 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL); |
| 283 const gfx::Rect left_bounds = | 266 const gfx::Rect left_bounds = |
| 284 wm_api.split_view_controller()->left_window()->bounds(); | 267 wm_api.GetSplitViewController()->left_window()->bounds(); |
| 285 EXPECT_NE(work_area.ToString(), | 268 EXPECT_NE(work_area.ToString(), |
| 286 left_bounds.size().ToString()); | 269 left_bounds.size().ToString()); |
| 287 | 270 |
| 288 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); | 271 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); |
| 289 aura::client::ParentWindowWithContext( | 272 aura::client::ParentWindowWithContext( |
| 290 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); | 273 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| 291 EXPECT_NE(wm_api.split_view_controller()->left_window(), third.get()); | 274 EXPECT_NE(wm_api.GetSplitViewController()->left_window(), third.get()); |
| 292 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString()); | 275 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString()); |
| 293 | 276 |
| 294 third->Hide(); | 277 third->Hide(); |
| 295 EXPECT_EQ(left_bounds.ToString(), | 278 EXPECT_EQ( |
| 296 wm_api.split_view_controller()->left_window()->bounds().ToString()); | 279 left_bounds.ToString(), |
| 280 wm_api.GetSplitViewController()->left_window()->bounds().ToString()); |
| 297 } | 281 } |
| 298 | 282 |
| 299 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) { | 283 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) { |
| 300 WindowManagerImplTestApi wm_api; | 284 WindowManagerImplTestApi wm_api; |
| 301 | 285 |
| 302 aura::test::TestWindowDelegate delegate; | 286 aura::test::TestWindowDelegate delegate; |
| 303 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); | 287 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); |
| 304 w1->Show(); | 288 w1->Show(); |
| 305 | 289 |
| 306 ui::test::EventGenerator generator(root_window()); | 290 ui::test::EventGenerator generator(root_window()); |
| 307 | 291 |
| 308 // Splitview mode needs at least two windows. | 292 // Splitview mode needs at least two windows. |
| 309 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); | 293 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); |
| 310 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); | 294 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); |
| 311 EXPECT_FALSE(wm_api.split_view_controller()->IsSplitViewModeActive()); | 295 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
| 312 | 296 |
| 313 scoped_ptr<aura::Window> w2(CreateTestWindow(&delegate, gfx::Rect())); | 297 scoped_ptr<aura::Window> w2(CreateTestWindow(&delegate, gfx::Rect())); |
| 314 w2->Show(); | 298 w2->Show(); |
| 315 | 299 |
| 316 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); | 300 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); |
| 317 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); | 301 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); |
| 318 EXPECT_TRUE(wm_api.split_view_controller()->IsSplitViewModeActive()); | 302 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
| 319 int width = | 303 int width = |
| 320 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width(); | 304 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width(); |
| 321 | 305 |
| 322 EXPECT_EQ(width / 2, w1->bounds().width()); | 306 EXPECT_EQ(width / 2, w1->bounds().width()); |
| 323 EXPECT_EQ(width / 2, w2->bounds().width()); | 307 EXPECT_EQ(width / 2, w2->bounds().width()); |
| 324 | 308 |
| 325 // Toggle back to normal mode. | 309 // Toggle back to normal mode. |
| 326 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); | 310 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); |
| 327 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); | 311 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); |
| 328 EXPECT_FALSE(wm_api.split_view_controller()->IsSplitViewModeActive()); | 312 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
| 329 | 313 |
| 330 EXPECT_EQ(width, w1->bounds().width()); | 314 EXPECT_EQ(width, w1->bounds().width()); |
| 331 EXPECT_EQ(width, w2->bounds().width()); | 315 EXPECT_EQ(width, w2->bounds().width()); |
| 332 } | 316 } |
| 333 | 317 |
| 334 } // namespace athena | 318 } // namespace athena |
| OLD | NEW |