| OLD | NEW |
| 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/test/user_action_tester.h" | 7 #include "base/test/user_action_tester.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 9 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 10 #include "chrome/browser/signin/account_fetcher_service_factory.h" | 10 #include "chrome/browser/signin/account_fetcher_service_factory.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 "gaia", | 144 "gaia", |
| 145 "foo@example.com", | 145 "foo@example.com", |
| 146 "gaia", | 146 "gaia", |
| 147 "", | 147 "", |
| 148 "full_name", | 148 "full_name", |
| 149 "given_name", | 149 "given_name", |
| 150 "locale", | 150 "locale", |
| 151 "http://picture.example.com/picture.jpg"); | 151 "http://picture.example.com/picture.jpg"); |
| 152 | 152 |
| 153 base::ListValue args; | 153 base::ListValue args; |
| 154 args.Set(0, new base::FundamentalValue(kDefaultDialogHeight)); | 154 args.Set(0, new base::Value(kDefaultDialogHeight)); |
| 155 handler()->HandleInitializedWithSize(&args); | 155 handler()->HandleInitializedWithSize(&args); |
| 156 EXPECT_EQ(2U, web_ui()->call_data().size()); | 156 EXPECT_EQ(2U, web_ui()->call_data().size()); |
| 157 | 157 |
| 158 // When the primary account is ready, setUserImageURL happens before | 158 // When the primary account is ready, setUserImageURL happens before |
| 159 // clearFocus since the image URL is known before showing the dialog. | 159 // clearFocus since the image URL is known before showing the dialog. |
| 160 EXPECT_EQ("sync.confirmation.setUserImageURL", | 160 EXPECT_EQ("sync.confirmation.setUserImageURL", |
| 161 web_ui()->call_data()[0]->function_name()); | 161 web_ui()->call_data()[0]->function_name()); |
| 162 EXPECT_TRUE( | 162 EXPECT_TRUE( |
| 163 web_ui()->call_data()[0]->arg1()->IsType(base::Value::TYPE_STRING)); | 163 web_ui()->call_data()[0]->arg1()->IsType(base::Value::TYPE_STRING)); |
| 164 std::string passed_picture_url; | 164 std::string passed_picture_url; |
| 165 EXPECT_TRUE( | 165 EXPECT_TRUE( |
| 166 web_ui()->call_data()[0]->arg1()->GetAsString(&passed_picture_url)); | 166 web_ui()->call_data()[0]->arg1()->GetAsString(&passed_picture_url)); |
| 167 | 167 |
| 168 EXPECT_EQ("sync.confirmation.clearFocus", | 168 EXPECT_EQ("sync.confirmation.clearFocus", |
| 169 web_ui()->call_data()[1]->function_name()); | 169 web_ui()->call_data()[1]->function_name()); |
| 170 | 170 |
| 171 std::string original_picture_url = | 171 std::string original_picture_url = |
| 172 AccountTrackerServiceFactory::GetForProfile(profile())-> | 172 AccountTrackerServiceFactory::GetForProfile(profile())-> |
| 173 GetAccountInfo("gaia").picture_url; | 173 GetAccountInfo("gaia").picture_url; |
| 174 GURL picture_url_with_size; | 174 GURL picture_url_with_size; |
| 175 EXPECT_TRUE(profiles::GetImageURLWithThumbnailSize(GURL(original_picture_url), | 175 EXPECT_TRUE(profiles::GetImageURLWithThumbnailSize(GURL(original_picture_url), |
| 176 kExpectedProfileImageSize, | 176 kExpectedProfileImageSize, |
| 177 &picture_url_with_size)); | 177 &picture_url_with_size)); |
| 178 EXPECT_EQ(picture_url_with_size.spec(), passed_picture_url); | 178 EXPECT_EQ(picture_url_with_size.spec(), passed_picture_url); |
| 179 } | 179 } |
| 180 | 180 |
| 181 TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) { | 181 TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) { |
| 182 base::ListValue args; | 182 base::ListValue args; |
| 183 args.Set(0, new base::FundamentalValue(kDefaultDialogHeight)); | 183 args.Set(0, new base::Value(kDefaultDialogHeight)); |
| 184 handler()->HandleInitializedWithSize(&args); | 184 handler()->HandleInitializedWithSize(&args); |
| 185 EXPECT_EQ(1U, web_ui()->call_data().size()); | 185 EXPECT_EQ(1U, web_ui()->call_data().size()); |
| 186 | 186 |
| 187 account_fetcher_service()->FakeUserInfoFetchSuccess( | 187 account_fetcher_service()->FakeUserInfoFetchSuccess( |
| 188 "gaia", | 188 "gaia", |
| 189 "foo@example.com", | 189 "foo@example.com", |
| 190 "gaia", | 190 "gaia", |
| 191 "", | 191 "", |
| 192 "full_name", | 192 "full_name", |
| 193 "given_name", | 193 "given_name", |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 EXPECT_FALSE(sync()->IsFirstSetupInProgress()); | 247 EXPECT_FALSE(sync()->IsFirstSetupInProgress()); |
| 248 EXPECT_TRUE(sync()->IsFirstSetupComplete()); | 248 EXPECT_TRUE(sync()->IsFirstSetupComplete()); |
| 249 EXPECT_TRUE( | 249 EXPECT_TRUE( |
| 250 SigninManagerFactory::GetForProfile(profile())->IsAuthenticated()); | 250 SigninManagerFactory::GetForProfile(profile())->IsAuthenticated()); |
| 251 EXPECT_EQ(0, user_action_tester()->GetActionCount("Signin_Undo_Signin")); | 251 EXPECT_EQ(0, user_action_tester()->GetActionCount("Signin_Undo_Signin")); |
| 252 EXPECT_EQ(1, user_action_tester()->GetActionCount( | 252 EXPECT_EQ(1, user_action_tester()->GetActionCount( |
| 253 "Signin_Signin_WithDefaultSyncSettings")); | 253 "Signin_Signin_WithDefaultSyncSettings")); |
| 254 EXPECT_EQ(0, user_action_tester()->GetActionCount( | 254 EXPECT_EQ(0, user_action_tester()->GetActionCount( |
| 255 "Signin_Signin_WithAdvancedSyncSettings")); | 255 "Signin_Signin_WithAdvancedSyncSettings")); |
| 256 } | 256 } |
| OLD | NEW |