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

Unified Diff: ash/common/system/tray/system_tray_unittest.cc

Issue 2557593009: Fix Chrome crashes on calling OnTrayVisibilityChange (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
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
« 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