OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signin/signin_error_notifier_ash.h" | 5 #include "chrome/browser/signin/signin_error_notifier_ash.h" |
6 | 6 |
7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/notifications/notification.h" | 10 #include "chrome/browser/notifications/notification.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "ui/gfx/screen.h" | 30 #include "ui/gfx/screen.h" |
31 #include "ui/gfx/screen_type_delegate.h" | 31 #include "ui/gfx/screen_type_delegate.h" |
32 #endif | 32 #endif |
33 | 33 |
34 namespace ash { | 34 namespace ash { |
35 namespace test { | 35 namespace test { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 static const char kTestAccountId[] = "testuser@test.com"; | 39 static const char kTestAccountId[] = "testuser@test.com"; |
| 40 static const char kTestUsername[] = "testuser@test.com"; |
40 | 41 |
41 // Notification ID corresponding to kProfileSigninNotificationId + | 42 // Notification ID corresponding to kProfileSigninNotificationId + |
42 // kTestAccountId. | 43 // kTestAccountId. |
43 static const std::string kNotificationId = | 44 static const std::string kNotificationId = |
44 "chrome://settings/signin/testuser@test.com"; | 45 "chrome://settings/signin/testuser@test.com"; |
45 } | 46 } |
46 | 47 |
47 #if !defined(OS_CHROMEOS) | 48 #if !defined(OS_CHROMEOS) |
48 class ScreenTypeDelegateDesktop : public gfx::ScreenTypeDelegate { | 49 class ScreenTypeDelegateDesktop : public gfx::ScreenTypeDelegate { |
49 public: | 50 public: |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 122 } |
122 | 123 |
123 #if !defined(OS_WIN) | 124 #if !defined(OS_WIN) |
124 // Disabled on Win due to flake. http://crbug.com/372236 | 125 // Disabled on Win due to flake. http://crbug.com/372236 |
125 TEST_F(SigninErrorNotifierTest, ErrorAuthStatusProvider) { | 126 TEST_F(SigninErrorNotifierTest, ErrorAuthStatusProvider) { |
126 { | 127 { |
127 FakeAuthStatusProvider provider(error_controller_); | 128 FakeAuthStatusProvider provider(error_controller_); |
128 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); | 129 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); |
129 { | 130 { |
130 FakeAuthStatusProvider error_provider(error_controller_); | 131 FakeAuthStatusProvider error_provider(error_controller_); |
131 error_provider.SetAuthError(kTestAccountId, GoogleServiceAuthError( | 132 error_provider.SetAuthError( |
132 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); | 133 kTestAccountId, |
| 134 kTestUsername, |
| 135 GoogleServiceAuthError( |
| 136 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); |
133 ASSERT_TRUE(notification_ui_manager_->FindById(kNotificationId)); | 137 ASSERT_TRUE(notification_ui_manager_->FindById(kNotificationId)); |
134 } | 138 } |
135 // error_provider is removed now that we've left that scope. | 139 // error_provider is removed now that we've left that scope. |
136 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); | 140 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); |
137 } | 141 } |
138 // All providers should be removed now. | 142 // All providers should be removed now. |
139 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); | 143 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); |
140 } | 144 } |
141 #endif | 145 #endif |
142 | 146 |
143 #if defined(OS_WIN) | 147 #if defined(OS_WIN) |
144 // Test started crashing on Win 7. http://crbug.com/372277 | 148 // Test started crashing on Win 7. http://crbug.com/372277 |
145 #define MAYBE_AuthStatusProviderErrorTransition \ | 149 #define MAYBE_AuthStatusProviderErrorTransition \ |
146 DISABLED_AuthStatusProviderErrorTransition | 150 DISABLED_AuthStatusProviderErrorTransition |
147 #else | 151 #else |
148 #define MAYBE_AuthStatusProviderErrorTransition \ | 152 #define MAYBE_AuthStatusProviderErrorTransition \ |
149 AuthStatusProviderErrorTransition | 153 AuthStatusProviderErrorTransition |
150 #endif | 154 #endif |
151 TEST_F(SigninErrorNotifierTest, MAYBE_AuthStatusProviderErrorTransition) { | 155 TEST_F(SigninErrorNotifierTest, MAYBE_AuthStatusProviderErrorTransition) { |
152 { | 156 { |
153 FakeAuthStatusProvider provider0(error_controller_); | 157 FakeAuthStatusProvider provider0(error_controller_); |
154 FakeAuthStatusProvider provider1(error_controller_); | 158 FakeAuthStatusProvider provider1(error_controller_); |
155 provider0.SetAuthError( | 159 provider0.SetAuthError( |
156 kTestAccountId, | 160 kTestAccountId, |
| 161 kTestUsername, |
157 GoogleServiceAuthError( | 162 GoogleServiceAuthError( |
158 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); | 163 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); |
159 ASSERT_TRUE(notification_ui_manager_->FindById(kNotificationId)); | 164 ASSERT_TRUE(notification_ui_manager_->FindById(kNotificationId)); |
160 | 165 |
161 base::string16 message; | 166 base::string16 message; |
162 GetMessage(&message); | 167 GetMessage(&message); |
163 ASSERT_FALSE(message.empty()); | 168 ASSERT_FALSE(message.empty()); |
164 | 169 |
165 // Now set another auth error and clear the original. | 170 // Now set another auth error and clear the original. |
166 provider1.SetAuthError( | 171 provider1.SetAuthError( |
167 kTestAccountId, | 172 kTestAccountId, |
| 173 kTestUsername, |
168 GoogleServiceAuthError( | 174 GoogleServiceAuthError( |
169 GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE)); | 175 GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE)); |
170 provider0.SetAuthError( | 176 provider0.SetAuthError( |
171 kTestAccountId, GoogleServiceAuthError::AuthErrorNone()); | 177 kTestAccountId, |
| 178 kTestUsername, |
| 179 GoogleServiceAuthError::AuthErrorNone()); |
172 | 180 |
173 ASSERT_TRUE(notification_ui_manager_->FindById(kNotificationId)); | 181 ASSERT_TRUE(notification_ui_manager_->FindById(kNotificationId)); |
174 | 182 |
175 base::string16 new_message; | 183 base::string16 new_message; |
176 GetMessage(&new_message); | 184 GetMessage(&new_message); |
177 ASSERT_FALSE(new_message.empty()); | 185 ASSERT_FALSE(new_message.empty()); |
178 | 186 |
179 ASSERT_NE(new_message, message); | 187 ASSERT_NE(new_message, message); |
180 | 188 |
181 provider1.SetAuthError( | 189 provider1.SetAuthError( |
182 kTestAccountId, GoogleServiceAuthError::AuthErrorNone()); | 190 kTestAccountId, kTestUsername, GoogleServiceAuthError::AuthErrorNone()); |
183 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); | 191 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); |
184 } | 192 } |
185 } | 193 } |
186 | 194 |
187 #if !defined(OS_WIN) | 195 #if !defined(OS_WIN) |
188 // Disabled on Win due to flake. http://crbug.com/372236 | 196 // Disabled on Win due to flake. http://crbug.com/372236 |
189 // Verify that SigninErrorNotifier ignores certain errors. | 197 // Verify that SigninErrorNotifier ignores certain errors. |
190 TEST_F(SigninErrorNotifierTest, AuthStatusEnumerateAllErrors) { | 198 TEST_F(SigninErrorNotifierTest, AuthStatusEnumerateAllErrors) { |
191 typedef struct { | 199 typedef struct { |
192 GoogleServiceAuthError::State error_state; | 200 GoogleServiceAuthError::State error_state; |
(...skipping 14 matching lines...) Expand all Loading... |
207 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, | 215 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, |
208 { GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE, true }, | 216 { GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE, true }, |
209 { GoogleServiceAuthError::SERVICE_ERROR, true }, | 217 { GoogleServiceAuthError::SERVICE_ERROR, true }, |
210 }; | 218 }; |
211 COMPILE_ASSERT(ARRAYSIZE_UNSAFE(table) == GoogleServiceAuthError::NUM_STATES, | 219 COMPILE_ASSERT(ARRAYSIZE_UNSAFE(table) == GoogleServiceAuthError::NUM_STATES, |
212 kTable_size_does_not_match_number_of_auth_error_types); | 220 kTable_size_does_not_match_number_of_auth_error_types); |
213 | 221 |
214 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(table); ++i) { | 222 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(table); ++i) { |
215 FakeAuthStatusProvider provider(error_controller_); | 223 FakeAuthStatusProvider provider(error_controller_); |
216 provider.SetAuthError(kTestAccountId, | 224 provider.SetAuthError(kTestAccountId, |
| 225 kTestUsername, |
217 GoogleServiceAuthError(table[i].error_state)); | 226 GoogleServiceAuthError(table[i].error_state)); |
218 const Notification* notification = notification_ui_manager_-> | 227 const Notification* notification = notification_ui_manager_-> |
219 FindById(kNotificationId); | 228 FindById(kNotificationId); |
220 ASSERT_EQ(table[i].is_error, notification != NULL); | 229 ASSERT_EQ(table[i].is_error, notification != NULL); |
221 if (table[i].is_error) { | 230 if (table[i].is_error) { |
222 EXPECT_FALSE(notification->title().empty()); | 231 EXPECT_FALSE(notification->title().empty()); |
223 EXPECT_FALSE(notification->message().empty()); | 232 EXPECT_FALSE(notification->message().empty()); |
224 EXPECT_EQ((size_t)1, notification->buttons().size()); | 233 EXPECT_EQ((size_t)1, notification->buttons().size()); |
225 } | 234 } |
226 } | 235 } |
227 } | 236 } |
228 #endif | 237 #endif |
229 | 238 |
230 } // namespace test | 239 } // namespace test |
231 } // namespace ash | 240 } // namespace ash |
OLD | NEW |