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

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

Issue 2330403002: Do not activate system tray bubble by default (Closed)
Patch Set: Do not activate system tray bubble Created 4 years, 3 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/accessibility_delegate.h" 10 #include "ash/common/accessibility_delegate.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 ASSERT_TRUE(tray->GetWidget()); 196 ASSERT_TRUE(tray->GetWidget());
197 197
198 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 198 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
199 199
200 // Ensure that closing the bubble destroys it. 200 // Ensure that closing the bubble destroys it.
201 ASSERT_TRUE(tray->CloseSystemBubble()); 201 ASSERT_TRUE(tray->CloseSystemBubble());
202 RunAllPendingInMessageLoop(); 202 RunAllPendingInMessageLoop();
203 ASSERT_FALSE(tray->CloseSystemBubble()); 203 ASSERT_FALSE(tray->CloseSystemBubble());
204 } 204 }
205 205
206 TEST_F(SystemTrayTest, Activation) {
James Cook 2016/09/22 21:17:16 Document what this is testing and reference the bu
oshima 2016/09/23 09:37:20 Done.
207 SystemTray* tray = GetPrimarySystemTray();
208
209 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
210 ASSERT_TRUE(tray->GetWidget());
211 EXPECT_FALSE(tray->GetSystemBubble()->bubble_view()->GetWidget()->IsActive());
212 tray->ActivateBubble();
213 EXPECT_TRUE(tray->GetSystemBubble()->bubble_view()->GetWidget()->IsActive());
214 }
215
206 // Opening and closing the bubble should change the coloring of the tray. 216 // Opening and closing the bubble should change the coloring of the tray.
207 TEST_F(SystemTrayTest, SystemTrayColoring) { 217 TEST_F(SystemTrayTest, SystemTrayColoring) {
208 SystemTray* tray = GetPrimarySystemTray(); 218 SystemTray* tray = GetPrimarySystemTray();
209 ASSERT_TRUE(tray->GetWidget()); 219 ASSERT_TRUE(tray->GetWidget());
210 // At the beginning the tray coloring is not active. 220 // At the beginning the tray coloring is not active.
211 ASSERT_FALSE(tray->draw_background_as_active()); 221 ASSERT_FALSE(tray->draw_background_as_active());
212 222
213 // Showing the system bubble should show the background as active. 223 // Showing the system bubble should show the background as active.
214 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 224 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
215 ASSERT_TRUE(tray->draw_background_as_active()); 225 ASSERT_TRUE(tray->draw_background_as_active());
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 ASSERT_TRUE(tray->GetWidget()); 448 ASSERT_TRUE(tray->GetWidget());
439 449
440 TestSystemTrayItem* test_item = new TestSystemTrayItem(); 450 TestSystemTrayItem* test_item = new TestSystemTrayItem();
441 tray->AddTrayItem(test_item); 451 tray->AddTrayItem(test_item);
442 452
443 std::unique_ptr<views::Widget> widget(CreateTestWidget( 453 std::unique_ptr<views::Widget> widget(CreateTestWidget(
444 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(0, 0, 100, 100))); 454 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(0, 0, 100, 100)));
445 455
446 // Tests for usual default view while activating a window. 456 // Tests for usual default view while activating a window.
447 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 457 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
458 tray->ActivateBubble();
448 ASSERT_TRUE(tray->HasSystemBubble()); 459 ASSERT_TRUE(tray->HasSystemBubble());
449 widget->Activate(); 460 widget->Activate();
450 base::RunLoop().RunUntilIdle(); 461 base::RunLoop().RunUntilIdle();
451 ASSERT_FALSE(tray->HasSystemBubble()); 462 ASSERT_FALSE(tray->HasSystemBubble());
452 463
453 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 464 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
454 ASSERT_TRUE(tray->HasSystemBubble()); 465 ASSERT_TRUE(tray->HasSystemBubble());
455 { 466 {
456 ui::test::EventGenerator& generator = GetEventGenerator(); 467 ui::test::EventGenerator& generator = GetEventGenerator();
457 generator.set_current_location(gfx::Point(5, 5)); 468 generator.set_current_location(gfx::Point(5, 5));
458 generator.ClickLeftButton(); 469 generator.ClickLeftButton();
459 ASSERT_FALSE(tray->HasSystemBubble()); 470 ASSERT_FALSE(tray->HasSystemBubble());
460 } 471 }
461 472
462 // Same tests for persistent default view. 473 // Same tests for persistent default view.
463 tray->ShowPersistentDefaultView(); 474 tray->ShowPersistentDefaultView();
464 ASSERT_TRUE(tray->HasSystemBubble()); 475 ASSERT_TRUE(tray->HasSystemBubble());
465 widget->Activate(); 476 widget->Activate();
466 base::RunLoop().RunUntilIdle(); 477 base::RunLoop().RunUntilIdle();
467 ASSERT_TRUE(tray->HasSystemBubble()); 478 ASSERT_TRUE(tray->HasSystemBubble());
468 479
469 { 480 {
470 ui::test::EventGenerator& generator = GetEventGenerator(); 481 ui::test::EventGenerator& generator = GetEventGenerator();
471 generator.set_current_location(gfx::Point(5, 5)); 482 generator.set_current_location(gfx::Point(5, 5));
472 generator.ClickLeftButton(); 483 generator.ClickLeftButton();
473 ASSERT_TRUE(tray->HasSystemBubble()); 484 ASSERT_TRUE(tray->HasSystemBubble());
474 } 485 }
486
487 // Same tests for persistent default view with activation.
488 tray->ShowPersistentDefaultView();
489 ASSERT_TRUE(tray->HasSystemBubble());
James Cook 2016/09/22 21:17:17 These should all be EXPECT_TRUE (the old test code
oshima 2016/09/23 09:37:20 Yes, I noticed that. I tried to change them all, b
490 widget->Activate();
491 base::RunLoop().RunUntilIdle();
492 ASSERT_TRUE(tray->HasSystemBubble());
493
494 {
James Cook 2016/09/22 21:17:17 no need for block scope here (or elsewhere in this
oshima 2016/09/23 09:37:20 Let me fix elsewhere in another CL.
495 ui::test::EventGenerator& generator = GetEventGenerator();
496 generator.set_current_location(gfx::Point(5, 5));
497 generator.ClickLeftButton();
498 ASSERT_TRUE(tray->HasSystemBubble());
499 }
475 } 500 }
476 501
477 #if defined(OS_CHROMEOS) 502 #if defined(OS_CHROMEOS)
478 // Accessibility/Settings tray items are available only on cros. 503 // Accessibility/Settings tray items are available only on cros.
479 #define MAYBE_WithSystemModal WithSystemModal 504 #define MAYBE_WithSystemModal WithSystemModal
480 #else 505 #else
481 #define MAYBE_WithSystemModal DISABLED_WithSystemModal 506 #define MAYBE_WithSystemModal DISABLED_WithSystemModal
482 #endif 507 #endif
483 TEST_F(SystemTrayTest, MAYBE_WithSystemModal) { 508 TEST_F(SystemTrayTest, MAYBE_WithSystemModal) {
484 // Check if the accessibility item is created even with system modal dialog. 509 // Check if the accessibility item is created even with system modal dialog.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 // Hide the default view, ensure the tray bubble height is back to zero. 624 // Hide the default view, ensure the tray bubble height is back to zero.
600 ASSERT_TRUE(tray->CloseSystemBubble()); 625 ASSERT_TRUE(tray->CloseSystemBubble());
601 RunAllPendingInMessageLoop(); 626 RunAllPendingInMessageLoop();
602 627
603 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); 628 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test());
604 } 629 }
605 #endif // OS_CHROMEOS 630 #endif // OS_CHROMEOS
606 631
607 } // namespace test 632 } // namespace test
608 } // namespace ash 633 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698