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

Side by Side Diff: chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc

Issue 2354613002: [Sync] Fix namespaces for the browser_sync component. (Closed)
Patch Set: Self-review. Created 4 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/options/sync_setup_handler.h" 5 #include "chrome/browser/ui/webui/options/sync_setup_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 BuildFakeSigninManagerBase); 192 BuildFakeSigninManagerBase);
193 profile_ = builder.Build(); 193 profile_ = builder.Build();
194 194
195 // Sign in the user. 195 // Sign in the user.
196 mock_signin_ = static_cast<SigninManagerBase*>( 196 mock_signin_ = static_cast<SigninManagerBase*>(
197 SigninManagerFactory::GetForProfile(profile_.get())); 197 SigninManagerFactory::GetForProfile(profile_.get()));
198 std::string username = GetTestUser(); 198 std::string username = GetTestUser();
199 if (!username.empty()) 199 if (!username.empty())
200 mock_signin_->SetAuthenticatedAccountInfo(username, username); 200 mock_signin_->SetAuthenticatedAccountInfo(username, username);
201 201
202 mock_pss_ = static_cast<ProfileSyncServiceMock*>( 202 mock_pss_ = static_cast<browser_sync::ProfileSyncServiceMock*>(
skym 2016/09/22 17:25:59 I would have expected you to do a using here since
maxbogue 2016/09/22 19:41:15 Done.
203 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 203 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
204 profile_.get(), BuildMockProfileSyncService)); 204 profile_.get(), BuildMockProfileSyncService));
205 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 205 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
206 ON_CALL(*mock_pss_, GetPassphraseType()) 206 ON_CALL(*mock_pss_, GetPassphraseType())
207 .WillByDefault(Return(syncer::PassphraseType::IMPLICIT_PASSPHRASE)); 207 .WillByDefault(Return(syncer::PassphraseType::IMPLICIT_PASSPHRASE));
208 ON_CALL(*mock_pss_, GetExplicitPassphraseTime()).WillByDefault( 208 ON_CALL(*mock_pss_, GetExplicitPassphraseTime()).WillByDefault(
209 Return(base::Time())); 209 Return(base::Time()));
210 ON_CALL(*mock_pss_, GetRegisteredDataTypes()) 210 ON_CALL(*mock_pss_, GetRegisteredDataTypes())
211 .WillByDefault(Return(syncer::ModelTypeSet())); 211 .WillByDefault(Return(syncer::ModelTypeSet()));
212 212
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (handler_->sync_startup_tracker_) 279 if (handler_->sync_startup_tracker_)
280 handler_->sync_startup_tracker_->OnStateChanged(); 280 handler_->sync_startup_tracker_->OnStateChanged();
281 } 281 }
282 282
283 virtual std::string GetTestUser() { 283 virtual std::string GetTestUser() {
284 return std::string(kTestUser); 284 return std::string(kTestUser);
285 } 285 }
286 286
287 content::TestBrowserThreadBundle thread_bundle_; 287 content::TestBrowserThreadBundle thread_bundle_;
288 std::unique_ptr<Profile> profile_; 288 std::unique_ptr<Profile> profile_;
289 ProfileSyncServiceMock* mock_pss_; 289 browser_sync::ProfileSyncServiceMock* mock_pss_;
290 GoogleServiceAuthError error_; 290 GoogleServiceAuthError error_;
291 SigninManagerBase* mock_signin_; 291 SigninManagerBase* mock_signin_;
292 content::TestWebUI web_ui_; 292 content::TestWebUI web_ui_;
293 std::unique_ptr<TestingSyncSetupHandler> handler_; 293 std::unique_ptr<TestingSyncSetupHandler> handler_;
294 }; 294 };
295 295
296 class SyncSetupHandlerFirstSigninTest : public SyncSetupHandlerTest { 296 class SyncSetupHandlerFirstSigninTest : public SyncSetupHandlerTest {
297 std::string GetTestUser() override { return std::string(); } 297 std::string GetTestUser() override { return std::string(); }
298 }; 298 };
299 299
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 error_ = GoogleServiceAuthError::AuthErrorNone(); 433 error_ = GoogleServiceAuthError::AuthErrorNone();
434 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) 434 EXPECT_CALL(*mock_pss_, IsBackendInitialized())
435 .WillOnce(Return(false)) 435 .WillOnce(Return(false))
436 .WillRepeatedly(Return(true)); 436 .WillRepeatedly(Return(true));
437 SetDefaultExpectationsForConfigPage(); 437 SetDefaultExpectationsForConfigPage();
438 handler_->OpenSyncSetup(false /* creating_supervised_user */); 438 handler_->OpenSyncSetup(false /* creating_supervised_user */);
439 439
440 // It's important to tell sync the user cancelled the setup flow before we 440 // It's important to tell sync the user cancelled the setup flow before we
441 // tell it we're through with the setup progress. 441 // tell it we're through with the setup progress.
442 testing::InSequence seq; 442 testing::InSequence seq;
443 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); 443 EXPECT_CALL(*mock_pss_,
444 RequestStop(browser_sync::ProfileSyncService::CLEAR_DATA));
444 EXPECT_CALL(*mock_pss_, OnSetupInProgressHandleDestroyed()); 445 EXPECT_CALL(*mock_pss_, OnSetupInProgressHandleDestroyed());
445 446
446 handler_->CloseSyncSetup(); 447 handler_->CloseSyncSetup();
447 EXPECT_EQ(NULL, 448 EXPECT_EQ(NULL,
448 LoginUIServiceFactory::GetForProfile( 449 LoginUIServiceFactory::GetForProfile(
449 profile_.get())->current_login_ui()); 450 profile_.get())->current_login_ui());
450 } 451 }
451 452
452 TEST_F(SyncSetupHandlerTest, 453 TEST_F(SyncSetupHandlerTest,
453 DisplayConfigureWithBackendDisabledAndSigninFailed) { 454 DisplayConfigureWithBackendDisabledAndSigninFailed) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 base::ListValue list_args; 611 base::ListValue list_args;
611 list_args.AppendString(args); 612 list_args.AppendString(args);
612 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 613 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
613 .WillRepeatedly(Return(false)); 614 .WillRepeatedly(Return(false));
614 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 615 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
615 .WillRepeatedly(Return(false)); 616 .WillRepeatedly(Return(false));
616 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 617 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
617 .WillRepeatedly(Return(false)); 618 .WillRepeatedly(Return(false));
618 SetupInitializedProfileSyncService(); 619 SetupInitializedProfileSyncService();
619 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); 620 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
620 EXPECT_CALL(*mock_pss_, 621 EXPECT_CALL(*mock_pss_, SetEncryptionPassphrase(
621 SetEncryptionPassphrase("custom_passphrase", 622 "custom_passphrase",
622 ProfileSyncService::EXPLICIT)); 623 browser_sync::ProfileSyncService::EXPLICIT));
623 624
624 handler_->HandleConfigure(&list_args); 625 handler_->HandleConfigure(&list_args);
625 // We should navigate to "done" page since we finished configuring. 626 // We should navigate to "done" page since we finished configuring.
626 ExpectDone(); 627 ExpectDone();
627 } 628 }
628 629
629 TEST_F(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) { 630 TEST_F(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) {
630 base::DictionaryValue dict; 631 base::DictionaryValue dict;
631 dict.SetBoolean("isGooglePassphrase", true); 632 dict.SetBoolean("isGooglePassphrase", true);
632 std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), 633 std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(),
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) 942 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
942 .WillRepeatedly(Return(false)); 943 .WillRepeatedly(Return(false));
943 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); 944 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0);
944 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); 945 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
945 handler_->HandleConfigure(&list_args); 946 handler_->HandleConfigure(&list_args);
946 947
947 // Ensure that we navigated to the "done" state since we don't need a 948 // Ensure that we navigated to the "done" state since we don't need a
948 // passphrase. 949 // passphrase.
949 ExpectDone(); 950 ExpectDone();
950 } 951 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698