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

Side by Side Diff: chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc

Issue 2820823005: Revert of Stop passing raw pointers to base::Value API in c/b/ui (Closed)
Patch Set: Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/webui/signin/sync_confirmation_handler.h" 5 #include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h"
6 6
7 #include "base/memory/ptr_util.h"
8 #include "base/test/user_action_tester.h" 7 #include "base/test/user_action_tester.h"
9 #include "base/values.h" 8 #include "base/values.h"
10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 9 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
11 #include "chrome/browser/signin/account_fetcher_service_factory.h" 10 #include "chrome/browser/signin/account_fetcher_service_factory.h"
12 #include "chrome/browser/signin/account_tracker_service_factory.h" 11 #include "chrome/browser/signin/account_tracker_service_factory.h"
13 #include "chrome/browser/signin/fake_account_fetcher_service_builder.h" 12 #include "chrome/browser/signin/fake_account_fetcher_service_builder.h"
14 #include "chrome/browser/signin/fake_signin_manager_builder.h" 13 #include "chrome/browser/signin/fake_signin_manager_builder.h"
15 #include "chrome/browser/signin/signin_manager_factory.h" 14 #include "chrome/browser/signin/signin_manager_factory.h"
16 #include "chrome/browser/sync/profile_sync_service_factory.h" 15 #include "chrome/browser/sync/profile_sync_service_factory.h"
17 #include "chrome/browser/ui/browser_commands.h" 16 #include "chrome/browser/ui/browser_commands.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 "gaia", 182 "gaia",
184 "foo@example.com", 183 "foo@example.com",
185 "gaia", 184 "gaia",
186 "", 185 "",
187 "full_name", 186 "full_name",
188 "given_name", 187 "given_name",
189 "locale", 188 "locale",
190 "http://picture.example.com/picture.jpg"); 189 "http://picture.example.com/picture.jpg");
191 190
192 base::ListValue args; 191 base::ListValue args;
193 args.Set(0, base::MakeUnique<base::Value>(kDefaultDialogHeight)); 192 args.Set(0, new base::Value(kDefaultDialogHeight));
194 handler()->HandleInitializedWithSize(&args); 193 handler()->HandleInitializedWithSize(&args);
195 EXPECT_EQ(2U, web_ui()->call_data().size()); 194 EXPECT_EQ(2U, web_ui()->call_data().size());
196 195
197 // When the primary account is ready, setUserImageURL happens before 196 // When the primary account is ready, setUserImageURL happens before
198 // clearFocus since the image URL is known before showing the dialog. 197 // clearFocus since the image URL is known before showing the dialog.
199 EXPECT_EQ("sync.confirmation.setUserImageURL", 198 EXPECT_EQ("sync.confirmation.setUserImageURL",
200 web_ui()->call_data()[0]->function_name()); 199 web_ui()->call_data()[0]->function_name());
201 EXPECT_TRUE( 200 EXPECT_TRUE(
202 web_ui()->call_data()[0]->arg1()->IsType(base::Value::Type::STRING)); 201 web_ui()->call_data()[0]->arg1()->IsType(base::Value::Type::STRING));
203 std::string passed_picture_url; 202 std::string passed_picture_url;
204 EXPECT_TRUE( 203 EXPECT_TRUE(
205 web_ui()->call_data()[0]->arg1()->GetAsString(&passed_picture_url)); 204 web_ui()->call_data()[0]->arg1()->GetAsString(&passed_picture_url));
206 205
207 EXPECT_EQ("sync.confirmation.clearFocus", 206 EXPECT_EQ("sync.confirmation.clearFocus",
208 web_ui()->call_data()[1]->function_name()); 207 web_ui()->call_data()[1]->function_name());
209 208
210 std::string original_picture_url = 209 std::string original_picture_url =
211 AccountTrackerServiceFactory::GetForProfile(profile())-> 210 AccountTrackerServiceFactory::GetForProfile(profile())->
212 GetAccountInfo("gaia").picture_url; 211 GetAccountInfo("gaia").picture_url;
213 GURL picture_url_with_size; 212 GURL picture_url_with_size;
214 EXPECT_TRUE(profiles::GetImageURLWithThumbnailSize(GURL(original_picture_url), 213 EXPECT_TRUE(profiles::GetImageURLWithThumbnailSize(GURL(original_picture_url),
215 kExpectedProfileImageSize, 214 kExpectedProfileImageSize,
216 &picture_url_with_size)); 215 &picture_url_with_size));
217 EXPECT_EQ(picture_url_with_size.spec(), passed_picture_url); 216 EXPECT_EQ(picture_url_with_size.spec(), passed_picture_url);
218 } 217 }
219 218
220 TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) { 219 TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) {
221 base::ListValue args; 220 base::ListValue args;
222 args.Set(0, base::MakeUnique<base::Value>(kDefaultDialogHeight)); 221 args.Set(0, new base::Value(kDefaultDialogHeight));
223 handler()->HandleInitializedWithSize(&args); 222 handler()->HandleInitializedWithSize(&args);
224 EXPECT_EQ(2U, web_ui()->call_data().size()); 223 EXPECT_EQ(2U, web_ui()->call_data().size());
225 224
226 account_fetcher_service()->FakeUserInfoFetchSuccess( 225 account_fetcher_service()->FakeUserInfoFetchSuccess(
227 "gaia", 226 "gaia",
228 "foo@example.com", 227 "foo@example.com",
229 "gaia", 228 "gaia",
230 "", 229 "",
231 "full_name", 230 "full_name",
232 "given_name", 231 "given_name",
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 GURL picture_url_with_size; 263 GURL picture_url_with_size;
265 EXPECT_TRUE(profiles::GetImageURLWithThumbnailSize(GURL(original_picture_url), 264 EXPECT_TRUE(profiles::GetImageURLWithThumbnailSize(GURL(original_picture_url),
266 kExpectedProfileImageSize, 265 kExpectedProfileImageSize,
267 &picture_url_with_size)); 266 &picture_url_with_size));
268 EXPECT_EQ(picture_url_with_size.spec(), passed_picture_url); 267 EXPECT_EQ(picture_url_with_size.spec(), passed_picture_url);
269 } 268 }
270 269
271 TEST_F(SyncConfirmationHandlerTest, 270 TEST_F(SyncConfirmationHandlerTest,
272 TestSetImageIgnoredIfSecondaryAccountUpdated) { 271 TestSetImageIgnoredIfSecondaryAccountUpdated) {
273 base::ListValue args; 272 base::ListValue args;
274 args.Set(0, base::MakeUnique<base::Value>(kDefaultDialogHeight)); 273 args.Set(0, new base::Value(kDefaultDialogHeight));
275 handler()->HandleInitializedWithSize(&args); 274 handler()->HandleInitializedWithSize(&args);
276 EXPECT_EQ(2U, web_ui()->call_data().size()); 275 EXPECT_EQ(2U, web_ui()->call_data().size());
277 276
278 AccountTrackerServiceFactory::GetForProfile(profile())->SeedAccountInfo( 277 AccountTrackerServiceFactory::GetForProfile(profile())->SeedAccountInfo(
279 "bar_gaia", "bar@example.com"); 278 "bar_gaia", "bar@example.com");
280 account_fetcher_service()->FakeUserInfoFetchSuccess( 279 account_fetcher_service()->FakeUserInfoFetchSuccess(
281 "bar_gaia", "bar@example.com", "bar_gaia", "", "bar_full_name", 280 "bar_gaia", "bar@example.com", "bar_gaia", "", "bar_full_name",
282 "bar_given_name", "bar_locale", 281 "bar_given_name", "bar_locale",
283 "http://picture.example.com/bar_picture.jpg"); 282 "http://picture.example.com/bar_picture.jpg");
284 283
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 EXPECT_FALSE(sync()->IsFirstSetupInProgress()); 346 EXPECT_FALSE(sync()->IsFirstSetupInProgress());
348 EXPECT_FALSE(sync()->IsFirstSetupComplete()); 347 EXPECT_FALSE(sync()->IsFirstSetupComplete());
349 EXPECT_TRUE( 348 EXPECT_TRUE(
350 SigninManagerFactory::GetForProfile(profile())->IsAuthenticated()); 349 SigninManagerFactory::GetForProfile(profile())->IsAuthenticated());
351 EXPECT_EQ(0, user_action_tester()->GetActionCount("Signin_Undo_Signin")); 350 EXPECT_EQ(0, user_action_tester()->GetActionCount("Signin_Undo_Signin"));
352 EXPECT_EQ(0, user_action_tester()->GetActionCount( 351 EXPECT_EQ(0, user_action_tester()->GetActionCount(
353 "Signin_Signin_WithDefaultSyncSettings")); 352 "Signin_Signin_WithDefaultSyncSettings"));
354 EXPECT_EQ(1, user_action_tester()->GetActionCount( 353 EXPECT_EQ(1, user_action_tester()->GetActionCount(
355 "Signin_Signin_WithAdvancedSyncSettings")); 354 "Signin_Signin_WithAdvancedSyncSettings"));
356 } 355 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698