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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 ~ModalWidgetDelegate() override {} | 53 ~ModalWidgetDelegate() override {} |
| 54 | 54 |
| 55 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_SYSTEM; } | 55 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_SYSTEM; } |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); | 58 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace | 61 } // namespace |
| 62 | 62 |
| 63 typedef AshTestBase SystemTrayTest; | 63 class SystemTrayTest : public AshTestBase { |
| 64 public: | |
| 65 SystemTrayTest() {} | |
| 66 ~SystemTrayTest() override {} | |
| 67 | |
| 68 bool AreTraysInitialized(StatusAreaWidget* widget) { | |
|
varkha
2016/12/09 00:59:03
nit: I think this could be IsWidgetInitialized().
yiyix
2016/12/09 20:04:53
Done.
| |
| 69 return widget->is_initialized_; | |
| 70 } | |
| 71 | |
| 72 private: | |
| 73 DISALLOW_COPY_AND_ASSIGN(SystemTrayTest); | |
| 74 }; | |
| 64 | 75 |
| 65 // Verifies only the visible default views are recorded in the | 76 // Verifies only the visible default views are recorded in the |
| 66 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. | 77 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. |
| 67 TEST_F(SystemTrayTest, OnlyVisibleItemsRecorded) { | 78 TEST_F(SystemTrayTest, OnlyVisibleItemsRecorded) { |
| 68 SystemTray* tray = GetPrimarySystemTray(); | 79 SystemTray* tray = GetPrimarySystemTray(); |
| 69 ASSERT_TRUE(tray->GetWidget()); | 80 ASSERT_TRUE(tray->GetWidget()); |
| 70 | 81 |
| 71 TestSystemTrayItem* test_item = new TestSystemTrayItem(); | 82 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
| 72 tray->AddTrayItem(test_item); | 83 tray->AddTrayItem(test_item); |
| 73 | 84 |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 668 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 658 RunAllPendingInMessageLoop(); | 669 RunAllPendingInMessageLoop(); |
| 659 EXPECT_LT(0, notification_tray->tray_bubble_height_for_test()); | 670 EXPECT_LT(0, notification_tray->tray_bubble_height_for_test()); |
| 660 | 671 |
| 661 // Hide the default view, ensure the tray bubble height is back to zero. | 672 // Hide the default view, ensure the tray bubble height is back to zero. |
| 662 ASSERT_TRUE(tray->CloseSystemBubble()); | 673 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 663 RunAllPendingInMessageLoop(); | 674 RunAllPendingInMessageLoop(); |
| 664 | 675 |
| 665 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); | 676 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); |
| 666 } | 677 } |
| 678 | |
| 679 // Calling OnVisibilityChange on uninitialized |tray| caused crashes, see | |
|
varkha
2016/12/09 00:59:03
nit: s/uninitialized |tray|/StatusAreaWidget that
yiyix
2016/12/09 20:04:53
I was not sure how to describe StatusAreaWidget th
| |
| 680 // crbug.com/671293. Test if crash is mitigated. | |
| 681 TEST_F(SystemTrayTest, SystemTrayInitialization) { | |
|
varkha
2016/12/09 00:59:03
Thanks for putting this together.
yiyix
2016/12/09 20:04:53
:D
| |
| 682 StatusAreaWidget* widget = StatusAreaWidgetTestHelper::GetStatusAreaWidget(); | |
| 683 WebNotificationTray* notification_tray = | |
| 684 StatusAreaWidgetTestHelper::GetStatusAreaWidget() | |
| 685 ->web_notification_tray(); | |
|
varkha
2016/12/09 00:59:03
nit: can move this down close to the place you use
yiyix
2016/12/09 20:04:53
Done.
| |
| 686 EXPECT_TRUE(AreTraysInitialized(widget)); | |
| 687 widget->Shutdown(); | |
| 688 EXPECT_FALSE(AreTraysInitialized(widget)); | |
| 689 widget->OnTrayVisibilityChanged(notification_tray); | |
| 690 | |
| 691 widget->CreateTrayViews(); | |
| 692 EXPECT_TRUE(AreTraysInitialized(widget)); | |
| 693 widget->OnTrayVisibilityChanged(notification_tray); | |
| 694 } | |
| 667 #endif // OS_CHROMEOS | 695 #endif // OS_CHROMEOS |
| 668 | 696 |
| 669 } // namespace test | 697 } // namespace test |
| 670 } // namespace ash | 698 } // namespace ash |
| OLD | NEW |