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

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

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

Powered by Google App Engine
This is Rietveld 408576698