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

Side by Side Diff: chrome/browser/signin/signin_error_notifier_ash_unittest.cc

Issue 1094103005: Profile chooser on mac was passing wrong value to signin error controller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 5 years, 7 months 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 unified diff | Download patch
OLDNEW
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 18 matching lines...) Expand all
29 #include "ui/gfx/screen.h" 29 #include "ui/gfx/screen.h"
30 #include "ui/gfx/screen_type_delegate.h" 30 #include "ui/gfx/screen_type_delegate.h"
31 #endif 31 #endif
32 32
33 namespace ash { 33 namespace ash {
34 namespace test { 34 namespace test {
35 35
36 namespace { 36 namespace {
37 37
38 static const char kTestAccountId[] = "testuser@test.com"; 38 static const char kTestAccountId[] = "testuser@test.com";
39 static const char kTestUsername[] = "testuser@test.com";
40 39
41 // Notification ID corresponding to kProfileSigninNotificationId + 40 // Notification ID corresponding to kProfileSigninNotificationId +
42 // kTestAccountId. 41 // kTestAccountId.
43 static const std::string kNotificationId = 42 static const std::string kNotificationId =
44 "chrome://settings/signin/testuser@test.com"; 43 "chrome://settings/signin/testuser@test.com";
45 } 44 }
46 45
47 #if defined(OS_WIN) 46 #if defined(OS_WIN)
48 class ScreenTypeDelegateDesktop : public gfx::ScreenTypeDelegate { 47 class ScreenTypeDelegateDesktop : public gfx::ScreenTypeDelegate {
49 public: 48 public:
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // Disabled on Win due to flake. http://crbug.com/372236 135 // Disabled on Win due to flake. http://crbug.com/372236
137 TEST_F(SigninErrorNotifierTest, ErrorAuthStatusProvider) { 136 TEST_F(SigninErrorNotifierTest, ErrorAuthStatusProvider) {
138 { 137 {
139 FakeAuthStatusProvider provider(error_controller_); 138 FakeAuthStatusProvider provider(error_controller_);
140 ASSERT_FALSE(notification_ui_manager_->FindById( 139 ASSERT_FALSE(notification_ui_manager_->FindById(
141 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); 140 kNotificationId, NotificationUIManager::GetProfileID(profile_.get())));
142 { 141 {
143 FakeAuthStatusProvider error_provider(error_controller_); 142 FakeAuthStatusProvider error_provider(error_controller_);
144 error_provider.SetAuthError( 143 error_provider.SetAuthError(
145 kTestAccountId, 144 kTestAccountId,
146 kTestUsername,
147 GoogleServiceAuthError( 145 GoogleServiceAuthError(
148 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); 146 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
149 ASSERT_TRUE(notification_ui_manager_->FindById( 147 ASSERT_TRUE(notification_ui_manager_->FindById(
150 kNotificationId, 148 kNotificationId,
151 NotificationUIManager::GetProfileID(profile_.get()))); 149 NotificationUIManager::GetProfileID(profile_.get())));
152 } 150 }
153 // error_provider is removed now that we've left that scope. 151 // error_provider is removed now that we've left that scope.
154 ASSERT_FALSE(notification_ui_manager_->FindById( 152 ASSERT_FALSE(notification_ui_manager_->FindById(
155 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); 153 kNotificationId, NotificationUIManager::GetProfileID(profile_.get())));
156 } 154 }
(...skipping 10 matching lines...) Expand all
167 #else 165 #else
168 #define MAYBE_AuthStatusProviderErrorTransition \ 166 #define MAYBE_AuthStatusProviderErrorTransition \
169 AuthStatusProviderErrorTransition 167 AuthStatusProviderErrorTransition
170 #endif 168 #endif
171 TEST_F(SigninErrorNotifierTest, MAYBE_AuthStatusProviderErrorTransition) { 169 TEST_F(SigninErrorNotifierTest, MAYBE_AuthStatusProviderErrorTransition) {
172 { 170 {
173 FakeAuthStatusProvider provider0(error_controller_); 171 FakeAuthStatusProvider provider0(error_controller_);
174 FakeAuthStatusProvider provider1(error_controller_); 172 FakeAuthStatusProvider provider1(error_controller_);
175 provider0.SetAuthError( 173 provider0.SetAuthError(
176 kTestAccountId, 174 kTestAccountId,
177 kTestUsername,
178 GoogleServiceAuthError( 175 GoogleServiceAuthError(
179 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); 176 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
180 ASSERT_TRUE(notification_ui_manager_->FindById( 177 ASSERT_TRUE(notification_ui_manager_->FindById(
181 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); 178 kNotificationId, NotificationUIManager::GetProfileID(profile_.get())));
182 179
183 base::string16 message; 180 base::string16 message;
184 GetMessage(&message); 181 GetMessage(&message);
185 ASSERT_FALSE(message.empty()); 182 ASSERT_FALSE(message.empty());
186 183
187 // Now set another auth error and clear the original. 184 // Now set another auth error and clear the original.
188 provider1.SetAuthError( 185 provider1.SetAuthError(
189 kTestAccountId, 186 kTestAccountId,
190 kTestUsername,
191 GoogleServiceAuthError( 187 GoogleServiceAuthError(
192 GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE)); 188 GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE));
193 provider0.SetAuthError( 189 provider0.SetAuthError(
194 kTestAccountId, 190 kTestAccountId,
195 kTestUsername,
196 GoogleServiceAuthError::AuthErrorNone()); 191 GoogleServiceAuthError::AuthErrorNone());
197 192
198 ASSERT_TRUE(notification_ui_manager_->FindById( 193 ASSERT_TRUE(notification_ui_manager_->FindById(
199 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); 194 kNotificationId, NotificationUIManager::GetProfileID(profile_.get())));
200 195
201 base::string16 new_message; 196 base::string16 new_message;
202 GetMessage(&new_message); 197 GetMessage(&new_message);
203 ASSERT_FALSE(new_message.empty()); 198 ASSERT_FALSE(new_message.empty());
204 199
205 ASSERT_NE(new_message, message); 200 ASSERT_NE(new_message, message);
206 201
207 provider1.SetAuthError( 202 provider1.SetAuthError(
208 kTestAccountId, kTestUsername, GoogleServiceAuthError::AuthErrorNone()); 203 kTestAccountId, GoogleServiceAuthError::AuthErrorNone());
209 ASSERT_FALSE(notification_ui_manager_->FindById( 204 ASSERT_FALSE(notification_ui_manager_->FindById(
210 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); 205 kNotificationId, NotificationUIManager::GetProfileID(profile_.get())));
211 } 206 }
212 } 207 }
213 208
214 #if !defined(OS_WIN) 209 #if !defined(OS_WIN)
215 // Disabled on Win due to flake. http://crbug.com/372236 210 // Disabled on Win due to flake. http://crbug.com/372236
216 // Verify that SigninErrorNotifier ignores certain errors. 211 // Verify that SigninErrorNotifier ignores certain errors.
217 TEST_F(SigninErrorNotifierTest, AuthStatusEnumerateAllErrors) { 212 TEST_F(SigninErrorNotifierTest, AuthStatusEnumerateAllErrors) {
218 typedef struct { 213 typedef struct {
(...skipping 16 matching lines...) Expand all
235 { GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE, true }, 230 { GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE, true },
236 { GoogleServiceAuthError::SERVICE_ERROR, true }, 231 { GoogleServiceAuthError::SERVICE_ERROR, true },
237 { GoogleServiceAuthError::WEB_LOGIN_REQUIRED, true }, 232 { GoogleServiceAuthError::WEB_LOGIN_REQUIRED, true },
238 }; 233 };
239 static_assert(arraysize(table) == GoogleServiceAuthError::NUM_STATES, 234 static_assert(arraysize(table) == GoogleServiceAuthError::NUM_STATES,
240 "table size should match number of auth error types"); 235 "table size should match number of auth error types");
241 236
242 for (size_t i = 0; i < arraysize(table); ++i) { 237 for (size_t i = 0; i < arraysize(table); ++i) {
243 FakeAuthStatusProvider provider(error_controller_); 238 FakeAuthStatusProvider provider(error_controller_);
244 provider.SetAuthError(kTestAccountId, 239 provider.SetAuthError(kTestAccountId,
245 kTestUsername,
246 GoogleServiceAuthError(table[i].error_state)); 240 GoogleServiceAuthError(table[i].error_state));
247 const Notification* notification = notification_ui_manager_->FindById( 241 const Notification* notification = notification_ui_manager_->FindById(
248 kNotificationId, NotificationUIManager::GetProfileID(profile_.get())); 242 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()));
249 ASSERT_EQ(table[i].is_error, notification != NULL); 243 ASSERT_EQ(table[i].is_error, notification != NULL);
250 if (table[i].is_error) { 244 if (table[i].is_error) {
251 EXPECT_FALSE(notification->title().empty()); 245 EXPECT_FALSE(notification->title().empty());
252 EXPECT_FALSE(notification->message().empty()); 246 EXPECT_FALSE(notification->message().empty());
253 EXPECT_EQ((size_t)1, notification->buttons().size()); 247 EXPECT_EQ((size_t)1, notification->buttons().size());
254 } 248 }
255 } 249 }
256 } 250 }
257 #endif 251 #endif
258 252
259 } // namespace test 253 } // namespace test
260 } // namespace ash 254 } // namespace ash
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac_unittest.mm ('k') | chrome/browser/signin/signin_global_error_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698