| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "ash/test/ash_test_base.h" | 6 #include "ash/test/ash_test_base.h" |
| 7 #include "ash/test/test_shell_delegate.h" | 7 #include "ash/test/test_shell_delegate.h" |
| 8 #include "ash/wm/window_util.h" | 8 #include "ash/wm/window_state.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" | 10 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" |
| 11 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
| 12 #include "ui/aura/test/test_windows.h" | 12 #include "ui/aura/test/test_windows.h" |
| 13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 class WallpaperPrivateApiUnittest : public ash::test::AshTestBase { | 17 class WallpaperPrivateApiUnittest : public ash::test::AshTestBase { |
| 18 }; | 18 }; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 TEST_F(WallpaperPrivateApiUnittest, HideAndRestoreWindows) { | 47 TEST_F(WallpaperPrivateApiUnittest, HideAndRestoreWindows) { |
| 48 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); | 48 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); |
| 49 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 49 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
| 50 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 50 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 51 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 51 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 52 | 52 |
| 53 ash::wm::MinimizeWindow(window3.get()); | 53 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); |
| 54 ash::wm::MaximizeWindow(window1.get()); | 54 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); |
| 55 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); |
| 56 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); |
| 57 |
| 58 window3_state->Minimize(); |
| 59 window1_state->Maximize(); |
| 55 | 60 |
| 56 // Window 3 starts minimized, window 1 starts maximized. | 61 // Window 3 starts minimized, window 1 starts maximized. |
| 57 EXPECT_FALSE(ash::wm::IsWindowMinimized(window0.get())); | 62 EXPECT_FALSE(window0_state->IsMinimized()); |
| 58 EXPECT_FALSE(ash::wm::IsWindowMinimized(window1.get())); | 63 EXPECT_FALSE(window1_state->IsMinimized()); |
| 59 EXPECT_FALSE(ash::wm::IsWindowMinimized(window2.get())); | 64 EXPECT_FALSE(window2_state->IsMinimized()); |
| 60 EXPECT_TRUE(ash::wm::IsWindowMinimized(window3.get())); | 65 EXPECT_TRUE(window3_state->IsMinimized()); |
| 61 | 66 |
| 62 // We then activate window 0 (i.e. wallpaper picker) and call the minimize | 67 // We then activate window 0 (i.e. wallpaper picker) and call the minimize |
| 63 // function. | 68 // function. |
| 64 ash::wm::ActivateWindow(window0.get()); | 69 window0_state->Activate(); |
| 65 EXPECT_TRUE(ash::wm::IsActiveWindow(window0.get())); | 70 EXPECT_TRUE(window0_state->IsActive()); |
| 66 scoped_refptr<TestMinimizeFunction> minimize_function( | 71 scoped_refptr<TestMinimizeFunction> minimize_function( |
| 67 new TestMinimizeFunction()); | 72 new TestMinimizeFunction()); |
| 68 EXPECT_TRUE(minimize_function->RunImpl()); | 73 EXPECT_TRUE(minimize_function->RunImpl()); |
| 69 | 74 |
| 70 // All windows except window 0 should be minimized. | 75 // All windows except window 0 should be minimized. |
| 71 EXPECT_FALSE(ash::wm::IsWindowMinimized(window0.get())); | 76 EXPECT_FALSE(window0_state->IsMinimized()); |
| 72 EXPECT_TRUE(ash::wm::IsWindowMinimized(window1.get())); | 77 EXPECT_TRUE(window1_state->IsMinimized()); |
| 73 EXPECT_TRUE(ash::wm::IsWindowMinimized(window2.get())); | 78 EXPECT_TRUE(window2_state->IsMinimized()); |
| 74 EXPECT_TRUE(ash::wm::IsWindowMinimized(window3.get())); | 79 EXPECT_TRUE(window3_state->IsMinimized()); |
| 75 | 80 |
| 76 // Then we destroy window 0 and call the restore function. | 81 // Then we destroy window 0 and call the restore function. |
| 77 window0.reset(); | 82 window0.reset(); |
| 78 scoped_refptr<TestRestoreFunction> restore_function( | 83 scoped_refptr<TestRestoreFunction> restore_function( |
| 79 new TestRestoreFunction()); | 84 new TestRestoreFunction()); |
| 80 EXPECT_TRUE(restore_function->RunImpl()); | 85 EXPECT_TRUE(restore_function->RunImpl()); |
| 81 | 86 |
| 82 // Windows 1 and 2 should no longer be minimized. Window 1 should again | 87 // Windows 1 and 2 should no longer be minimized. Window 1 should again |
| 83 // be maximized. Window 3 should still be minimized. | 88 // be maximized. Window 3 should still be minimized. |
| 84 EXPECT_FALSE(ash::wm::IsWindowMinimized(window1.get())); | 89 EXPECT_FALSE(window1_state->IsMinimized()); |
| 85 EXPECT_TRUE(ash::wm::IsWindowMaximized(window1.get())); | 90 EXPECT_TRUE(window1_state->IsMaximized()); |
| 86 EXPECT_FALSE(ash::wm::IsWindowMinimized(window2.get())); | 91 EXPECT_FALSE(window2_state->IsMinimized()); |
| 87 EXPECT_TRUE(ash::wm::IsWindowMinimized(window3.get())); | 92 EXPECT_TRUE(window3_state->IsMinimized()); |
| 88 } | 93 } |
| OLD | NEW |