Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: chrome/browser/chromeos/extensions/wallpaper_private_api_unittest.cc

Issue 1023863003: Don't track windows that were interacted (restored/minimized) by user while wallpaper picker applic… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unit test. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/extensions/wallpaper_private_api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_session_state_delegate.h" 7 #include "ash/test/test_session_state_delegate.h"
8 #include "ash/test/test_shell_delegate.h" 8 #include "ash/test/test_shell_delegate.h"
9 #include "ash/wm/window_state.h" 9 #include "ash/wm/window_state.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return WallpaperPrivateRestoreMinimizedWindowsFunction::RunAsync(); 63 return WallpaperPrivateRestoreMinimizedWindowsFunction::RunAsync();
64 } 64 }
65 protected: 65 protected:
66 ~TestRestoreFunction() override {} 66 ~TestRestoreFunction() override {}
67 }; 67 };
68 68
69 } // namespace 69 } // namespace
70 70
71 TEST_F(WallpaperPrivateApiUnittest, HideAndRestoreWindows) { 71 TEST_F(WallpaperPrivateApiUnittest, HideAndRestoreWindows) {
72 fake_user_manager()->AddUser(kTestAccount1); 72 fake_user_manager()->AddUser(kTestAccount1);
73 scoped_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4));
73 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); 74 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3));
74 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); 75 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2));
75 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); 76 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1));
76 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); 77 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0));
77 78
78 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); 79 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get());
79 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); 80 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get());
80 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); 81 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get());
81 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); 82 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get());
83 ash::wm::WindowState* window4_state = ash::wm::GetWindowState(window4.get());
82 84
83 window3_state->Minimize(); 85 window3_state->Minimize();
84 window1_state->Maximize(); 86 window1_state->Maximize();
85 87
86 // Window 3 starts minimized, window 1 starts maximized. 88 // Window 3 starts minimized, window 1 starts maximized.
87 EXPECT_FALSE(window0_state->IsMinimized()); 89 EXPECT_FALSE(window0_state->IsMinimized());
88 EXPECT_FALSE(window1_state->IsMinimized()); 90 EXPECT_FALSE(window1_state->IsMinimized());
89 EXPECT_FALSE(window2_state->IsMinimized()); 91 EXPECT_FALSE(window2_state->IsMinimized());
90 EXPECT_TRUE(window3_state->IsMinimized()); 92 EXPECT_TRUE(window3_state->IsMinimized());
93 EXPECT_FALSE(window4_state->IsMinimized());
91 94
92 // We then activate window 0 (i.e. wallpaper picker) and call the minimize 95 // We then activate window 0 (i.e. wallpaper picker) and call the minimize
93 // function. 96 // function.
94 window0_state->Activate(); 97 window0_state->Activate();
95 EXPECT_TRUE(window0_state->IsActive()); 98 EXPECT_TRUE(window0_state->IsActive());
96 scoped_refptr<TestMinimizeFunction> minimize_function( 99 scoped_refptr<TestMinimizeFunction> minimize_function(
97 new TestMinimizeFunction()); 100 new TestMinimizeFunction());
98 EXPECT_TRUE(minimize_function->RunAsync()); 101 EXPECT_TRUE(minimize_function->RunAsync());
99 102
100 // All windows except window 0 should be minimized. 103 // All windows except window 0 should be minimized.
101 EXPECT_FALSE(window0_state->IsMinimized()); 104 EXPECT_FALSE(window0_state->IsMinimized());
102 EXPECT_TRUE(window1_state->IsMinimized()); 105 EXPECT_TRUE(window1_state->IsMinimized());
103 EXPECT_TRUE(window2_state->IsMinimized()); 106 EXPECT_TRUE(window2_state->IsMinimized());
104 EXPECT_TRUE(window3_state->IsMinimized()); 107 EXPECT_TRUE(window3_state->IsMinimized());
108 EXPECT_TRUE(window4_state->IsMinimized());
109
110 // Activates window 4 and then minimizes it.
111 window4_state->Activate();
112 window4_state->Minimize();
105 113
106 // Then we destroy window 0 and call the restore function. 114 // Then we destroy window 0 and call the restore function.
107 window0.reset(); 115 window0.reset();
108 scoped_refptr<TestRestoreFunction> restore_function( 116 scoped_refptr<TestRestoreFunction> restore_function(
109 new TestRestoreFunction()); 117 new TestRestoreFunction());
110 EXPECT_TRUE(restore_function->RunAsync()); 118 EXPECT_TRUE(restore_function->RunAsync());
111 119
112 // Windows 1 and 2 should no longer be minimized. Window 1 should again 120 // Windows 1 and 2 should no longer be minimized. Window 1 should again
113 // be maximized. Window 3 should still be minimized. 121 // be maximized. Window 3 should still be minimized. Window 4 should remain
122 // minimized since user interacted with it while wallpaper picker was open.
114 EXPECT_TRUE(window1_state->IsMaximized()); 123 EXPECT_TRUE(window1_state->IsMaximized());
115 EXPECT_FALSE(window2_state->IsMinimized()); 124 EXPECT_FALSE(window2_state->IsMinimized());
116 EXPECT_TRUE(window3_state->IsMinimized()); 125 EXPECT_TRUE(window3_state->IsMinimized());
126 EXPECT_TRUE(window4_state->IsMinimized());
117 } 127 }
118 128
119 // Test for multiple calls to |MinimizeInactiveWindows| before call 129 // Test for multiple calls to |MinimizeInactiveWindows| before call
120 // |RestoreWindows|: 130 // |RestoreWindows|:
121 // 1. If all window hasn't change their states, the following calls are noops. 131 // 1. If all window hasn't change their states, the following calls are noops.
122 // 2. If some windows are manually unminimized, the following call will minimize 132 // 2. If some windows are manually unminimized, the following call will minimize
123 // all the unminimized windows. 133 // all the unminimized windows.
124 TEST_F(WallpaperPrivateApiUnittest, HideAndManualUnminimizeWindows) { 134 TEST_F(WallpaperPrivateApiUnittest, HideAndManualUnminimizeWindows) {
125 fake_user_manager()->AddUser(kTestAccount1); 135 fake_user_manager()->AddUser(kTestAccount1);
126 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); 136 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1));
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 scoped_refptr<TestRestoreFunction> restore_function_1( 403 scoped_refptr<TestRestoreFunction> restore_function_1(
394 new TestRestoreFunction()); 404 new TestRestoreFunction());
395 EXPECT_TRUE(restore_function_1->RunAsync()); 405 EXPECT_TRUE(restore_function_1->RunAsync());
396 406
397 EXPECT_FALSE(window1_state->IsMinimized()); 407 EXPECT_FALSE(window1_state->IsMinimized());
398 EXPECT_FALSE(window2_state->IsMinimized()); 408 EXPECT_FALSE(window2_state->IsMinimized());
399 EXPECT_FALSE(window3_state->IsMinimized()); 409 EXPECT_FALSE(window3_state->IsMinimized());
400 } 410 }
401 411
402 } // namespace chromeos 412 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/wallpaper_private_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698