Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 17 matching lines...) Expand all Loading... | |
| 28 #include "base/test/histogram_tester.h" | 28 #include "base/test/histogram_tester.h" |
| 29 #include "ui/base/ui_base_types.h" | 29 #include "ui/base/ui_base_types.h" |
| 30 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 30 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 31 #include "ui/events/test/event_generator.h" | 31 #include "ui/events/test/event_generator.h" |
| 32 #include "ui/gfx/geometry/point.h" | 32 #include "ui/gfx/geometry/point.h" |
| 33 #include "ui/gfx/geometry/rect.h" | 33 #include "ui/gfx/geometry/rect.h" |
| 34 #include "ui/views/view.h" | 34 #include "ui/views/view.h" |
| 35 #include "ui/views/widget/widget.h" | 35 #include "ui/views/widget/widget.h" |
| 36 #include "ui/views/widget/widget_delegate.h" | 36 #include "ui/views/widget/widget_delegate.h" |
| 37 | 37 |
| 38 #if defined(OS_WIN) | |
| 39 #include "base/win/windows_version.h" | |
| 40 #endif | |
| 41 | |
| 42 namespace ash { | 38 namespace ash { |
| 43 namespace test { | 39 namespace test { |
| 44 | 40 |
| 45 namespace { | 41 namespace { |
| 46 | 42 |
| 47 const char kVisibleRowsHistogramName[] = | 43 const char kVisibleRowsHistogramName[] = |
| 48 "Ash.SystemMenu.DefaultView.VisibleRows"; | 44 "Ash.SystemMenu.DefaultView.VisibleRows"; |
| 49 | 45 |
| 50 class ModalWidgetDelegate : public views::WidgetDelegateView { | 46 class ModalWidgetDelegate : public views::WidgetDelegateView { |
| 51 public: | 47 public: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 | 110 |
| 115 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 111 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 116 RunAllPendingInMessageLoop(); | 112 RunAllPendingInMessageLoop(); |
| 117 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName, | 113 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName, |
| 118 SystemTrayItem::UMA_NOT_RECORDED, 0); | 114 SystemTrayItem::UMA_NOT_RECORDED, 0); |
| 119 | 115 |
| 120 ASSERT_TRUE(tray->CloseSystemBubble()); | 116 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 121 RunAllPendingInMessageLoop(); | 117 RunAllPendingInMessageLoop(); |
| 122 } | 118 } |
| 123 | 119 |
| 124 // TODO(bruthig): Re-enable. See https://crbug.com/665960. | |
|
msw
2016/12/14 22:51:00
optional nit: cite # in BUG= (doesn't really matte
James Cook
2016/12/14 23:46:08
Done.
| |
| 125 #if defined(OS_WIN) | |
| 126 #define MAYBE_NullDefaultViewIsNotRecorded DISABLED_NullDefaultViewIsNotRecorded | |
| 127 #else | |
| 128 #define MAYBE_NullDefaultViewIsNotRecorded NullDefaultViewIsNotRecorded | |
| 129 #endif | |
| 130 // Verifies null default views are not recorded in the | 120 // Verifies null default views are not recorded in the |
| 131 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. | 121 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. |
| 132 TEST_F(SystemTrayTest, MAYBE_NullDefaultViewIsNotRecorded) { | 122 TEST_F(SystemTrayTest, NullDefaultViewIsNotRecorded) { |
| 133 SystemTray* tray = GetPrimarySystemTray(); | 123 SystemTray* tray = GetPrimarySystemTray(); |
| 134 ASSERT_TRUE(tray->GetWidget()); | 124 ASSERT_TRUE(tray->GetWidget()); |
| 135 | 125 |
| 136 TestSystemTrayItem* test_item = new TestSystemTrayItem(); | 126 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
| 137 test_item->set_has_views(false); | 127 test_item->set_has_views(false); |
| 138 tray->AddTrayItem(test_item); | 128 tray->AddTrayItem(test_item); |
| 139 | 129 |
| 140 base::HistogramTester histogram_tester; | 130 base::HistogramTester histogram_tester; |
| 141 | 131 |
| 142 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 132 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 ASSERT_TRUE(detailed_item->detailed_view() != NULL); | 374 ASSERT_TRUE(detailed_item->detailed_view() != NULL); |
| 385 ASSERT_TRUE(test_item->notification_view() != NULL); | 375 ASSERT_TRUE(test_item->notification_view() != NULL); |
| 386 | 376 |
| 387 // Hide the detailed view, ensure the notification view still exists. | 377 // Hide the detailed view, ensure the notification view still exists. |
| 388 ASSERT_TRUE(tray->CloseSystemBubble()); | 378 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 389 RunAllPendingInMessageLoop(); | 379 RunAllPendingInMessageLoop(); |
| 390 ASSERT_TRUE(detailed_item->detailed_view() == NULL); | 380 ASSERT_TRUE(detailed_item->detailed_view() == NULL); |
| 391 ASSERT_TRUE(test_item->notification_view() != NULL); | 381 ASSERT_TRUE(test_item->notification_view() != NULL); |
| 392 } | 382 } |
| 393 | 383 |
| 394 // Test is flaky on Win7 and Cros (crbug.com/637978). | 384 // Test is flaky. http://crbug.com/637978 |
| 395 #if defined(OS_CHROMEOS) || defined(OS_WIN) | 385 TEST_F(SystemTrayTest, DISABLED_BubbleCreationTypesTest) { |
| 396 #define MAYBE_BubbleCreationTypesTest DISABLED_BubbleCreationTypesTest | |
| 397 #else | |
| 398 #define MAYBE_BubbleCreationTypesTest BubbleCreationTypesTest | |
| 399 #endif | |
| 400 TEST_F(SystemTrayTest, MAYBE_BubbleCreationTypesTest) { | |
| 401 SystemTray* tray = GetPrimarySystemTray(); | 386 SystemTray* tray = GetPrimarySystemTray(); |
| 402 ASSERT_TRUE(tray->GetWidget()); | 387 ASSERT_TRUE(tray->GetWidget()); |
| 403 | 388 |
| 404 TestSystemTrayItem* test_item = new TestSystemTrayItem(); | 389 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
| 405 tray->AddTrayItem(test_item); | 390 tray->AddTrayItem(test_item); |
| 406 | 391 |
| 407 // Ensure the tray views are created. | 392 // Ensure the tray views are created. |
| 408 ASSERT_TRUE(test_item->tray_view() != NULL); | 393 ASSERT_TRUE(test_item->tray_view() != NULL); |
| 409 | 394 |
| 410 // Show the default view, ensure the notification view is destroyed. | 395 // Show the default view, ensure the notification view is destroyed. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 widget->Activate(); | 501 widget->Activate(); |
| 517 base::RunLoop().RunUntilIdle(); | 502 base::RunLoop().RunUntilIdle(); |
| 518 EXPECT_TRUE(tray->HasSystemBubble()); | 503 EXPECT_TRUE(tray->HasSystemBubble()); |
| 519 | 504 |
| 520 ui::test::EventGenerator& generator = GetEventGenerator(); | 505 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 521 generator.set_current_location(gfx::Point(5, 5)); | 506 generator.set_current_location(gfx::Point(5, 5)); |
| 522 generator.ClickLeftButton(); | 507 generator.ClickLeftButton(); |
| 523 EXPECT_TRUE(tray->HasSystemBubble()); | 508 EXPECT_TRUE(tray->HasSystemBubble()); |
| 524 } | 509 } |
| 525 | 510 |
| 526 #if defined(OS_CHROMEOS) | 511 TEST_F(SystemTrayTest, WithSystemModal) { |
| 527 // Accessibility/Settings tray items are available only on cros. | |
| 528 #define MAYBE_WithSystemModal WithSystemModal | |
| 529 #else | |
| 530 #define MAYBE_WithSystemModal DISABLED_WithSystemModal | |
| 531 #endif | |
| 532 TEST_F(SystemTrayTest, MAYBE_WithSystemModal) { | |
| 533 // Check if the accessibility item is created even with system modal dialog. | 512 // Check if the accessibility item is created even with system modal dialog. |
| 534 WmShell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(true); | 513 WmShell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(true); |
| 535 std::unique_ptr<views::Widget> widget(CreateTestWidget( | 514 std::unique_ptr<views::Widget> widget(CreateTestWidget( |
| 536 new ModalWidgetDelegate, kShellWindowId_SystemModalContainer, | 515 new ModalWidgetDelegate, kShellWindowId_SystemModalContainer, |
| 537 gfx::Rect(0, 0, 100, 100))); | 516 gfx::Rect(0, 0, 100, 100))); |
| 538 | 517 |
| 539 SystemTray* tray = GetPrimarySystemTray(); | 518 SystemTray* tray = GetPrimarySystemTray(); |
| 540 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 519 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 541 | 520 |
| 542 ASSERT_TRUE(tray->HasSystemBubble()); | 521 ASSERT_TRUE(tray->HasSystemBubble()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 EXPECT_TRUE(tray->visible()); | 561 EXPECT_TRUE(tray->visible()); |
| 583 EXPECT_EQ(0.0f, tray->layer()->GetTargetOpacity()); | 562 EXPECT_EQ(0.0f, tray->layer()->GetTargetOpacity()); |
| 584 | 563 |
| 585 tray->SetVisible(true); | 564 tray->SetVisible(true); |
| 586 animation_duration.reset(); | 565 animation_duration.reset(); |
| 587 tray->layer()->GetAnimator()->StopAnimating(); | 566 tray->layer()->GetAnimator()->StopAnimating(); |
| 588 EXPECT_TRUE(tray->visible()); | 567 EXPECT_TRUE(tray->visible()); |
| 589 EXPECT_EQ(1.0f, tray->layer()->GetTargetOpacity()); | 568 EXPECT_EQ(1.0f, tray->layer()->GetTargetOpacity()); |
| 590 } | 569 } |
| 591 | 570 |
| 592 #if defined(OS_CHROMEOS) | |
| 593 // Tests that touch on an item in the system bubble triggers it to become | 571 // Tests that touch on an item in the system bubble triggers it to become |
| 594 // active. | 572 // active. |
| 595 TEST_F(SystemTrayTest, TrayPopupItemContainerTouchFeedback) { | 573 TEST_F(SystemTrayTest, TrayPopupItemContainerTouchFeedback) { |
| 596 // Material design will use the ink drop ripple framework to show | 574 // Material design will use the ink drop ripple framework to show |
| 597 // active states. | 575 // active states. |
| 598 if (MaterialDesignController::IsSystemTrayMenuMaterial()) | 576 if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 599 return; | 577 return; |
| 600 | 578 |
| 601 SystemTray* tray = GetPrimarySystemTray(); | 579 SystemTray* tray = GetPrimarySystemTray(); |
| 602 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 580 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 635 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 658 RunAllPendingInMessageLoop(); | 636 RunAllPendingInMessageLoop(); |
| 659 EXPECT_LT(0, notification_tray->tray_bubble_height_for_test()); | 637 EXPECT_LT(0, notification_tray->tray_bubble_height_for_test()); |
| 660 | 638 |
| 661 // Hide the default view, ensure the tray bubble height is back to zero. | 639 // Hide the default view, ensure the tray bubble height is back to zero. |
| 662 ASSERT_TRUE(tray->CloseSystemBubble()); | 640 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 663 RunAllPendingInMessageLoop(); | 641 RunAllPendingInMessageLoop(); |
| 664 | 642 |
| 665 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); | 643 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); |
| 666 } | 644 } |
| 667 #endif // OS_CHROMEOS | |
| 668 | 645 |
| 669 } // namespace test | 646 } // namespace test |
| 670 } // namespace ash | 647 } // namespace ash |
| OLD | NEW |