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 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace athena { | 23 namespace athena { |
24 | 24 |
25 class WindowManagerTest : public test::AthenaTestBase { | 25 class WindowManagerTest : public test::AthenaTestBase { |
26 public: | 26 public: |
27 WindowManagerTest() {} | 27 WindowManagerTest() {} |
28 virtual ~WindowManagerTest() {} | 28 virtual ~WindowManagerTest() {} |
29 | 29 |
30 scoped_ptr<aura::Window> CreateAndActivateWindow( | 30 scoped_ptr<aura::Window> CreateAndActivateWindow( |
31 aura::WindowDelegate* delegate) { | 31 aura::WindowDelegate* delegate) { |
32 scoped_ptr<aura::Window> window(test::CreateNormalWindow(delegate, NULL)); | 32 scoped_ptr<aura::Window> window( |
| 33 test::CreateNormalWindow(delegate, nullptr)); |
33 window->Show(); | 34 window->Show(); |
34 wm::ActivateWindow(window.get()); | 35 wm::ActivateWindow(window.get()); |
35 return window.Pass(); | 36 return window.Pass(); |
36 } | 37 } |
37 | 38 |
38 private: | 39 private: |
39 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); | 40 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); |
40 }; | 41 }; |
41 | 42 |
42 TEST_F(WindowManagerTest, OverviewModeBasics) { | 43 TEST_F(WindowManagerTest, OverviewModeBasics) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate)); | 88 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate)); |
88 wm::ActivateWindow(w3.get()); | 89 wm::ActivateWindow(w3.get()); |
89 | 90 |
90 WindowManager::Get()->EnterOverview(); | 91 WindowManager::Get()->EnterOverview(); |
91 EXPECT_TRUE(w1->IsVisible()); | 92 EXPECT_TRUE(w1->IsVisible()); |
92 EXPECT_TRUE(w2->IsVisible()); | 93 EXPECT_TRUE(w2->IsVisible()); |
93 EXPECT_TRUE(w3->IsVisible()); | 94 EXPECT_TRUE(w3->IsVisible()); |
94 | 95 |
95 // Go into split-view mode. | 96 // Go into split-view mode. |
96 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); | 97 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); |
97 overview_delegate->OnSelectSplitViewWindow(w3.get(), NULL, w3.get()); | 98 overview_delegate->OnSelectSplitViewWindow(w3.get(), nullptr, w3.get()); |
98 EXPECT_TRUE(w3->IsVisible()); | 99 EXPECT_TRUE(w3->IsVisible()); |
99 EXPECT_TRUE(w2->IsVisible()); | 100 EXPECT_TRUE(w2->IsVisible()); |
100 EXPECT_FALSE(w1->IsVisible()); | 101 EXPECT_FALSE(w1->IsVisible()); |
101 } | 102 } |
102 | 103 |
103 TEST_F(WindowManagerTest, NewWindowFromOverview) { | 104 TEST_F(WindowManagerTest, NewWindowFromOverview) { |
104 aura::test::TestWindowDelegate delegate; | 105 aura::test::TestWindowDelegate delegate; |
105 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); | 106 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
106 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); | 107 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); |
107 | 108 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); | 291 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); |
291 EXPECT_EQ(work_area.ToString(), | 292 EXPECT_EQ(work_area.ToString(), |
292 first->bounds().size().ToString()); | 293 first->bounds().size().ToString()); |
293 EXPECT_TRUE(first->bounds().origin().IsOrigin()); | 294 EXPECT_TRUE(first->bounds().origin().IsOrigin()); |
294 | 295 |
295 // A second window should have the same bounds as the first one. | 296 // A second window should have the same bounds as the first one. |
296 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); | 297 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); |
297 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); | 298 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); |
298 | 299 |
299 // Get into split view. | 300 // Get into split view. |
300 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL, NULL); | 301 wm_api.GetSplitViewController()->ActivateSplitMode(nullptr, nullptr, nullptr); |
301 const gfx::Rect left_bounds = | 302 const gfx::Rect left_bounds = |
302 wm_api.GetSplitViewController()->left_window()->bounds(); | 303 wm_api.GetSplitViewController()->left_window()->bounds(); |
303 EXPECT_NE(work_area.ToString(), | 304 EXPECT_NE(work_area.ToString(), |
304 left_bounds.size().ToString()); | 305 left_bounds.size().ToString()); |
305 | 306 |
306 // A new window should replace the left window when in split view. | 307 // A new window should replace the left window when in split view. |
307 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); | 308 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); |
308 EXPECT_EQ(wm_api.GetSplitViewController()->left_window(), third.get()); | 309 EXPECT_EQ(wm_api.GetSplitViewController()->left_window(), third.get()); |
309 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString()); | 310 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString()); |
310 } | 311 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 | 358 |
358 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) { | 359 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) { |
359 test::WindowManagerImplTestApi wm_api; | 360 test::WindowManagerImplTestApi wm_api; |
360 | 361 |
361 aura::test::TestWindowDelegate delegate; | 362 aura::test::TestWindowDelegate delegate; |
362 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); | 363 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
363 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); | 364 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); |
364 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate)); | 365 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate)); |
365 | 366 |
366 // Get into split-view mode, and then turn on overview mode. | 367 // Get into split-view mode, and then turn on overview mode. |
367 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL, NULL); | 368 wm_api.GetSplitViewController()->ActivateSplitMode(nullptr, nullptr, nullptr); |
368 WindowManager::Get()->EnterOverview(); | 369 WindowManager::Get()->EnterOverview(); |
369 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | 370 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
370 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window()); | 371 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window()); |
371 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window()); | 372 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window()); |
372 | 373 |
373 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); | 374 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); |
374 overview_delegate->OnSelectWindow(w1.get()); | 375 overview_delegate->OnSelectWindow(w1.get()); |
375 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | 376 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
376 EXPECT_TRUE(w1->IsVisible()); | 377 EXPECT_TRUE(w1->IsVisible()); |
377 // Make sure the windows that were in split-view mode are hidden. | 378 // Make sure the windows that were in split-view mode are hidden. |
378 EXPECT_FALSE(w2->IsVisible()); | 379 EXPECT_FALSE(w2->IsVisible()); |
379 EXPECT_FALSE(w3->IsVisible()); | 380 EXPECT_FALSE(w3->IsVisible()); |
380 } | 381 } |
381 | 382 |
382 // Clicking a background in overview should not crash. | 383 // Clicking a background in overview should not crash. |
383 TEST_F(WindowManagerTest, ClickBackgroundInOverview) { | 384 TEST_F(WindowManagerTest, ClickBackgroundInOverview) { |
384 test::WindowManagerImplTestApi wm_api; | 385 test::WindowManagerImplTestApi wm_api; |
385 | 386 |
386 aura::test::TestWindowDelegate delegate; | 387 aura::test::TestWindowDelegate delegate; |
387 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); | 388 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
388 WindowManager::Get()->EnterOverview(); | 389 WindowManager::Get()->EnterOverview(); |
389 | 390 |
390 ui::test::EventGenerator generator(root_window()); | 391 ui::test::EventGenerator generator(root_window()); |
391 generator.MoveMouseTo(1, 1); | 392 generator.MoveMouseTo(1, 1); |
392 generator.ClickLeftButton(); | 393 generator.ClickLeftButton(); |
393 } | 394 } |
394 | 395 |
395 } // namespace athena | 396 } // namespace athena |
OLD | NEW |