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

Side by Side Diff: ash/focus_cycler_unittest.cc

Issue 9570013: Activate the status area only when it's focused using the keyboard (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix new FocusCycler tests Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/shell.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/status_area/status_area_view.h"
10 #include "ash/wm/window_util.h" 11 #include "ash/wm/window_util.h"
11 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
12 #include "ash/shell_factory.h" 13 #include "ash/shell_factory.h"
13 #include "ui/aura/test/test_windows.h" 14 #include "ui/aura/test/test_windows.h"
14 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
15 #include "ui/views/controls/button/menu_button.h" 16 #include "ui/views/controls/button/menu_button.h"
16 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
17 18
18 namespace ash { 19 namespace ash {
19 namespace test { 20 namespace test {
(...skipping 20 matching lines...) Expand all
40 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 41 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
41 } 42 }
42 43
43 TEST_F(FocusCyclerTest, CycleFocusForward) { 44 TEST_F(FocusCyclerTest, CycleFocusForward) {
44 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); 45 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
45 46
46 // Add the Status area 47 // Add the Status area
47 views::Widget* status_widget = internal::CreateStatusArea(NULL); 48 views::Widget* status_widget = internal::CreateStatusArea(NULL);
48 ASSERT_TRUE(status_widget); 49 ASSERT_TRUE(status_widget);
49 focus_cycler->AddWidget(status_widget); 50 focus_cycler->AddWidget(status_widget);
51 static_cast<internal::StatusAreaView*>(status_widget->GetContentsView())->
52 SetFocusCyclerForTesting(focus_cycler.get());
50 53
51 // Add a mock button to the status area. 54 // Add a mock button to the status area.
52 status_widget->GetContentsView()->AddChildView( 55 status_widget->GetContentsView()->AddChildView(
53 new views::MenuButton(NULL, string16(), NULL, false)); 56 new views::MenuButton(NULL, string16(), NULL, false));
54 57
55 // Add the launcher 58 // Add the launcher
56 Launcher* launcher = Shell::GetInstance()->launcher(); 59 Launcher* launcher = Shell::GetInstance()->launcher();
57 ASSERT_TRUE(launcher); 60 ASSERT_TRUE(launcher);
58 views::Widget* launcher_widget = launcher->widget(); 61 views::Widget* launcher_widget = launcher->widget();
59 ASSERT_TRUE(launcher_widget); 62 ASSERT_TRUE(launcher_widget);
(...skipping 21 matching lines...) Expand all
81 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 84 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
82 } 85 }
83 86
84 TEST_F(FocusCyclerTest, CycleFocusBackward) { 87 TEST_F(FocusCyclerTest, CycleFocusBackward) {
85 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); 88 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
86 89
87 // Add the Status area 90 // Add the Status area
88 views::Widget* status_widget = internal::CreateStatusArea(NULL); 91 views::Widget* status_widget = internal::CreateStatusArea(NULL);
89 ASSERT_TRUE(status_widget); 92 ASSERT_TRUE(status_widget);
90 focus_cycler->AddWidget(status_widget); 93 focus_cycler->AddWidget(status_widget);
94 static_cast<internal::StatusAreaView*>(status_widget->GetContentsView())->
95 SetFocusCyclerForTesting(focus_cycler.get());
91 96
92 // Add a mock button to the status area. 97 // Add a mock button to the status area.
93 status_widget->GetContentsView()->AddChildView( 98 status_widget->GetContentsView()->AddChildView(
94 new views::MenuButton(NULL, string16(), NULL, false)); 99 new views::MenuButton(NULL, string16(), NULL, false));
95 100
96 // Add the launcher 101 // Add the launcher
97 Launcher* launcher = Shell::GetInstance()->launcher(); 102 Launcher* launcher = Shell::GetInstance()->launcher();
98 ASSERT_TRUE(launcher); 103 ASSERT_TRUE(launcher);
99 views::Widget* launcher_widget = launcher->widget(); 104 views::Widget* launcher_widget = launcher->widget();
100 ASSERT_TRUE(launcher_widget); 105 ASSERT_TRUE(launcher_widget);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 DISALLOW_COPY_AND_ASSIGN(FocusCyclerLauncherTest); 158 DISALLOW_COPY_AND_ASSIGN(FocusCyclerLauncherTest);
154 }; 159 };
155 160
156 TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) { 161 TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) {
157 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); 162 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
158 163
159 // Add the Status area 164 // Add the Status area
160 views::Widget* status_widget = internal::CreateStatusArea(NULL); 165 views::Widget* status_widget = internal::CreateStatusArea(NULL);
161 ASSERT_TRUE(status_widget); 166 ASSERT_TRUE(status_widget);
162 focus_cycler->AddWidget(status_widget); 167 focus_cycler->AddWidget(status_widget);
168 static_cast<internal::StatusAreaView*>(status_widget->GetContentsView())->
169 SetFocusCyclerForTesting(focus_cycler.get());
163 170
164 // Add a mock button to the status area. 171 // Add a mock button to the status area.
165 status_widget->GetContentsView()->AddChildView( 172 status_widget->GetContentsView()->AddChildView(
166 new views::MenuButton(NULL, string16(), NULL, false)); 173 new views::MenuButton(NULL, string16(), NULL, false));
167 174
168 // Add the launcher 175 // Add the launcher
169 Launcher* launcher = Shell::GetInstance()->launcher(); 176 Launcher* launcher = Shell::GetInstance()->launcher();
170 ASSERT_TRUE(launcher); 177 ASSERT_TRUE(launcher);
171 views::Widget* launcher_widget = launcher->widget(); 178 views::Widget* launcher_widget = launcher->widget();
172 ASSERT_TRUE(launcher_widget); 179 ASSERT_TRUE(launcher_widget);
(...skipping 17 matching lines...) Expand all
190 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 197 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
191 } 198 }
192 199
193 TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) { 200 TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) {
194 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); 201 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
195 202
196 // Add the Status area 203 // Add the Status area
197 views::Widget* status_widget = internal::CreateStatusArea(NULL); 204 views::Widget* status_widget = internal::CreateStatusArea(NULL);
198 ASSERT_TRUE(status_widget); 205 ASSERT_TRUE(status_widget);
199 focus_cycler->AddWidget(status_widget); 206 focus_cycler->AddWidget(status_widget);
207 static_cast<internal::StatusAreaView*>(status_widget->GetContentsView())->
208 SetFocusCyclerForTesting(focus_cycler.get());
200 209
201 // Add a mock button to the status area. 210 // Add a mock button to the status area.
202 status_widget->GetContentsView()->AddChildView( 211 status_widget->GetContentsView()->AddChildView(
203 new views::MenuButton(NULL, string16(), NULL, false)); 212 new views::MenuButton(NULL, string16(), NULL, false));
204 213
205 // Add the launcher 214 // Add the launcher
206 Launcher* launcher = Shell::GetInstance()->launcher(); 215 Launcher* launcher = Shell::GetInstance()->launcher();
207 ASSERT_TRUE(launcher); 216 ASSERT_TRUE(launcher);
208 views::Widget* launcher_widget = launcher->widget(); 217 views::Widget* launcher_widget = launcher->widget();
209 ASSERT_TRUE(launcher_widget); 218 ASSERT_TRUE(launcher_widget);
(...skipping 12 matching lines...) Expand all
222 focus_cycler->RotateFocus(FocusCycler::BACKWARD); 231 focus_cycler->RotateFocus(FocusCycler::BACKWARD);
223 EXPECT_TRUE(status_widget->IsActive()); 232 EXPECT_TRUE(status_widget->IsActive());
224 233
225 // Cycle focus to the browser 234 // Cycle focus to the browser
226 focus_cycler->RotateFocus(FocusCycler::BACKWARD); 235 focus_cycler->RotateFocus(FocusCycler::BACKWARD);
227 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 236 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
228 } 237 }
229 238
230 } // namespace test 239 } // namespace test
231 } // namespace ash 240 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698