Index: ash/common/system/tray/system_tray_unittest.cc |
diff --git a/ash/common/system/tray/system_tray_unittest.cc b/ash/common/system/tray/system_tray_unittest.cc |
index 6a9c270fc2058a587173a9288d6ebcbb172f8e0a..0eb232a7e56c0b7e89dd30c73ce826c9b4308239 100644 |
--- a/ash/common/system/tray/system_tray_unittest.cc |
+++ b/ash/common/system/tray/system_tray_unittest.cc |
@@ -60,7 +60,18 @@ class ModalWidgetDelegate : public views::WidgetDelegateView { |
} // namespace |
-typedef AshTestBase SystemTrayTest; |
+class SystemTrayTest : public AshTestBase { |
+ public: |
+ SystemTrayTest() {} |
+ ~SystemTrayTest() override {} |
+ |
+ 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.
|
+ return widget->is_initialized_; |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(SystemTrayTest); |
+}; |
// Verifies only the visible default views are recorded in the |
// "Ash.SystemMenu.DefaultView.VisibleItems" histogram. |
@@ -664,6 +675,23 @@ TEST_F(SystemTrayTest, SystemTrayHeightWithBubble) { |
EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); |
} |
+ |
+// 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
|
+// crbug.com/671293. Test if crash is mitigated. |
+TEST_F(SystemTrayTest, SystemTrayInitialization) { |
varkha
2016/12/09 00:59:03
Thanks for putting this together.
yiyix
2016/12/09 20:04:53
:D
|
+ StatusAreaWidget* widget = StatusAreaWidgetTestHelper::GetStatusAreaWidget(); |
+ WebNotificationTray* notification_tray = |
+ StatusAreaWidgetTestHelper::GetStatusAreaWidget() |
+ ->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.
|
+ EXPECT_TRUE(AreTraysInitialized(widget)); |
+ widget->Shutdown(); |
+ EXPECT_FALSE(AreTraysInitialized(widget)); |
+ widget->OnTrayVisibilityChanged(notification_tray); |
+ |
+ widget->CreateTrayViews(); |
+ EXPECT_TRUE(AreTraysInitialized(widget)); |
+ widget->OnTrayVisibilityChanged(notification_tray); |
+} |
#endif // OS_CHROMEOS |
} // namespace test |