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

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

Issue 2557593009: Fix Chrome crashes on calling OnTrayVisibilityChange (Closed)
Patch Set: address comments Created 4 years 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void ShutDownLogoutButtonTray(StatusAreaWidget* widget) {
varkha 2016/12/13 17:34:54 nit: I think we usually prefer Shutdown over ShutD
69 widget->logout_button_tray_ = nullptr;
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
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 StatusAreaWidget that has been Shutdown, see
680 // crbug.com/671293. Test if crash is mitigated.
681 TEST_F(SystemTrayTest, SystemTrayInitialization) {
682 StatusAreaWidget* widget = StatusAreaWidgetTestHelper::GetStatusAreaWidget();
683 ShutDownLogoutButtonTray(widget);
varkha 2016/12/13 17:34:54 I am still confused if the bad scenario is a resul
684 WebNotificationTray* notification_tray = widget->web_notification_tray();
685 widget->OnTrayVisibilityChanged(notification_tray);
686 }
667 #endif // OS_CHROMEOS 687 #endif // OS_CHROMEOS
668 688
669 } // namespace test 689 } // namespace test
670 } // namespace ash 690 } // namespace ash
OLDNEW
« ash/common/system/status_area_widget.cc ('K') | « ash/common/system/status_area_widget.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698