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

Side by Side Diff: ash/focus_cycler_unittest.cc

Issue 11017079: Remove Shell::shelf()|status_area_widget()|launcher() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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
« no previous file with comments | « ash/display/display_controller_unittest.cc ('k') | ash/launcher/launcher.h » ('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/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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); 61 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
62 62
63 // Add the Status area 63 // Add the Status area
64 scoped_ptr<SystemTray> tray(CreateSystemTray()); 64 scoped_ptr<SystemTray> tray(CreateSystemTray());
65 ASSERT_TRUE(tray->GetWidget()); 65 ASSERT_TRUE(tray->GetWidget());
66 focus_cycler->AddWidget(tray->GetWidget()); 66 focus_cycler->AddWidget(tray->GetWidget());
67 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting( 67 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting(
68 focus_cycler.get()); 68 focus_cycler.get());
69 69
70 // Add the launcher 70 // Add the launcher
71 Launcher* launcher = Shell::GetInstance()->launcher(); 71 Launcher* launcher = Launcher::ForPrimaryDisplay();
72 ASSERT_TRUE(launcher); 72 ASSERT_TRUE(launcher);
73 views::Widget* launcher_widget = launcher->widget(); 73 views::Widget* launcher_widget = launcher->widget();
74 ASSERT_TRUE(launcher_widget); 74 ASSERT_TRUE(launcher_widget);
75 launcher->SetFocusCycler(focus_cycler.get()); 75 launcher->SetFocusCycler(focus_cycler.get());
76 76
77 // Create a single test window. 77 // Create a single test window.
78 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 78 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
79 wm::ActivateWindow(window0.get()); 79 wm::ActivateWindow(window0.get());
80 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 80 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
81 81
(...skipping 14 matching lines...) Expand all
96 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); 96 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
97 97
98 // Add the Status area 98 // Add the Status area
99 scoped_ptr<SystemTray> tray(CreateSystemTray()); 99 scoped_ptr<SystemTray> tray(CreateSystemTray());
100 ASSERT_TRUE(tray->GetWidget()); 100 ASSERT_TRUE(tray->GetWidget());
101 focus_cycler->AddWidget(tray->GetWidget()); 101 focus_cycler->AddWidget(tray->GetWidget());
102 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting( 102 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting(
103 focus_cycler.get()); 103 focus_cycler.get());
104 104
105 // Add the launcher 105 // Add the launcher
106 Launcher* launcher = Shell::GetInstance()->launcher(); 106 Launcher* launcher = Launcher::ForPrimaryDisplay();
107 ASSERT_TRUE(launcher); 107 ASSERT_TRUE(launcher);
108 views::Widget* launcher_widget = launcher->widget(); 108 views::Widget* launcher_widget = launcher->widget();
109 ASSERT_TRUE(launcher_widget); 109 ASSERT_TRUE(launcher_widget);
110 launcher->SetFocusCycler(focus_cycler.get()); 110 launcher->SetFocusCycler(focus_cycler.get());
111 111
112 // Create a single test window. 112 // Create a single test window.
113 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 113 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
114 wm::ActivateWindow(window0.get()); 114 wm::ActivateWindow(window0.get());
115 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 115 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
116 116
(...skipping 14 matching lines...) Expand all
131 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); 131 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
132 132
133 // Add the Status area 133 // Add the Status area
134 scoped_ptr<SystemTray> tray(CreateSystemTray()); 134 scoped_ptr<SystemTray> tray(CreateSystemTray());
135 ASSERT_TRUE(tray->GetWidget()); 135 ASSERT_TRUE(tray->GetWidget());
136 focus_cycler->AddWidget(tray->GetWidget()); 136 focus_cycler->AddWidget(tray->GetWidget());
137 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting( 137 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting(
138 focus_cycler.get()); 138 focus_cycler.get());
139 139
140 // Add the launcher 140 // Add the launcher
141 Launcher* launcher = Shell::GetInstance()->launcher(); 141 Launcher* launcher = Launcher::ForPrimaryDisplay();
142 ASSERT_TRUE(launcher); 142 ASSERT_TRUE(launcher);
143 views::Widget* launcher_widget = launcher->widget(); 143 views::Widget* launcher_widget = launcher->widget();
144 ASSERT_TRUE(launcher_widget); 144 ASSERT_TRUE(launcher_widget);
145 launcher->SetFocusCycler(focus_cycler.get()); 145 launcher->SetFocusCycler(focus_cycler.get());
146 146
147 // Create a single test window. 147 // Create a single test window.
148 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 148 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
149 wm::ActivateWindow(window0.get()); 149 wm::ActivateWindow(window0.get());
150 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 150 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
151 151
(...skipping 26 matching lines...) Expand all
178 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); 178 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
179 179
180 // Add the Status area 180 // Add the Status area
181 scoped_ptr<SystemTray> tray(CreateSystemTray()); 181 scoped_ptr<SystemTray> tray(CreateSystemTray());
182 ASSERT_TRUE(tray->GetWidget()); 182 ASSERT_TRUE(tray->GetWidget());
183 focus_cycler->AddWidget(tray->GetWidget()); 183 focus_cycler->AddWidget(tray->GetWidget());
184 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting( 184 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting(
185 focus_cycler.get()); 185 focus_cycler.get());
186 186
187 // Add the launcher and focus it 187 // Add the launcher and focus it
188 Launcher* launcher = Shell::GetInstance()->launcher(); 188 Launcher* launcher = Launcher::ForPrimaryDisplay();
189 ASSERT_TRUE(launcher); 189 ASSERT_TRUE(launcher);
190 views::Widget* launcher_widget = launcher->widget(); 190 views::Widget* launcher_widget = launcher->widget();
191 ASSERT_TRUE(launcher_widget); 191 ASSERT_TRUE(launcher_widget);
192 launcher->SetFocusCycler(focus_cycler.get()); 192 launcher->SetFocusCycler(focus_cycler.get());
193 focus_cycler->FocusWidget(launcher_widget); 193 focus_cycler->FocusWidget(launcher_widget);
194 194
195 // Cycle focus to the status area 195 // Cycle focus to the status area
196 focus_cycler->RotateFocus(FocusCycler::FORWARD); 196 focus_cycler->RotateFocus(FocusCycler::FORWARD);
197 EXPECT_TRUE(tray->GetWidget()->IsActive()); 197 EXPECT_TRUE(tray->GetWidget()->IsActive());
198 198
(...skipping 16 matching lines...) Expand all
215 215
216 class FocusCyclerLauncherTest : public AshTestBase { 216 class FocusCyclerLauncherTest : public AshTestBase {
217 public: 217 public:
218 FocusCyclerLauncherTest() : AshTestBase() {} 218 FocusCyclerLauncherTest() : AshTestBase() {}
219 virtual ~FocusCyclerLauncherTest() {} 219 virtual ~FocusCyclerLauncherTest() {}
220 220
221 virtual void SetUp() OVERRIDE { 221 virtual void SetUp() OVERRIDE {
222 AshTestBase::SetUp(); 222 AshTestBase::SetUp();
223 223
224 // Hide the launcher 224 // Hide the launcher
225 Launcher* launcher = Shell::GetInstance()->launcher(); 225 Launcher* launcher = Launcher::ForPrimaryDisplay();
226 ASSERT_TRUE(launcher); 226 ASSERT_TRUE(launcher);
227 views::Widget* launcher_widget = launcher->widget(); 227 views::Widget* launcher_widget = launcher->widget();
228 ASSERT_TRUE(launcher_widget); 228 ASSERT_TRUE(launcher_widget);
229 launcher_widget->Hide(); 229 launcher_widget->Hide();
230 } 230 }
231 231
232 virtual void TearDown() OVERRIDE { 232 virtual void TearDown() OVERRIDE {
233 // Show the launcher 233 // Show the launcher
234 Launcher* launcher = Shell::GetInstance()->launcher(); 234 Launcher* launcher = Launcher::ForPrimaryDisplay();
235 ASSERT_TRUE(launcher); 235 ASSERT_TRUE(launcher);
236 views::Widget* launcher_widget = launcher->widget(); 236 views::Widget* launcher_widget = launcher->widget();
237 ASSERT_TRUE(launcher_widget); 237 ASSERT_TRUE(launcher_widget);
238 launcher_widget->Show(); 238 launcher_widget->Show();
239 239
240 AshTestBase::TearDown(); 240 AshTestBase::TearDown();
241 } 241 }
242 242
243 private: 243 private:
244 DISALLOW_COPY_AND_ASSIGN(FocusCyclerLauncherTest); 244 DISALLOW_COPY_AND_ASSIGN(FocusCyclerLauncherTest);
245 }; 245 };
246 246
247 TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) { 247 TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) {
248 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); 248 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
249 249
250 // Add the Status area 250 // Add the Status area
251 scoped_ptr<SystemTray> tray(CreateSystemTray()); 251 scoped_ptr<SystemTray> tray(CreateSystemTray());
252 ASSERT_TRUE(tray->GetWidget()); 252 ASSERT_TRUE(tray->GetWidget());
253 focus_cycler->AddWidget(tray->GetWidget()); 253 focus_cycler->AddWidget(tray->GetWidget());
254 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting( 254 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting(
255 focus_cycler.get()); 255 focus_cycler.get());
256 256
257 // Add the launcher 257 // Add the launcher
258 Launcher* launcher = Shell::GetInstance()->launcher(); 258 Launcher* launcher = Launcher::ForPrimaryDisplay();
259 ASSERT_TRUE(launcher); 259 ASSERT_TRUE(launcher);
260 views::Widget* launcher_widget = launcher->widget(); 260 views::Widget* launcher_widget = launcher->widget();
261 ASSERT_TRUE(launcher_widget); 261 ASSERT_TRUE(launcher_widget);
262 launcher->SetFocusCycler(focus_cycler.get()); 262 launcher->SetFocusCycler(focus_cycler.get());
263 263
264 // Create a single test window. 264 // Create a single test window.
265 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 265 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
266 wm::ActivateWindow(window0.get()); 266 wm::ActivateWindow(window0.get());
267 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 267 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
268 268
(...skipping 10 matching lines...) Expand all
279 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); 279 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
280 280
281 // Add the Status area 281 // Add the Status area
282 scoped_ptr<SystemTray> tray(CreateSystemTray()); 282 scoped_ptr<SystemTray> tray(CreateSystemTray());
283 ASSERT_TRUE(tray->GetWidget()); 283 ASSERT_TRUE(tray->GetWidget());
284 focus_cycler->AddWidget(tray->GetWidget()); 284 focus_cycler->AddWidget(tray->GetWidget());
285 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting( 285 GetStatusAreaWidgetDelegate(tray->GetWidget())->SetFocusCyclerForTesting(
286 focus_cycler.get()); 286 focus_cycler.get());
287 287
288 // Add the launcher 288 // Add the launcher
289 Launcher* launcher = Shell::GetInstance()->launcher(); 289 Launcher* launcher = Launcher::ForPrimaryDisplay();
290 ASSERT_TRUE(launcher); 290 ASSERT_TRUE(launcher);
291 views::Widget* launcher_widget = launcher->widget(); 291 views::Widget* launcher_widget = launcher->widget();
292 ASSERT_TRUE(launcher_widget); 292 ASSERT_TRUE(launcher_widget);
293 launcher->SetFocusCycler(focus_cycler.get()); 293 launcher->SetFocusCycler(focus_cycler.get());
294 294
295 // Create a single test window. 295 // Create a single test window.
296 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 296 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
297 wm::ActivateWindow(window0.get()); 297 wm::ActivateWindow(window0.get());
298 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 298 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
299 299
300 // Cycle focus to the status area 300 // Cycle focus to the status area
301 focus_cycler->RotateFocus(FocusCycler::BACKWARD); 301 focus_cycler->RotateFocus(FocusCycler::BACKWARD);
302 EXPECT_TRUE(tray->GetWidget()->IsActive()); 302 EXPECT_TRUE(tray->GetWidget()->IsActive());
303 303
304 // Cycle focus to the browser 304 // Cycle focus to the browser
305 focus_cycler->RotateFocus(FocusCycler::BACKWARD); 305 focus_cycler->RotateFocus(FocusCycler::BACKWARD);
306 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 306 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
307 } 307 }
308 308
309 } // namespace test 309 } // namespace test
310 } // namespace ash 310 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_controller_unittest.cc ('k') | ash/launcher/launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698