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

Side by Side Diff: ash/focus_cycler_unittest.cc

Issue 10857021: Prepare a bunch of ash tests for workspace2. With Workspace2 you can't (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/system/status_area_widget.h" 10 #include "ash/system/status_area_widget.h"
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 42
43 } // namespace 43 } // namespace
44 44
45 typedef AshTestBase FocusCyclerTest; 45 typedef AshTestBase FocusCyclerTest;
46 46
47 TEST_F(FocusCyclerTest, CycleFocusBrowserOnly) { 47 TEST_F(FocusCyclerTest, CycleFocusBrowserOnly) {
48 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); 48 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
49 49
50 // Create a single test window. 50 // Create a single test window.
51 Window* default_container = Shell::GetContainer( 51 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
52 Shell::GetPrimaryRootWindow(),
53 internal::kShellWindowId_DefaultContainer);
54 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
55 wm::ActivateWindow(window0.get()); 52 wm::ActivateWindow(window0.get());
56 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 53 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
57 54
58 // Cycle the window 55 // Cycle the window
59 focus_cycler->RotateFocus(FocusCycler::FORWARD); 56 focus_cycler->RotateFocus(FocusCycler::FORWARD);
60 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 57 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
61 } 58 }
62 59
63 TEST_F(FocusCyclerTest, CycleFocusForward) { 60 TEST_F(FocusCyclerTest, CycleFocusForward) {
64 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); 61 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
65 62
66 // Add the Status area 63 // Add the Status area
67 scoped_ptr<SystemTray> tray(CreateSystemTray()); 64 scoped_ptr<SystemTray> tray(CreateSystemTray());
68 ASSERT_TRUE(tray->GetWidget()); 65 ASSERT_TRUE(tray->GetWidget());
69 focus_cycler->AddWidget(tray->GetWidget()); 66 focus_cycler->AddWidget(tray->GetWidget());
70 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting( 67 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting(
71 focus_cycler.get()); 68 focus_cycler.get());
72 69
73 // Add the launcher 70 // Add the launcher
74 Launcher* launcher = Shell::GetInstance()->launcher(); 71 Launcher* launcher = Shell::GetInstance()->launcher();
75 ASSERT_TRUE(launcher); 72 ASSERT_TRUE(launcher);
76 views::Widget* launcher_widget = launcher->widget(); 73 views::Widget* launcher_widget = launcher->widget();
77 ASSERT_TRUE(launcher_widget); 74 ASSERT_TRUE(launcher_widget);
78 launcher->SetFocusCycler(focus_cycler.get()); 75 launcher->SetFocusCycler(focus_cycler.get());
79 76
80 // Create a single test window. 77 // Create a single test window.
81 Window* default_container = Shell::GetContainer( 78 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
82 Shell::GetPrimaryRootWindow(),
83 internal::kShellWindowId_DefaultContainer);
84 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
85 wm::ActivateWindow(window0.get()); 79 wm::ActivateWindow(window0.get());
86 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 80 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
87 81
88 // Cycle focus to the status area 82 // Cycle focus to the status area
89 focus_cycler->RotateFocus(FocusCycler::FORWARD); 83 focus_cycler->RotateFocus(FocusCycler::FORWARD);
90 EXPECT_TRUE(tray->GetWidget()->IsActive()); 84 EXPECT_TRUE(tray->GetWidget()->IsActive());
91 85
92 // Cycle focus to the launcher 86 // Cycle focus to the launcher
93 focus_cycler->RotateFocus(FocusCycler::FORWARD); 87 focus_cycler->RotateFocus(FocusCycler::FORWARD);
94 EXPECT_TRUE(launcher_widget->IsActive()); 88 EXPECT_TRUE(launcher_widget->IsActive());
(...skipping 14 matching lines...) Expand all
109 focus_cycler.get()); 103 focus_cycler.get());
110 104
111 // Add the launcher 105 // Add the launcher
112 Launcher* launcher = Shell::GetInstance()->launcher(); 106 Launcher* launcher = Shell::GetInstance()->launcher();
113 ASSERT_TRUE(launcher); 107 ASSERT_TRUE(launcher);
114 views::Widget* launcher_widget = launcher->widget(); 108 views::Widget* launcher_widget = launcher->widget();
115 ASSERT_TRUE(launcher_widget); 109 ASSERT_TRUE(launcher_widget);
116 launcher->SetFocusCycler(focus_cycler.get()); 110 launcher->SetFocusCycler(focus_cycler.get());
117 111
118 // Create a single test window. 112 // Create a single test window.
119 Window* default_container = Shell::GetContainer( 113 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
120 Shell::GetPrimaryRootWindow(),
121 internal::kShellWindowId_DefaultContainer);
122 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
123 wm::ActivateWindow(window0.get()); 114 wm::ActivateWindow(window0.get());
124 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 115 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
125 116
126 // Cycle focus to the launcher 117 // Cycle focus to the launcher
127 focus_cycler->RotateFocus(FocusCycler::BACKWARD); 118 focus_cycler->RotateFocus(FocusCycler::BACKWARD);
128 EXPECT_TRUE(launcher_widget->IsActive()); 119 EXPECT_TRUE(launcher_widget->IsActive());
129 120
130 // Cycle focus to the status area 121 // Cycle focus to the status area
131 focus_cycler->RotateFocus(FocusCycler::BACKWARD); 122 focus_cycler->RotateFocus(FocusCycler::BACKWARD);
132 EXPECT_TRUE(tray->GetWidget()->IsActive()); 123 EXPECT_TRUE(tray->GetWidget()->IsActive());
(...skipping 14 matching lines...) Expand all
147 focus_cycler.get()); 138 focus_cycler.get());
148 139
149 // Add the launcher 140 // Add the launcher
150 Launcher* launcher = Shell::GetInstance()->launcher(); 141 Launcher* launcher = Shell::GetInstance()->launcher();
151 ASSERT_TRUE(launcher); 142 ASSERT_TRUE(launcher);
152 views::Widget* launcher_widget = launcher->widget(); 143 views::Widget* launcher_widget = launcher->widget();
153 ASSERT_TRUE(launcher_widget); 144 ASSERT_TRUE(launcher_widget);
154 launcher->SetFocusCycler(focus_cycler.get()); 145 launcher->SetFocusCycler(focus_cycler.get());
155 146
156 // Create a single test window. 147 // Create a single test window.
157 Window* default_container = Shell::GetContainer( 148 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
158 Shell::GetPrimaryRootWindow(),
159 internal::kShellWindowId_DefaultContainer);
160 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
161 wm::ActivateWindow(window0.get()); 149 wm::ActivateWindow(window0.get());
162 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 150 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
163 151
164 // Cycle focus to the launcher 152 // Cycle focus to the launcher
165 focus_cycler->RotateFocus(FocusCycler::BACKWARD); 153 focus_cycler->RotateFocus(FocusCycler::BACKWARD);
166 EXPECT_TRUE(launcher_widget->IsActive()); 154 EXPECT_TRUE(launcher_widget->IsActive());
167 155
168 // Cycle focus to the status area 156 // Cycle focus to the status area
169 focus_cycler->RotateFocus(FocusCycler::BACKWARD); 157 focus_cycler->RotateFocus(FocusCycler::BACKWARD);
170 EXPECT_TRUE(tray->GetWidget()->IsActive()); 158 EXPECT_TRUE(tray->GetWidget()->IsActive());
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 focus_cycler.get()); 255 focus_cycler.get());
268 256
269 // Add the launcher 257 // Add the launcher
270 Launcher* launcher = Shell::GetInstance()->launcher(); 258 Launcher* launcher = Shell::GetInstance()->launcher();
271 ASSERT_TRUE(launcher); 259 ASSERT_TRUE(launcher);
272 views::Widget* launcher_widget = launcher->widget(); 260 views::Widget* launcher_widget = launcher->widget();
273 ASSERT_TRUE(launcher_widget); 261 ASSERT_TRUE(launcher_widget);
274 launcher->SetFocusCycler(focus_cycler.get()); 262 launcher->SetFocusCycler(focus_cycler.get());
275 263
276 // Create a single test window. 264 // Create a single test window.
277 Window* default_container = Shell::GetContainer( 265 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
278 Shell::GetPrimaryRootWindow(),
279 internal::kShellWindowId_DefaultContainer);
280 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
281 wm::ActivateWindow(window0.get()); 266 wm::ActivateWindow(window0.get());
282 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 267 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
283 268
284 // Cycle focus to the status area 269 // Cycle focus to the status area
285 focus_cycler->RotateFocus(FocusCycler::FORWARD); 270 focus_cycler->RotateFocus(FocusCycler::FORWARD);
286 EXPECT_TRUE(tray->GetWidget()->IsActive()); 271 EXPECT_TRUE(tray->GetWidget()->IsActive());
287 272
288 // Cycle focus to the browser 273 // Cycle focus to the browser
289 focus_cycler->RotateFocus(FocusCycler::FORWARD); 274 focus_cycler->RotateFocus(FocusCycler::FORWARD);
290 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 275 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
(...skipping 10 matching lines...) Expand all
301 focus_cycler.get()); 286 focus_cycler.get());
302 287
303 // Add the launcher 288 // Add the launcher
304 Launcher* launcher = Shell::GetInstance()->launcher(); 289 Launcher* launcher = Shell::GetInstance()->launcher();
305 ASSERT_TRUE(launcher); 290 ASSERT_TRUE(launcher);
306 views::Widget* launcher_widget = launcher->widget(); 291 views::Widget* launcher_widget = launcher->widget();
307 ASSERT_TRUE(launcher_widget); 292 ASSERT_TRUE(launcher_widget);
308 launcher->SetFocusCycler(focus_cycler.get()); 293 launcher->SetFocusCycler(focus_cycler.get());
309 294
310 // Create a single test window. 295 // Create a single test window.
311 Window* default_container = Shell::GetInstance()->GetContainer( 296 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
312 Shell::GetPrimaryRootWindow(),
313 internal::kShellWindowId_DefaultContainer);
314 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
315 wm::ActivateWindow(window0.get()); 297 wm::ActivateWindow(window0.get());
316 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 298 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
317 299
318 // Cycle focus to the status area 300 // Cycle focus to the status area
319 focus_cycler->RotateFocus(FocusCycler::BACKWARD); 301 focus_cycler->RotateFocus(FocusCycler::BACKWARD);
320 EXPECT_TRUE(tray->GetWidget()->IsActive()); 302 EXPECT_TRUE(tray->GetWidget()->IsActive());
321 303
322 // Cycle focus to the browser 304 // Cycle focus to the browser
323 focus_cycler->RotateFocus(FocusCycler::BACKWARD); 305 focus_cycler->RotateFocus(FocusCycler::BACKWARD);
324 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 306 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
325 } 307 }
326 308
327 } // namespace test 309 } // namespace test
328 } // namespace ash 310 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/nested_dispatcher_controller_unittest.cc ('k') | ash/launcher/launcher_context_menu_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698