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

Side by Side Diff: ash/common/system/tray/system_tray_unittest.cc

Issue 2752643002: chromeos: Enable Alt-Shift-S to show system tray bubble for mash (Closed)
Patch Set: Created 3 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
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/common/system/tray/system_tray.h" 5 #include "ash/common/system/tray/system_tray.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/accelerators/accelerator_controller.h" 10 #include "ash/common/accelerators/accelerator_controller.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 // Ensure that closing the bubble destroys it. 199 // Ensure that closing the bubble destroys it.
200 ASSERT_TRUE(tray->CloseSystemBubble()); 200 ASSERT_TRUE(tray->CloseSystemBubble());
201 RunAllPendingInMessageLoop(); 201 RunAllPendingInMessageLoop();
202 ASSERT_FALSE(tray->CloseSystemBubble()); 202 ASSERT_FALSE(tray->CloseSystemBubble());
203 } 203 }
204 204
205 // Make sure the opening system tray bubble will not deactivate the 205 // Make sure the opening system tray bubble will not deactivate the
206 // other window. crbug.com/120680. 206 // other window. crbug.com/120680.
207 TEST_F(SystemTrayTest, Activation) { 207 TEST_F(SystemTrayTest, Activation) {
208 // TODO: investigate why this fails in mash. http://crbug.com/695559.
209 if (WmShell::Get()->IsRunningInMash())
210 return;
211
212 SystemTray* tray = GetPrimarySystemTray(); 208 SystemTray* tray = GetPrimarySystemTray();
213 std::unique_ptr<views::Widget> widget(CreateTestWidget( 209 std::unique_ptr<views::Widget> widget(CreateTestWidget(
214 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(0, 0, 100, 100))); 210 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(0, 0, 100, 100)));
215 EXPECT_TRUE(widget->IsActive()); 211 EXPECT_TRUE(widget->IsActive());
216 212
213 // The window stays active after the bubble opens.
217 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 214 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
218 ASSERT_TRUE(tray->GetWidget()); 215 ASSERT_TRUE(tray->GetWidget());
219 EXPECT_FALSE(tray->GetSystemBubble()->bubble_view()->GetWidget()->IsActive()); 216 EXPECT_FALSE(tray->GetSystemBubble()->bubble_view()->GetWidget()->IsActive());
220 EXPECT_TRUE(widget->IsActive()); 217 EXPECT_TRUE(widget->IsActive());
221 218
219 // Activating the bubble makes the window lose activation.
222 tray->ActivateBubble(); 220 tray->ActivateBubble();
223 EXPECT_TRUE(tray->GetSystemBubble()->bubble_view()->GetWidget()->IsActive()); 221 EXPECT_TRUE(tray->GetSystemBubble()->bubble_view()->GetWidget()->IsActive());
224 EXPECT_FALSE(widget->IsActive()); 222 EXPECT_FALSE(widget->IsActive());
225 223
226 // Accelerator will activate the bubble. 224 // Closing the bubble re-activates the window.
msw 2017/03/14 17:25:23 aside: Activation changes in unit tests can be fla
James Cook 2017/03/14 17:46:30 Acknowledged. I think each test gets its own ash::
227 tray->CloseSystemBubble(); 225 tray->CloseSystemBubble();
226 EXPECT_TRUE(widget->IsActive());
228 227
229 EXPECT_TRUE(widget->IsActive()); 228 // Opening the bubble with an accelerator activates the bubble because the
229 // user will probably navigate with the keyboard.
230 WmShell::Get()->accelerator_controller()->PerformActionIfEnabled( 230 WmShell::Get()->accelerator_controller()->PerformActionIfEnabled(
231 SHOW_SYSTEM_TRAY_BUBBLE); 231 SHOW_SYSTEM_TRAY_BUBBLE);
232 ASSERT_TRUE(tray->GetWidget());
232 EXPECT_TRUE(tray->GetSystemBubble()->bubble_view()->GetWidget()->IsActive()); 233 EXPECT_TRUE(tray->GetSystemBubble()->bubble_view()->GetWidget()->IsActive());
233 EXPECT_FALSE(widget->IsActive()); 234 EXPECT_FALSE(widget->IsActive());
234 } 235 }
235 236
236 // Opening and closing the bubble should change the coloring of the tray. 237 // Opening and closing the bubble should change the coloring of the tray.
237 TEST_F(SystemTrayTest, SystemTrayColoring) { 238 TEST_F(SystemTrayTest, SystemTrayColoring) {
238 SystemTray* tray = GetPrimarySystemTray(); 239 SystemTray* tray = GetPrimarySystemTray();
239 ASSERT_TRUE(tray->GetWidget()); 240 ASSERT_TRUE(tray->GetWidget());
240 // At the beginning the tray coloring is not active. 241 // At the beginning the tray coloring is not active.
241 ASSERT_FALSE(tray->is_active()); 242 ASSERT_FALSE(tray->is_active());
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 556
556 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); 557 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test());
557 } 558 }
558 559
559 TEST_F(SystemTrayTest, SeparatorThickness) { 560 TEST_F(SystemTrayTest, SeparatorThickness) {
560 EXPECT_EQ(kSeparatorWidth, views::Separator::kThickness); 561 EXPECT_EQ(kSeparatorWidth, views::Separator::kThickness);
561 } 562 }
562 563
563 } // namespace test 564 } // namespace test
564 } // namespace ash 565 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/accelerators/accelerator_controller.cc ('k') | ash/mus/accelerators/accelerator_controller_delegate_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698