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 "chrome/browser/chromeos/extensions/file_browser_notifications.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_notifications.h" |
6 | 6 |
7 #include <gtest/gtest.h> | 7 #include <gtest/gtest.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 IN_PROC_BROWSER_TEST_F(FileBrowserNotificationsTest, ShowDelayedTest) { | 70 IN_PROC_BROWSER_TEST_F(FileBrowserNotificationsTest, ShowDelayedTest) { |
71 InitNotifications(); | 71 InitNotifications(); |
72 // Adding a delayed notification does not create a notification. | 72 // Adding a delayed notification does not create a notification. |
73 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE, | 73 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE, |
74 "path", | 74 "path", |
75 base::TimeDelta::FromSeconds(0)); | 75 base::TimeDelta::FromSeconds(0)); |
76 EXPECT_EQ(0u, notifications_->GetNotificationCountForTest()); | 76 EXPECT_EQ(0u, notifications_->GetNotificationCountForTest()); |
77 EXPECT_FALSE(FindNotification("Dpath")); | 77 EXPECT_FALSE(FindNotification("Dpath")); |
78 | 78 |
79 // Running the message loop should create the notification. | 79 // Running the message loop should create the notification. |
80 ui_test_utils::RunAllPendingInMessageLoop(); | 80 content::RunAllPendingInMessageLoop(); |
81 EXPECT_EQ(1u, notifications_->GetNotificationCountForTest()); | 81 EXPECT_EQ(1u, notifications_->GetNotificationCountForTest()); |
82 EXPECT_TRUE(FindNotification("Dpath")); | 82 EXPECT_TRUE(FindNotification("Dpath")); |
83 | 83 |
84 // Showing a notification both immediately and delayed results in one | 84 // Showing a notification both immediately and delayed results in one |
85 // additional notification. | 85 // additional notification. |
86 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE_FAIL, | 86 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE_FAIL, |
87 "path", | 87 "path", |
88 base::TimeDelta::FromSeconds(0)); | 88 base::TimeDelta::FromSeconds(0)); |
89 notifications_->ShowNotification(FileBrowserNotifications::DEVICE_FAIL, | 89 notifications_->ShowNotification(FileBrowserNotifications::DEVICE_FAIL, |
90 "path"); | 90 "path"); |
91 EXPECT_EQ(2u, notifications_->GetNotificationCountForTest()); | 91 EXPECT_EQ(2u, notifications_->GetNotificationCountForTest()); |
92 EXPECT_TRUE(FindNotification("DFpath")); | 92 EXPECT_TRUE(FindNotification("DFpath")); |
93 | 93 |
94 // When the delayed notification is processed, it's an update, so we still | 94 // When the delayed notification is processed, it's an update, so we still |
95 // only have two notifications. | 95 // only have two notifications. |
96 ui_test_utils::RunAllPendingInMessageLoop(); | 96 content::RunAllPendingInMessageLoop(); |
97 EXPECT_EQ(2u, notifications_->GetNotificationCountForTest()); | 97 EXPECT_EQ(2u, notifications_->GetNotificationCountForTest()); |
98 EXPECT_TRUE(FindNotification("DFpath")); | 98 EXPECT_TRUE(FindNotification("DFpath")); |
99 | 99 |
100 // If we schedule a show for later, then hide before it becomes visible, | 100 // If we schedule a show for later, then hide before it becomes visible, |
101 // the notification should not be added. | 101 // the notification should not be added. |
102 notifications_->ShowNotificationDelayed(FileBrowserNotifications::FORMAT_FAIL, | 102 notifications_->ShowNotificationDelayed(FileBrowserNotifications::FORMAT_FAIL, |
103 "path", | 103 "path", |
104 base::TimeDelta::FromSeconds(0)); | 104 base::TimeDelta::FromSeconds(0)); |
105 notifications_->HideNotification(FileBrowserNotifications::FORMAT_FAIL, | 105 notifications_->HideNotification(FileBrowserNotifications::FORMAT_FAIL, |
106 "path"); | 106 "path"); |
107 EXPECT_EQ(2u, notifications_->GetNotificationCountForTest()); | 107 EXPECT_EQ(2u, notifications_->GetNotificationCountForTest()); |
108 EXPECT_TRUE(FindNotification("Dpath")); | 108 EXPECT_TRUE(FindNotification("Dpath")); |
109 EXPECT_TRUE(FindNotification("DFpath")); | 109 EXPECT_TRUE(FindNotification("DFpath")); |
110 EXPECT_FALSE(FindNotification("Fpath")); | 110 EXPECT_FALSE(FindNotification("Fpath")); |
111 | 111 |
112 // Even after processing messages, no new notification should be added. | 112 // Even after processing messages, no new notification should be added. |
113 ui_test_utils::RunAllPendingInMessageLoop(); | 113 content::RunAllPendingInMessageLoop(); |
114 EXPECT_EQ(2u, notifications_->GetNotificationCountForTest()); | 114 EXPECT_EQ(2u, notifications_->GetNotificationCountForTest()); |
115 EXPECT_TRUE(FindNotification("Dpath")); | 115 EXPECT_TRUE(FindNotification("Dpath")); |
116 EXPECT_TRUE(FindNotification("DFpath")); | 116 EXPECT_TRUE(FindNotification("DFpath")); |
117 EXPECT_FALSE(FindNotification("Fpath")); | 117 EXPECT_FALSE(FindNotification("Fpath")); |
118 } | 118 } |
119 | 119 |
120 IN_PROC_BROWSER_TEST_F(FileBrowserNotificationsTest, HideDelayedTest) { | 120 IN_PROC_BROWSER_TEST_F(FileBrowserNotificationsTest, HideDelayedTest) { |
121 InitNotifications(); | 121 InitNotifications(); |
122 // Showing now, and scheduling a hide for later, results in one notification. | 122 // Showing now, and scheduling a hide for later, results in one notification. |
123 notifications_->ShowNotification(FileBrowserNotifications::DEVICE, "path"); | 123 notifications_->ShowNotification(FileBrowserNotifications::DEVICE, "path"); |
124 notifications_->HideNotificationDelayed(FileBrowserNotifications::DEVICE, | 124 notifications_->HideNotificationDelayed(FileBrowserNotifications::DEVICE, |
125 "path", | 125 "path", |
126 base::TimeDelta::FromSeconds(0)); | 126 base::TimeDelta::FromSeconds(0)); |
127 EXPECT_EQ(1u, notifications_->GetNotificationCountForTest()); | 127 EXPECT_EQ(1u, notifications_->GetNotificationCountForTest()); |
128 EXPECT_TRUE(FindNotification("Dpath")); | 128 EXPECT_TRUE(FindNotification("Dpath")); |
129 | 129 |
130 // Running pending messges should remove the notification. | 130 // Running pending messges should remove the notification. |
131 ui_test_utils::RunAllPendingInMessageLoop(); | 131 content::RunAllPendingInMessageLoop(); |
132 EXPECT_EQ(0u, notifications_->GetNotificationCountForTest()); | 132 EXPECT_EQ(0u, notifications_->GetNotificationCountForTest()); |
133 | 133 |
134 // Immediate show then hide results in no notification. | 134 // Immediate show then hide results in no notification. |
135 notifications_->ShowNotification(FileBrowserNotifications::DEVICE_FAIL, | 135 notifications_->ShowNotification(FileBrowserNotifications::DEVICE_FAIL, |
136 "path"); | 136 "path"); |
137 notifications_->HideNotification(FileBrowserNotifications::DEVICE_FAIL, | 137 notifications_->HideNotification(FileBrowserNotifications::DEVICE_FAIL, |
138 "path"); | 138 "path"); |
139 ui_test_utils::RunAllPendingInMessageLoop(); | 139 content::RunAllPendingInMessageLoop(); |
140 EXPECT_EQ(0u, notifications_->GetNotificationCountForTest()); | 140 EXPECT_EQ(0u, notifications_->GetNotificationCountForTest()); |
141 | 141 |
142 // Delayed hide for a notification that doesn't exist does nothing. | 142 // Delayed hide for a notification that doesn't exist does nothing. |
143 notifications_->HideNotificationDelayed(FileBrowserNotifications::DEVICE_FAIL, | 143 notifications_->HideNotificationDelayed(FileBrowserNotifications::DEVICE_FAIL, |
144 "path", | 144 "path", |
145 base::TimeDelta::FromSeconds(0)); | 145 base::TimeDelta::FromSeconds(0)); |
146 ui_test_utils::RunAllPendingInMessageLoop(); | 146 content::RunAllPendingInMessageLoop(); |
147 EXPECT_EQ(0u, notifications_->GetNotificationCountForTest()); | 147 EXPECT_EQ(0u, notifications_->GetNotificationCountForTest()); |
148 } | 148 } |
149 | 149 |
150 } // namespace chromeos. | 150 } // namespace chromeos. |
OLD | NEW |