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

Side by Side Diff: ash/focus_cycler_unittest.cc

Issue 11421006: Desktop aura: Break aura::Window::SetParent in two. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ash_unittests Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « ash/drag_drop/drag_drop_tracker_unittest.cc ('k') | ash/root_window_controller_unittest.cc » ('j') | 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/focus_cycler.h" 5 #include "ash/focus_cycler.h"
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
11 #include "ash/system/status_area_widget.h" 11 #include "ash/system/status_area_widget.h"
12 #include "ash/system/status_area_widget_delegate.h" 12 #include "ash/system/status_area_widget_delegate.h"
13 #include "ash/system/tray/system_tray.h" 13 #include "ash/system/tray/system_tray.h"
14 #include "ash/wm/window_util.h" 14 #include "ash/wm/window_util.h"
15 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
16 #include "ash/shell_factory.h" 16 #include "ash/shell_factory.h"
17 #include "ui/aura/test/test_windows.h" 17 #include "ui/aura/test/test_windows.h"
18 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
19 #include "ui/views/controls/button/menu_button.h" 19 #include "ui/views/controls/button/menu_button.h"
20 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
21 21
22 namespace ash { 22 namespace ash {
23 namespace test { 23 namespace test {
24 24
25 using aura::test::CreateTestWindowWithId;
26 using aura::Window; 25 using aura::Window;
27 using internal::FocusCycler; 26 using internal::FocusCycler;
28 27
29 namespace { 28 namespace {
30 29
31 internal::StatusAreaWidgetDelegate* GetStatusAreaWidgetDelegate( 30 internal::StatusAreaWidgetDelegate* GetStatusAreaWidgetDelegate(
32 views::Widget* widget) { 31 views::Widget* widget) {
33 return static_cast<internal::StatusAreaWidgetDelegate*>( 32 return static_cast<internal::StatusAreaWidgetDelegate*>(
34 widget->GetContentsView()); 33 widget->GetContentsView());
35 } 34 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 97
99 private: 98 private:
100 scoped_ptr<FocusCycler> focus_cycler_; 99 scoped_ptr<FocusCycler> focus_cycler_;
101 scoped_ptr<SystemTray> tray_; 100 scoped_ptr<SystemTray> tray_;
102 101
103 DISALLOW_COPY_AND_ASSIGN(FocusCyclerTest); 102 DISALLOW_COPY_AND_ASSIGN(FocusCyclerTest);
104 }; 103 };
105 104
106 TEST_F(FocusCyclerTest, CycleFocusBrowserOnly) { 105 TEST_F(FocusCyclerTest, CycleFocusBrowserOnly) {
107 // Create a single test window. 106 // Create a single test window.
108 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 107 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
109 wm::ActivateWindow(window0.get()); 108 wm::ActivateWindow(window0.get());
110 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 109 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
111 110
112 // Cycle the window 111 // Cycle the window
113 focus_cycler()->RotateFocus(FocusCycler::FORWARD); 112 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
114 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 113 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
115 } 114 }
116 115
117 TEST_F(FocusCyclerTest, CycleFocusForward) { 116 TEST_F(FocusCyclerTest, CycleFocusForward) {
118 ASSERT_TRUE(CreateTray()); 117 ASSERT_TRUE(CreateTray());
119 118
120 InstallFocusCycleOnLauncher(); 119 InstallFocusCycleOnLauncher();
121 120
122 // Create a single test window. 121 // Create a single test window.
123 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 122 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
124 wm::ActivateWindow(window0.get()); 123 wm::ActivateWindow(window0.get());
125 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 124 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
126 125
127 // Cycle focus to the status area 126 // Cycle focus to the status area
128 focus_cycler()->RotateFocus(FocusCycler::FORWARD); 127 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
129 EXPECT_TRUE(tray()->GetWidget()->IsActive()); 128 EXPECT_TRUE(tray()->GetWidget()->IsActive());
130 129
131 // Cycle focus to the launcher 130 // Cycle focus to the launcher
132 focus_cycler()->RotateFocus(FocusCycler::FORWARD); 131 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
133 EXPECT_TRUE(launcher_widget()->IsActive()); 132 EXPECT_TRUE(launcher_widget()->IsActive());
134 133
135 // Cycle focus to the browser 134 // Cycle focus to the browser
136 focus_cycler()->RotateFocus(FocusCycler::FORWARD); 135 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
137 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 136 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
138 } 137 }
139 138
140 TEST_F(FocusCyclerTest, CycleFocusBackward) { 139 TEST_F(FocusCyclerTest, CycleFocusBackward) {
141 ASSERT_TRUE(CreateTray()); 140 ASSERT_TRUE(CreateTray());
142 141
143 InstallFocusCycleOnLauncher(); 142 InstallFocusCycleOnLauncher();
144 143
145 // Create a single test window. 144 // Create a single test window.
146 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 145 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
147 wm::ActivateWindow(window0.get()); 146 wm::ActivateWindow(window0.get());
148 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 147 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
149 148
150 // Cycle focus to the launcher 149 // Cycle focus to the launcher
151 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); 150 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
152 EXPECT_TRUE(launcher_widget()->IsActive()); 151 EXPECT_TRUE(launcher_widget()->IsActive());
153 152
154 // Cycle focus to the status area 153 // Cycle focus to the status area
155 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); 154 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
156 EXPECT_TRUE(tray()->GetWidget()->IsActive()); 155 EXPECT_TRUE(tray()->GetWidget()->IsActive());
157 156
158 // Cycle focus to the browser 157 // Cycle focus to the browser
159 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); 158 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
160 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 159 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
161 } 160 }
162 161
163 TEST_F(FocusCyclerTest, CycleFocusForwardBackward) { 162 TEST_F(FocusCyclerTest, CycleFocusForwardBackward) {
164 ASSERT_TRUE(CreateTray()); 163 ASSERT_TRUE(CreateTray());
165 164
166 InstallFocusCycleOnLauncher(); 165 InstallFocusCycleOnLauncher();
167 166
168 // Create a single test window. 167 // Create a single test window.
169 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 168 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
170 wm::ActivateWindow(window0.get()); 169 wm::ActivateWindow(window0.get());
171 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 170 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
172 171
173 // Cycle focus to the launcher 172 // Cycle focus to the launcher
174 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); 173 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
175 EXPECT_TRUE(launcher_widget()->IsActive()); 174 EXPECT_TRUE(launcher_widget()->IsActive());
176 175
177 // Cycle focus to the status area 176 // Cycle focus to the status area
178 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); 177 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
179 EXPECT_TRUE(tray()->GetWidget()->IsActive()); 178 EXPECT_TRUE(tray()->GetWidget()->IsActive());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); 222 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
224 EXPECT_TRUE(tray()->GetWidget()->IsActive()); 223 EXPECT_TRUE(tray()->GetWidget()->IsActive());
225 } 224 }
226 225
227 TEST_F(FocusCyclerTest, Launcher_CycleFocusForward) { 226 TEST_F(FocusCyclerTest, Launcher_CycleFocusForward) {
228 ASSERT_TRUE(CreateTray()); 227 ASSERT_TRUE(CreateTray());
229 InstallFocusCycleOnLauncher(); 228 InstallFocusCycleOnLauncher();
230 launcher_widget()->Hide(); 229 launcher_widget()->Hide();
231 230
232 // Create a single test window. 231 // Create a single test window.
233 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 232 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
234 wm::ActivateWindow(window0.get()); 233 wm::ActivateWindow(window0.get());
235 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 234 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
236 235
237 // Cycle focus to the status area 236 // Cycle focus to the status area
238 focus_cycler()->RotateFocus(FocusCycler::FORWARD); 237 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
239 EXPECT_TRUE(tray()->GetWidget()->IsActive()); 238 EXPECT_TRUE(tray()->GetWidget()->IsActive());
240 239
241 // Cycle focus to the browser 240 // Cycle focus to the browser
242 focus_cycler()->RotateFocus(FocusCycler::FORWARD); 241 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
243 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 242 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
244 } 243 }
245 244
246 TEST_F(FocusCyclerTest, Launcher_CycleFocusBackwardInvisible) { 245 TEST_F(FocusCyclerTest, Launcher_CycleFocusBackwardInvisible) {
247 ASSERT_TRUE(CreateTray()); 246 ASSERT_TRUE(CreateTray());
248 InstallFocusCycleOnLauncher(); 247 InstallFocusCycleOnLauncher();
249 launcher_widget()->Hide(); 248 launcher_widget()->Hide();
250 249
251 // Create a single test window. 250 // Create a single test window.
252 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 251 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
253 wm::ActivateWindow(window0.get()); 252 wm::ActivateWindow(window0.get());
254 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 253 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
255 254
256 // Cycle focus to the status area 255 // Cycle focus to the status area
257 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); 256 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
258 EXPECT_TRUE(tray()->GetWidget()->IsActive()); 257 EXPECT_TRUE(tray()->GetWidget()->IsActive());
259 258
260 // Cycle focus to the browser 259 // Cycle focus to the browser
261 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); 260 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
262 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 261 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
263 } 262 }
264 263
265 } // namespace test 264 } // namespace test
266 } // namespace ash 265 } // namespace ash
OLDNEW
« no previous file with comments | « ash/drag_drop/drag_drop_tracker_unittest.cc ('k') | ash/root_window_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698