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

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

Issue 11428100: Add NULL check in SystemTray::ShowDetailedView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a test. Created 8 years, 1 month 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
« no previous file with comments | « ash/system/tray/system_tray.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/system_tray_unittest.cc
diff --git a/ash/system/tray/system_tray_unittest.cc b/ash/system/tray/system_tray_unittest.cc
index 3a6c377c06720a2943a6103725b16f88845f39d6..e80aeae3a4c4042f209da6fffd4a1b12a6ec158e 100644
--- a/ash/system/tray/system_tray_unittest.cc
+++ b/ash/system/tray/system_tray_unittest.cc
@@ -89,6 +89,37 @@ class TestItem : public SystemTrayItem {
views::View* notification_view_;
};
+// Trivial item implementation that returns NULL from tray/default/detailed view
+// creation methods.
+class TestNoViewItem : public SystemTrayItem {
+ public:
+ TestNoViewItem() : SystemTrayItem(GetSystemTray()) {}
+
+ virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE {
+ return NULL;
+ }
+
+ virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE {
+ return NULL;
+ }
+
+ virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE {
+ return NULL;
+ }
+
+ virtual views::View* CreateNotificationView(
+ user::LoginStatus status) OVERRIDE {
+ return NULL;
+ }
+
+ virtual void DestroyTrayView() OVERRIDE {}
+ virtual void DestroyDefaultView() OVERRIDE {}
+ virtual void DestroyDetailedView() OVERRIDE {}
+ virtual void DestroyNotificationView() OVERRIDE {}
+ virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE {
+ }
+};
+
} // namespace
typedef AshTestBase SystemTrayTest;
@@ -136,6 +167,18 @@ TEST_F(SystemTrayTest, SystemTrayTestItems) {
ASSERT_TRUE(detailed_item->detailed_view() == NULL);
}
+TEST_F(SystemTrayTest, SystemTrayNoViewItems) {
+ SystemTray* tray = GetSystemTray();
+ ASSERT_TRUE(tray->GetWidget());
+
+ // Verify that no crashes occur on items lacking some views.
+ TestNoViewItem* no_view_item = new TestNoViewItem;
+ tray->AddTrayItem(no_view_item);
+ tray->ShowDefaultView(BUBBLE_CREATE_NEW);
+ tray->ShowDetailedView(no_view_item, 0, false, BUBBLE_USE_EXISTING);
+ RunAllPendingInMessageLoop();
+}
+
TEST_F(SystemTrayTest, TrayWidgetAutoResizes) {
SystemTray* tray = GetSystemTray();
ASSERT_TRUE(tray->GetWidget());
« no previous file with comments | « ash/system/tray/system_tray.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698