| 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/base/athena_test_base.h" | 8 #include "athena/test/base/athena_test_base.h" |
| 9 #include "athena/test/base/test_windows.h" | 9 #include "athena/test/base/test_windows.h" |
| 10 #include "athena/wm/public/window_list_provider.h" | 10 #include "athena/wm/public/window_list_provider.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // have been opened by JavaScript or by the home card. | 169 // have been opened by JavaScript or by the home card. |
| 170 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate)); | 170 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate)); |
| 171 | 171 |
| 172 ASSERT_FALSE(WindowManager::Get()->IsOverviewModeActive()); | 172 ASSERT_FALSE(WindowManager::Get()->IsOverviewModeActive()); |
| 173 EXPECT_TRUE(w3->IsVisible()); | 173 EXPECT_TRUE(w3->IsVisible()); |
| 174 EXPECT_TRUE(wm::IsActiveWindow(w3.get())); | 174 EXPECT_TRUE(wm::IsActiveWindow(w3.get())); |
| 175 EXPECT_FALSE(w1->IsVisible()); | 175 EXPECT_FALSE(w1->IsVisible()); |
| 176 EXPECT_FALSE(w2->IsVisible()); | 176 EXPECT_FALSE(w2->IsVisible()); |
| 177 } | 177 } |
| 178 | 178 |
| 179 TEST_F(WindowManagerTest, BezelGestureToSplitViewMode) { | |
| 180 aura::test::TestWindowDelegate delegate; | |
| 181 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); | |
| 182 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); | |
| 183 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); | |
| 184 | |
| 185 test::WindowManagerImplTestApi wm_api; | |
| 186 | |
| 187 // Test that going into split-view mode with two-finger gesture selects the | |
| 188 // correct windows on left and right splits. | |
| 189 ui::test::EventGenerator generator(root_window()); | |
| 190 const gfx::Point start_points[2] = { | |
| 191 gfx::Point(2, 10), gfx::Point(4, 20), | |
| 192 }; | |
| 193 const int kEventTimeSepration = 16; | |
| 194 int x_middle = root_window()->bounds().width() / 2; | |
| 195 generator.GestureMultiFingerScroll( | |
| 196 2, start_points, kEventTimeSepration, 1, x_middle, 0); | |
| 197 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | |
| 198 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); | |
| 199 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); | |
| 200 EXPECT_EQ(second->bounds().size().ToString(), | |
| 201 third->bounds().size().ToString()); | |
| 202 } | |
| 203 | |
| 204 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) { | |
| 205 aura::test::TestWindowDelegate delegate; | |
| 206 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); | |
| 207 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); | |
| 208 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); | |
| 209 first->Hide(); | |
| 210 second->Hide(); | |
| 211 | |
| 212 test::WindowManagerImplTestApi wm_api; | |
| 213 | |
| 214 EXPECT_EQ(third.get(), | |
| 215 wm_api.GetWindowListProvider()->GetWindowList().back()); | |
| 216 | |
| 217 // Do a two-finger swipe from the left bezel. | |
| 218 ui::test::EventGenerator generator(root_window()); | |
| 219 const gfx::Point left_bezel_points[2] = { | |
| 220 gfx::Point(2, 10), gfx::Point(4, 20), | |
| 221 }; | |
| 222 const int kEventTimeSeparation = 16; | |
| 223 int width = root_window()->bounds().width(); | |
| 224 generator.GestureMultiFingerScroll( | |
| 225 2, left_bezel_points, kEventTimeSeparation, 1, width, 0); | |
| 226 EXPECT_TRUE(wm::IsActiveWindow(second.get())); | |
| 227 EXPECT_EQ(second.get(), | |
| 228 wm_api.GetWindowListProvider()->GetWindowList().back()); | |
| 229 | |
| 230 // Do a two-finger swipe from the right bezel. | |
| 231 const gfx::Point right_bezel_points[2] = { | |
| 232 gfx::Point(width - 5, 10), | |
| 233 gfx::Point(width - 10, 20) | |
| 234 }; | |
| 235 generator.GestureMultiFingerScroll( | |
| 236 2, right_bezel_points, kEventTimeSeparation, 1, -width, 0); | |
| 237 EXPECT_TRUE(wm::IsActiveWindow(third.get())); | |
| 238 EXPECT_EQ(third.get(), | |
| 239 wm_api.GetWindowListProvider()->GetWindowList().back()); | |
| 240 } | |
| 241 | |
| 242 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) { | 179 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) { |
| 243 aura::test::TestWindowDelegate delegate; | 180 aura::test::TestWindowDelegate delegate; |
| 244 delegate.set_window_component(HTCAPTION); | 181 delegate.set_window_component(HTCAPTION); |
| 245 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); | 182 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); |
| 246 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); | 183 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); |
| 247 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); | 184 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); |
| 248 | 185 |
| 249 test::WindowManagerImplTestApi wm_api; | 186 test::WindowManagerImplTestApi wm_api; |
| 250 | 187 |
| 251 EXPECT_EQ(third.get(), | 188 EXPECT_EQ(third.get(), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 279 gfx::Point(20, 90), | 216 gfx::Point(20, 90), |
| 280 base::TimeDelta::FromMilliseconds(20), | 217 base::TimeDelta::FromMilliseconds(20), |
| 281 5); | 218 5); |
| 282 EXPECT_TRUE(wm::IsActiveWindow(third.get())); | 219 EXPECT_TRUE(wm::IsActiveWindow(third.get())); |
| 283 EXPECT_EQ(third.get(), | 220 EXPECT_EQ(third.get(), |
| 284 wm_api.GetWindowListProvider()->GetWindowList().back()); | 221 wm_api.GetWindowListProvider()->GetWindowList().back()); |
| 285 EXPECT_FALSE(second->IsVisible()); | 222 EXPECT_FALSE(second->IsVisible()); |
| 286 EXPECT_TRUE(third->IsVisible()); | 223 EXPECT_TRUE(third->IsVisible()); |
| 287 } | 224 } |
| 288 | 225 |
| 289 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) { | 226 // Verifies that the correct windows are replaced and the ordering of |
| 227 // the window list changes correctly when the window titlebars are dragged |
| 228 // in split view mode. |
| 229 TEST_F(WindowManagerTest, ReplaceWindowsInSplitViewMode) { |
| 290 aura::test::TestWindowDelegate delegate; | 230 aura::test::TestWindowDelegate delegate; |
| 291 delegate.set_window_component(HTCAPTION); | 231 delegate.set_window_component(HTCAPTION); |
| 292 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); | 232 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); |
| 293 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); | 233 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); |
| 294 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); | 234 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); |
| 295 scoped_ptr<aura::Window> fourth(CreateAndActivateWindow(&delegate)); | 235 scoped_ptr<aura::Window> fourth(CreateAndActivateWindow(&delegate)); |
| 296 | 236 |
| 297 test::WindowManagerImplTestApi wm_api; | 237 test::WindowManagerImplTestApi wm_api; |
| 238 wm_api.wm()->ToggleSplitView(); |
| 239 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
| 298 | 240 |
| 299 // Test that going into split-view mode with two-finger gesture selects the | 241 // Verify that the left and right windows have been set to the |
| 300 // correct windows on left and right splits. | 242 // two windows at the top of the window list. |
| 243 aura::Window::Windows windows = |
| 244 wm_api.GetWindowListProvider()->GetWindowList(); |
| 245 ASSERT_EQ(4u, windows.size()); |
| 246 EXPECT_EQ(first.get(), windows[0]); |
| 247 EXPECT_EQ(second.get(), windows[1]); |
| 248 EXPECT_EQ(third.get(), windows[2]); |
| 249 EXPECT_EQ(fourth.get(), windows[3]); |
| 250 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->left_window()); |
| 251 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); |
| 252 |
| 253 // Swiping the title of the left window should change it from |fourth| |
| 254 // to |second|. The right window should not change. |
| 301 ui::test::EventGenerator generator(root_window()); | 255 ui::test::EventGenerator generator(root_window()); |
| 302 const gfx::Point start_points[2] = { | |
| 303 gfx::Point(2, 10), gfx::Point(4, 20), | |
| 304 }; | |
| 305 const int kEventTimeSepration = 16; | |
| 306 int x_middle = root_window()->bounds().width() / 2; | |
| 307 generator.GestureMultiFingerScroll( | |
| 308 2, start_points, kEventTimeSepration, 1, x_middle, 0); | |
| 309 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | |
| 310 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->left_window()); | |
| 311 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window()); | |
| 312 | |
| 313 // Swipe the title of the left window. It should switch to |second|. | |
| 314 generator.GestureScrollSequence(gfx::Point(20, 10), | 256 generator.GestureScrollSequence(gfx::Point(20, 10), |
| 315 gfx::Point(20, 400), | 257 gfx::Point(20, 400), |
| 316 base::TimeDelta::FromMilliseconds(20), | 258 base::TimeDelta::FromMilliseconds(20), |
| 317 5); | 259 5); |
| 318 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); | 260 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); |
| 319 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window()); | 261 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); |
| 320 aura::Window::Windows windows = | 262 |
| 321 wm_api.GetWindowListProvider()->GetWindowList(); | 263 // |second| should be placed at the front of the list. The replaced |
| 264 // window (|fourth|) should be stacked behind the non-replaced window |
| 265 // (|third|). |
| 266 windows = wm_api.GetWindowListProvider()->GetWindowList(); |
| 322 ASSERT_EQ(4u, windows.size()); | 267 ASSERT_EQ(4u, windows.size()); |
| 268 EXPECT_EQ(first.get(), windows[0]); |
| 269 EXPECT_EQ(fourth.get(), windows[1]); |
| 270 EXPECT_EQ(third.get(), windows[2]); |
| 323 EXPECT_EQ(second.get(), windows[3]); | 271 EXPECT_EQ(second.get(), windows[3]); |
| 324 EXPECT_EQ(fourth.get(), windows[2]); | |
| 325 | 272 |
| 326 // Swipe the title of the right window now. It should switch to |third|. | 273 // Swiping the title of the right window should change it from |third| |
| 274 // to |fourth|. The left window should not change. |
| 275 int x_middle = root_window()->bounds().width() / 2; |
| 327 generator.GestureScrollSequence(gfx::Point(x_middle + 20, 10), | 276 generator.GestureScrollSequence(gfx::Point(x_middle + 20, 10), |
| 328 gfx::Point(x_middle + 20, 400), | 277 gfx::Point(x_middle + 20, 400), |
| 329 base::TimeDelta::FromMilliseconds(20), | 278 base::TimeDelta::FromMilliseconds(20), |
| 330 5); | 279 5); |
| 331 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); | 280 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); |
| 332 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); | 281 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window()); |
| 282 |
| 283 // |fourth| should be placed at the front of the list. The replaced |
| 284 // window (|third|) should be stacked behind the non-replaced window |
| 285 // (|second|). |
| 333 windows = wm_api.GetWindowListProvider()->GetWindowList(); | 286 windows = wm_api.GetWindowListProvider()->GetWindowList(); |
| 334 ASSERT_EQ(4u, windows.size()); | 287 ASSERT_EQ(4u, windows.size()); |
| 335 EXPECT_EQ(third.get(), windows[3]); | 288 EXPECT_EQ(first.get(), windows[0]); |
| 289 EXPECT_EQ(third.get(), windows[1]); |
| 336 EXPECT_EQ(second.get(), windows[2]); | 290 EXPECT_EQ(second.get(), windows[2]); |
| 291 EXPECT_EQ(fourth.get(), windows[3]); |
| 337 } | 292 } |
| 338 | 293 |
| 339 TEST_F(WindowManagerTest, NewWindowBounds) { | 294 TEST_F(WindowManagerTest, NewWindowBounds) { |
| 340 aura::test::TestWindowDelegate delegate; | 295 aura::test::TestWindowDelegate delegate; |
| 341 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); | 296 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); |
| 342 | 297 |
| 343 test::WindowManagerImplTestApi wm_api; | 298 test::WindowManagerImplTestApi wm_api; |
| 344 // The window should have the same size as the container. | 299 // The window should have the same size as the container. |
| 345 const gfx::Size work_area = | 300 const gfx::Size work_area = |
| 346 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); | 301 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 | 589 |
| 635 // Closes a non-visible window (w1). | 590 // Closes a non-visible window (w1). |
| 636 w3.reset(); | 591 w3.reset(); |
| 637 | 592 |
| 638 ASSERT_TRUE(WindowManager::Get()->IsOverviewModeActive()); | 593 ASSERT_TRUE(WindowManager::Get()->IsOverviewModeActive()); |
| 639 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | 594 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
| 640 EXPECT_TRUE(w2->IsVisible()); | 595 EXPECT_TRUE(w2->IsVisible()); |
| 641 } | 596 } |
| 642 | 597 |
| 643 } // namespace athena | 598 } // namespace athena |
| OLD | NEW |