diff options
-rw-r--r-- | chrome/browser/sync/profile_sync_service_harness.cc | 132 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_service_harness.h | 12 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 | ||||
-rw-r--r-- | chrome/test/live_sync/live_passwords_sync_test.cc | 124 | ||||
-rw-r--r-- | chrome/test/live_sync/live_passwords_sync_test.h | 97 | ||||
-rw-r--r-- | chrome/test/live_sync/many_client_live_passwords_sync_test.cc | 20 | ||||
-rw-r--r-- | chrome/test/live_sync/multiple_client_live_passwords_sync_test.cc | 26 | ||||
-rw-r--r-- | chrome/test/live_sync/single_client_live_passwords_sync_test.cc | 28 | ||||
-rw-r--r-- | chrome/test/live_sync/two_client_live_passwords_sync_test.cc | 173 |
9 files changed, 321 insertions, 292 deletions
diff --git a/chrome/browser/sync/profile_sync_service_harness.cc b/chrome/browser/sync/profile_sync_service_harness.cc index 989f6a9..96047c0 100644 --- a/chrome/browser/sync/profile_sync_service_harness.cc +++ b/chrome/browser/sync/profile_sync_service_harness.cc @@ -160,28 +160,8 @@ bool ProfileSyncServiceHarness::SetupSync( (syncable::MODEL_TYPE_COUNT - syncable::FIRST_REAL_MODEL_TYPE)); service()->OnUserChoseDatatypes(sync_everything, synced_datatypes); - // Wait for a passphrase to be required. - DCHECK_EQ(wait_state_, WAITING_FOR_PASSPHRASE_REQUIRED); - if (!AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, - "Waiting for Passphrase required.")) { - LOG(ERROR) << "Passphrase required not seen after " - << kLiveSyncOperationTimeoutMs / 1000 - << " seconds."; - return false; - } - - // Wait for initial gaia passphrase to be accepted. - DCHECK_EQ(wait_state_, WAITING_FOR_PASSPHRASE_ACCEPTED); - if (!AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, - "Waiting for Passphrase accept.")) { - LOG(ERROR) << "Passphrase accept not seen after " - << kLiveSyncOperationTimeoutMs / 1000 - << " seconds."; - return false; - } - - DCHECK_EQ(wait_state_, WAITING_FOR_INITIAL_SYNC); // Wait for initial sync cycle to be completed. + DCHECK_EQ(wait_state_, WAITING_FOR_INITIAL_SYNC); if (!AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, "Waiting for initial sync cycle to complete.")) { LOG(ERROR) << "Initial sync cycle did not complete after " @@ -212,27 +192,9 @@ bool ProfileSyncServiceHarness::RunStateChangeMachine() { case WAITING_FOR_ON_BACKEND_INITIALIZED: { LogClientInfo("WAITING_FOR_ON_BACKEND_INITIALIZED"); if (service()->sync_initialized()) { - // The sync backend is initialized. We now wait for passphrase events. - SignalStateCompleteWithNextState(WAITING_FOR_PASSPHRASE_REQUIRED); - } - break; - } - case WAITING_FOR_PASSPHRASE_REQUIRED: { - LogClientInfo("WAITING_FOR_PASSPHRASE_REQUIRED"); - if (service()->observed_passphrase_required()) { - // Special case when the first client signs in to sync. - if (id_ == 0) - DCHECK(!service()->passphrase_required_for_decryption()); - // The SYNC_PASSPHRASE_REQUIRED notification has been seen. - SignalStateCompleteWithNextState(WAITING_FOR_PASSPHRASE_ACCEPTED); - } - break; - } - case WAITING_FOR_PASSPHRASE_ACCEPTED: { - LogClientInfo("WAITING_FOR_PASSPHRASE_ACCEPTED"); - if (service()->ShouldPushChanges()) - // The SYNC_PASSPHRASE_ACCEPTED notification has been seen. + // The sync backend is initialized. SignalStateCompleteWithNextState(WAITING_FOR_INITIAL_SYNC); + } break; } case WAITING_FOR_INITIAL_SYNC: { @@ -270,6 +232,25 @@ bool ProfileSyncServiceHarness::RunStateChangeMachine() { SignalStateCompleteWithNextState(FULLY_SYNCED); break; } + case WAITING_FOR_PASSPHRASE_ACCEPTED: { + LogClientInfo("WAITING_FOR_PASSPHRASE_ACCEPTED"); + // TODO(atwilson): After ProfileSyncService::OnPassphraseAccepted() is + // fixed, add an extra check to make sure that the value of + // service()->observed_passphrase_required() is false. + if (service()->ShouldPushChanges()) { + // The passphrase has been accepted, and sync has been restarted. + SignalStateCompleteWithNextState(FULLY_SYNCED); + } + break; + } + case WAITING_FOR_ENCRYPTION: { + LogClientInfo("WAITING_FOR_ENCRYPTION"); + if (IsTypeEncrypted(waiting_for_encryption_type_)) { + // Encryption is complete for the type we are waiting on. + SignalStateCompleteWithNextState(FULLY_SYNCED); + } + break; + } case SERVER_UNREACHABLE: { LogClientInfo("SERVER_UNREACHABLE"); if (GetStatus().server_reachable) { @@ -289,14 +270,6 @@ bool ProfileSyncServiceHarness::RunStateChangeMachine() { LogClientInfo("SYNC_DISABLED"); break; } - case WAITING_FOR_ENCRYPTION: { - // If the type whose encryption we are waiting for is now complete, there - // is nothing to do. - LogClientInfo("WAITING_FOR_ENCRYPTION"); - if (IsTypeEncrypted(waiting_for_encryption_type_)) - SignalStateCompleteWithNextState(FULLY_SYNCED); - break; - } default: // Invalid state during observer callback which may be triggered by other // classes using the the UI message loop. Defer to their handling. @@ -315,6 +288,15 @@ bool ProfileSyncServiceHarness::AwaitPassphraseAccepted() { LOG(ERROR) << "Sync disabled for Client " << id_ << "."; return false; } + + // TODO(atwilson): After ProfileSyncService::OnPassphraseAccepted() is + // fixed, add an extra check to make sure that the value of + // service()->observed_passphrase_required() is false. + if (service()->ShouldPushChanges()) { + // Passphrase is already accepted; don't wait. + return true; + } + wait_state_ = WAITING_FOR_PASSPHRASE_ACCEPTED; return AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, "Waiting for passphrase accepted."); @@ -327,31 +309,32 @@ bool ProfileSyncServiceHarness::AwaitSyncCycleCompletion( LOG(ERROR) << "Sync disabled for Client " << id_ << "."; return false; } - if (!IsSynced()) { - if (wait_state_ == SERVER_UNREACHABLE) { - // Client was offline; wait for it to go online, and then wait for sync. - AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason); - DCHECK_EQ(wait_state_, WAITING_FOR_SYNC_TO_FINISH); - return AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason); - } else { - DCHECK(service()->sync_initialized()); - wait_state_ = WAITING_FOR_SYNC_TO_FINISH; - AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason); - if (wait_state_ == FULLY_SYNCED) { - // Client is online; sync was successful. - return true; - } else if (wait_state_ == SERVER_UNREACHABLE) { - // Client is offline; sync was unsuccessful. - return false; - } else { - LOG(ERROR) << "Invalid wait state:" << wait_state_; - return false; - } - } - } else { + + if (IsSynced()) { // Client is already synced; don't wait. return true; } + + if (wait_state_ == SERVER_UNREACHABLE) { + // Client was offline; wait for it to go online, and then wait for sync. + AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason); + DCHECK_EQ(wait_state_, WAITING_FOR_SYNC_TO_FINISH); + return AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason); + } else { + DCHECK(service()->sync_initialized()); + wait_state_ = WAITING_FOR_SYNC_TO_FINISH; + AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason); + if (wait_state_ == FULLY_SYNCED) { + // Client is online; sync was successful. + return true; + } else if (wait_state_ == SERVER_UNREACHABLE) { + // Client is offline; sync was unsuccessful. + return false; + } else { + LOG(ERROR) << "Invalid wait state:" << wait_state_; + return false; + } + } } bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion( @@ -401,10 +384,13 @@ bool ProfileSyncServiceHarness::WaitUntilTimestampMatches( LOG(ERROR) << "Sync disabled for Client " << id_ << "."; return false; } - DCHECK(!timestamp_match_partner_); - if (MatchesOtherClient(partner)) + + if (MatchesOtherClient(partner)) { + // Timestamps already match; don't wait. return true; + } + DCHECK(!timestamp_match_partner_); timestamp_match_partner_ = partner; partner->service()->AddObserver(this); wait_state_ = WAITING_FOR_UPDATES; diff --git a/chrome/browser/sync/profile_sync_service_harness.h b/chrome/browser/sync/profile_sync_service_harness.h index 5b62795..3ddc74e 100644 --- a/chrome/browser/sync/profile_sync_service_harness.h +++ b/chrome/browser/sync/profile_sync_service_harness.h @@ -87,7 +87,7 @@ class ProfileSyncServiceHarness : public ProfileSyncServiceObserver { std::vector<ProfileSyncServiceHarness*>& clients); // If a SetPassphrase call has been issued with a valid passphrase, this - // will wait until the Cryptographer broadcasts SYNC_PASSPHRASE_ACCEPTED. + // will wait until the passphrase has been accepted. bool AwaitPassphraseAccepted(); // Returns the ProfileSyncService member of the the sync client. @@ -135,12 +135,6 @@ class ProfileSyncServiceHarness : public ProfileSyncServiceObserver { // The sync client awaits the OnBackendInitialized() callback. WAITING_FOR_ON_BACKEND_INITIALIZED, - // Waiting for a passphrase to be required. - WAITING_FOR_PASSPHRASE_REQUIRED, - - // Waiting for a set passphrase to be accepted by the cryptographer. - WAITING_FOR_PASSPHRASE_ACCEPTED, - // The sync client is waiting for the first sync cycle to complete. WAITING_FOR_INITIAL_SYNC, @@ -150,6 +144,10 @@ class ProfileSyncServiceHarness : public ProfileSyncServiceObserver { // The sync client anticipates incoming updates leading to a new sync cycle. WAITING_FOR_UPDATES, + // The sync client is waiting for its passphrase to be accepted by the + // cryptographer. + WAITING_FOR_PASSPHRASE_ACCEPTED, + // The sync client anticipates encryption of new datatypes. WAITING_FOR_ENCRYPTION, diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 1402a00..0dfd105 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -3053,6 +3053,7 @@ 'test/live_sync/live_extensions_sync_test_base.h', 'test/live_sync/live_extensions_sync_test.cc', 'test/live_sync/live_extensions_sync_test.h', + 'test/live_sync/live_passwords_sync_test.cc', 'test/live_sync/live_passwords_sync_test.h', 'test/live_sync/live_preferences_sync_test.h', 'test/live_sync/live_sessions_sync_test.cc', diff --git a/chrome/test/live_sync/live_passwords_sync_test.cc b/chrome/test/live_sync/live_passwords_sync_test.cc new file mode 100644 index 0000000..abdc2d8 --- /dev/null +++ b/chrome/test/live_sync/live_passwords_sync_test.cc @@ -0,0 +1,124 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/test/live_sync/live_passwords_sync_test.h" + +#include "base/string_util.h" +#include "base/synchronization/waitable_event.h" +#include "base/utf_string_conversions.h" +#include "chrome/browser/password_manager/password_store_consumer.h" +#include "chrome/browser/password_manager/password_store.h" +#include "chrome/browser/sync/profile_sync_service_harness.h" +#include "chrome/test/ui_test_utils.h" +#include "content/browser/browser_thread.h" + +using webkit_glue::PasswordForm; + +const std::string kFakeSignonRealm = "http://fake-domain.google.com/"; + +// We use a WaitableEvent to wait on AddLogin instead of running the UI message +// loop because of a restriction that prevents a DB thread from initiating a +// quit of the UI message loop. +void PasswordStoreCallback(base::WaitableEvent* wait_event) { + // Wake up LivePasswordsSyncTest::AddLogin. + wait_event->Signal(); +} + +class PasswordStoreConsumerHelper : public PasswordStoreConsumer { + public: + explicit PasswordStoreConsumerHelper(std::vector<PasswordForm>* result) + : PasswordStoreConsumer(), + result_(result) {} + + virtual void OnPasswordStoreRequestDone( + CancelableRequestProvider::Handle handle, + const std::vector<PasswordForm*>& result) { + result_->clear(); + for (std::vector<PasswordForm*>::const_iterator it = result.begin(); + it != result.end(); ++it) { + // Make a copy of the form since it gets deallocated after the caller of + // this method returns. + result_->push_back(**it); + } + + // Quit the message loop to wake up LivePasswordsSyncTest::GetLogins. + MessageLoopForUI::current()->Quit(); + } + + private: + std::vector<PasswordForm>* result_; + + DISALLOW_COPY_AND_ASSIGN(PasswordStoreConsumerHelper); +}; + +LivePasswordsSyncTest::LivePasswordsSyncTest(TestType test_type) + : LiveSyncTest(test_type) {} + +void LivePasswordsSyncTest::CleanUpOnMainThread() { + CleanupTestPasswordForms(); + LiveSyncTest::CleanUpOnMainThread(); +} + +bool LivePasswordsSyncTest::SetupClients() { + if (LiveSyncTest::SetupClients()) { + CleanupTestPasswordForms(); + return true; + } + return false; +} + +void LivePasswordsSyncTest::AddLogin(PasswordStore* store, + const PasswordForm& form) { + ASSERT_TRUE(store); + base::WaitableEvent wait_event(true, false); + store->AddLogin(form); + store->ScheduleTask(NewRunnableFunction(&PasswordStoreCallback, &wait_event)); + wait_event.Wait(); +} + +void LivePasswordsSyncTest::GetLogins(PasswordStore* store, + std::vector<PasswordForm>& matches) { + ASSERT_TRUE(store); + PasswordForm matcher_form; + matcher_form.signon_realm = kFakeSignonRealm; + PasswordStoreConsumerHelper consumer(&matches); + store->GetLogins(matcher_form, &consumer); + ui_test_utils::RunMessageLoop(); +} + +void LivePasswordsSyncTest::SetPassphrase(int index, + const std::string& passphrase, + bool is_creation) { + GetProfile(index)->GetProfileSyncService("")->SetPassphrase( + passphrase, true, is_creation); +} + +PasswordStore* LivePasswordsSyncTest::GetPasswordStore(int index) { + return GetProfile(index)->GetPasswordStore(Profile::IMPLICIT_ACCESS); +} + +PasswordStore* LivePasswordsSyncTest::GetVerifierPasswordStore() { + return verifier()->GetPasswordStore(Profile::IMPLICIT_ACCESS); +} + +PasswordForm LivePasswordsSyncTest::CreateTestPasswordForm(int index) { + PasswordForm form; + form.signon_realm = kFakeSignonRealm; + form.origin = GURL(StringPrintf("http://fake-domain%d.google.com/", index)); + form.username_value = ASCIIToUTF16(StringPrintf("username%d", index)); + form.password_value = ASCIIToUTF16(StringPrintf("password%d", index)); + return form; +} + +void LivePasswordsSyncTest::CleanupTestPasswordForms() { + std::vector<PasswordForm> forms; + GetLogins(GetVerifierPasswordStore(), forms); + for (std::vector<PasswordForm>::iterator it = forms.begin(); + it != forms.end(); ++it) { + GetVerifierPasswordStore()->RemoveLogin(*it); + } + forms.clear(); + GetLogins(GetVerifierPasswordStore(), forms); + ASSERT_EQ(0U, forms.size()); +} diff --git a/chrome/test/live_sync/live_passwords_sync_test.h b/chrome/test/live_sync/live_passwords_sync_test.h index 6663f9f..1fc1d86 100644 --- a/chrome/test/live_sync/live_passwords_sync_test.h +++ b/chrome/test/live_sync/live_passwords_sync_test.h @@ -6,86 +6,71 @@ #define CHROME_TEST_LIVE_SYNC_LIVE_PASSWORDS_SYNC_TEST_H_ #pragma once -#include <set> +#include <vector> +#include "base/time.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/password_manager/password_store_consumer.h" -#include "chrome/browser/password_manager/password_store.h" #include "chrome/test/live_sync/live_sync_test.h" -#include "chrome/test/ui_test_utils.h" -#include "chrome/test/signaling_task.h" #include "webkit/glue/password_form.h" +class PasswordStore; + class LivePasswordsSyncTest : public LiveSyncTest { public: - explicit LivePasswordsSyncTest(TestType test_type) - : LiveSyncTest(test_type) {} - + explicit LivePasswordsSyncTest(TestType test_type); virtual ~LivePasswordsSyncTest() {} + // Overrides LiveSyncTest::CleanUpOnMainThread. Cleans up password forms that + // were added by a test. + virtual void CleanUpOnMainThread(); + + // Overrides LiveSyncTest::SetupClients. Initializes sync clients and profiles + // and cleans up old password forms that might have been left behind on the + // host machine by a previous test run that crashed before it could clean up + // after itself. + virtual bool SetupClients() WARN_UNUSED_RESULT; + // Adds the login held in |form| to the password store |store|. Even though // logins are normally added asynchronously, this method will block until the // login is added. - void AddLogin(PasswordStore* store, const webkit_glue::PasswordForm& form) { - EXPECT_TRUE(store); + void AddLogin(PasswordStore* store, + const webkit_glue::PasswordForm& form); - store->AddLogin(form); + // Searches |store| for all logins matching a fake signon realm used only by + // LivePasswordsSyncTest and adds the results to |matches|. Note that the + // caller is responsible for deleting the forms added to |matches|. + void GetLogins(PasswordStore* store, + std::vector<webkit_glue::PasswordForm>& matches); - base::WaitableEvent login_added(false, false); - store->ScheduleTask(new SignalingTask(&login_added)); - login_added.Wait(); - } - // Searches |store| for all logins matching |form|, the results are added to - // |matches|. Note that the caller is responsible for deleting the forms added - // to |matches|. - void GetLogins(PasswordStore* store, - const webkit_glue::PasswordForm& form, - std::vector<webkit_glue::PasswordForm>& matches) { - EXPECT_TRUE(store); + // Sets the cryptographer's passphrase for the profile at index |index| to + // |passphrase|. |is_creation| is true if a new passphrase is being set up + // and false otherwise. + void SetPassphrase(int index, + const std::string& passphrase, + bool is_creation); - PasswordStoreConsumerHelper consumer(matches); - store->GetLogins(form, &consumer); - ui_test_utils::RunMessageLoop(); - } + // Gets the password store of the profile with index |index|. + PasswordStore* GetPasswordStore(int index); - PasswordStore* GetPasswordStore(int index) { - return GetProfile(index)->GetPasswordStore(Profile::IMPLICIT_ACCESS); - } + // Gets the password store of the verifier profile. + PasswordStore* GetVerifierPasswordStore(); - PasswordStore* GetVerifierPasswordStore() { - return verifier()->GetPasswordStore(Profile::IMPLICIT_ACCESS); - } + // Creates a test password form with a well known fake signon realm used only + // by LivePasswordsSyncTest based on |index|. + webkit_glue::PasswordForm CreateTestPasswordForm(int index); private: - class PasswordStoreConsumerHelper : public PasswordStoreConsumer { - public: - explicit PasswordStoreConsumerHelper( - std::vector<webkit_glue::PasswordForm>& result) - : PasswordStoreConsumer(), result_(result) {} - - virtual void OnPasswordStoreRequestDone( - CancelableRequestProvider::Handle handle, - const std::vector<webkit_glue::PasswordForm*>& result) { - result_.clear(); - for (std::vector<webkit_glue::PasswordForm*>::const_iterator it = - result.begin(); it != result.end(); ++it) { - // Make a copy of the form since it gets deallocated after the caller of - // this method returns. - result_.push_back(**it); - } - MessageLoopForUI::current()->Quit(); - } - - private: - std::vector<webkit_glue::PasswordForm>& result_; - - DISALLOW_COPY_AND_ASSIGN(PasswordStoreConsumerHelper); - }; + // Cleans up all password forms ever added by LivePasswordsSyncTest. This is + // done by matching existing password forms found on a machine against a known + // fake sign-on realm used only by LivePasswordsSyncTest. + void CleanupTestPasswordForms(); DISALLOW_COPY_AND_ASSIGN(LivePasswordsSyncTest); }; +DISABLE_RUNNABLE_METHOD_REFCOUNT(LivePasswordsSyncTest); + class SingleClientLivePasswordsSyncTest : public LivePasswordsSyncTest { public: SingleClientLivePasswordsSyncTest() diff --git a/chrome/test/live_sync/many_client_live_passwords_sync_test.cc b/chrome/test/live_sync/many_client_live_passwords_sync_test.cc index e4e54bd..3aded8d 100644 --- a/chrome/test/live_sync/many_client_live_passwords_sync_test.cc +++ b/chrome/test/live_sync/many_client_live_passwords_sync_test.cc @@ -13,24 +13,18 @@ using webkit_glue::PasswordForm; IN_PROC_BROWSER_TEST_F(ManyClientLivePasswordsSyncTest, DISABLED_Sanity) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - PasswordForm form; - form.origin = GURL("http://www.google.com/"); - form.username_value = ASCIIToUTF16("username"); - form.password_value = ASCIIToUTF16("password"); - + PasswordForm form = CreateTestPasswordForm(0); AddLogin(GetVerifierPasswordStore(), form); AddLogin(GetPasswordStore(0), form); - ASSERT_TRUE(GetClient(0)->AwaitGroupSyncCycleCompletion(clients())); - std::vector<PasswordForm> expected; - GetLogins(GetVerifierPasswordStore(), form, expected); - ASSERT_EQ(1U, expected.size()); + std::vector<PasswordForm> verifier_forms; + GetLogins(GetVerifierPasswordStore(), verifier_forms); + ASSERT_EQ(1U, verifier_forms.size()); for (int i = 0; i < num_clients(); ++i) { - std::vector<PasswordForm> actual; - GetLogins(GetPasswordStore(i), form, actual); - - ASSERT_TRUE(ContainsSamePasswordForms(expected, actual)); + std::vector<PasswordForm> forms; + GetLogins(GetPasswordStore(i), forms); + ASSERT_TRUE(ContainsSamePasswordForms(verifier_forms, forms)); } } diff --git a/chrome/test/live_sync/multiple_client_live_passwords_sync_test.cc b/chrome/test/live_sync/multiple_client_live_passwords_sync_test.cc index bc50048..69f424b 100644 --- a/chrome/test/live_sync/multiple_client_live_passwords_sync_test.cc +++ b/chrome/test/live_sync/multiple_client_live_passwords_sync_test.cc @@ -9,34 +9,22 @@ using webkit_glue::PasswordForm; -// TODO(sync): Remove FAILS_ annotation after http://crbug.com/59867 is fixed. -#if defined(OS_MACOSX) -IN_PROC_BROWSER_TEST_F(MultipleClientLivePasswordsSyncTest, FAILS_Sanity) { -#else IN_PROC_BROWSER_TEST_F(MultipleClientLivePasswordsSyncTest, Sanity) { -#endif ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; for (int i = 0; i < num_clients(); ++i) { - PasswordForm form; - form.origin = GURL(StringPrintf("http://www.google.com/%d", i)); - form.username_value = ASCIIToUTF16(StringPrintf("username%d", i)); - form.password_value = ASCIIToUTF16(StringPrintf("password%d", i)); - + PasswordForm form = CreateTestPasswordForm(i); AddLogin(GetPasswordStore(i), form); } - ASSERT_TRUE(AwaitQuiescence()); - PasswordForm form; // Don't set any fields, so that all logins match. - std::vector<PasswordForm> expected; - GetLogins(GetPasswordStore(0), form, expected); - ASSERT_EQ((size_t) num_clients(), expected.size()); + std::vector<PasswordForm> forms0; + GetLogins(GetPasswordStore(0), forms0); + ASSERT_EQ((size_t) num_clients(), forms0.size()); for (int i = 1; i < num_clients(); ++i) { - std::vector<PasswordForm> actual; - GetLogins(GetPasswordStore(i), form, actual); - - ASSERT_TRUE(ContainsSamePasswordForms(expected, actual)); + std::vector<PasswordForm> forms; + GetLogins(GetPasswordStore(i), forms); + ASSERT_TRUE(ContainsSamePasswordForms(forms0, forms)); } } diff --git a/chrome/test/live_sync/single_client_live_passwords_sync_test.cc b/chrome/test/live_sync/single_client_live_passwords_sync_test.cc index 400eb1b6..ba56e02 100644 --- a/chrome/test/live_sync/single_client_live_passwords_sync_test.cc +++ b/chrome/test/live_sync/single_client_live_passwords_sync_test.cc @@ -8,30 +8,20 @@ using webkit_glue::PasswordForm; -// TODO(sync): Remove FAILS_ annotation after http://crbug.com/59867 is fixed. -#if defined(OS_MACOSX) -IN_PROC_BROWSER_TEST_F(SingleClientLivePasswordsSyncTest, FAILS_Sanity) { -#else IN_PROC_BROWSER_TEST_F(SingleClientLivePasswordsSyncTest, Sanity) { -#endif ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - PasswordForm form; - form.origin = GURL("http://www.google.com/"); - form.username_value = ASCIIToUTF16("username"); - form.password_value = ASCIIToUTF16("password"); - + PasswordForm form = CreateTestPasswordForm(0); AddLogin(GetVerifierPasswordStore(), form); - AddLogin(GetPasswordStore(0), form); - ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( - "Waiting for passwords change.")); + std::vector<PasswordForm> verifier_forms; + GetLogins(GetVerifierPasswordStore(), verifier_forms); + EXPECT_EQ(1U, verifier_forms.size()); - std::vector<PasswordForm> expected; - GetLogins(GetVerifierPasswordStore(), form, expected); - ASSERT_EQ(1U, expected.size()); + AddLogin(GetPasswordStore(0), form); + ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Added a login.")); - std::vector<PasswordForm> actual; - GetLogins(GetPasswordStore(0), form, actual); - ASSERT_TRUE(ContainsSamePasswordForms(expected, actual)); + std::vector<PasswordForm> forms0; + GetLogins(GetPasswordStore(0), forms0); + ASSERT_TRUE(ContainsSamePasswordForms(verifier_forms, forms0)); } diff --git a/chrome/test/live_sync/two_client_live_passwords_sync_test.cc b/chrome/test/live_sync/two_client_live_passwords_sync_test.cc index e308104..86f9433 100644 --- a/chrome/test/live_sync/two_client_live_passwords_sync_test.cc +++ b/chrome/test/live_sync/two_client_live_passwords_sync_test.cc @@ -12,155 +12,118 @@ using webkit_glue::PasswordForm; static const char* kValidPassphrase = "passphrase!"; -// TODO(sync): Remove FAILS_ annotation after http://crbug.com/59867 is fixed. -#if defined(OS_MACOSX) -IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, FAILS_Add) { -#else IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, Add) { -#endif - ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - PasswordForm form; - form.origin = GURL("http://www.google.com/"); - form.username_value = ASCIIToUTF16("username"); - form.password_value = ASCIIToUTF16("password"); + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + PasswordForm form = CreateTestPasswordForm(0); AddLogin(GetVerifierPasswordStore(), form); AddLogin(GetPasswordStore(0), form); - ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + std::vector<PasswordForm> verifier_forms; + GetLogins(GetVerifierPasswordStore(), verifier_forms); + ASSERT_EQ(1U, verifier_forms.size()); - std::vector<PasswordForm> expected; - GetLogins(GetVerifierPasswordStore(), form, expected); - ASSERT_EQ(1U, expected.size()); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - std::vector<PasswordForm> actual_zero; - GetLogins(GetPasswordStore(0), form, actual_zero); - ASSERT_TRUE(ContainsSamePasswordForms(expected, actual_zero)); + std::vector<PasswordForm> forms0; + GetLogins(GetPasswordStore(0), forms0); + ASSERT_TRUE(ContainsSamePasswordForms(verifier_forms, forms0)); - std::vector<PasswordForm> actual_one; - GetLogins(GetPasswordStore(1), form, actual_one); - ASSERT_TRUE(ContainsSamePasswordForms(expected, actual_one)); + std::vector<PasswordForm> forms1; + GetLogins(GetPasswordStore(1), forms1); + ASSERT_TRUE(ContainsSamePasswordForms(verifier_forms, forms1)); } -// TODO(sync): Remove FAILS_ annotation after http://crbug.com/59867 is fixed. -#if defined(OS_MACOSX) -IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, FAILS_Race) { -#else IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, Race) { -#endif ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - PasswordForm form; - form.origin = GURL("http://www.google.com/"); - - PasswordForm form_zero; - form_zero.origin = GURL("http://www.google.com/"); - form_zero.username_value = ASCIIToUTF16("username"); - form_zero.password_value = ASCIIToUTF16("zero"); - AddLogin(GetPasswordStore(0), form_zero); + PasswordForm form0 = CreateTestPasswordForm(0); + AddLogin(GetPasswordStore(0), form0); - PasswordForm form_one; - form_one.origin = GURL("http://www.google.com/"); - form_one.username_value = ASCIIToUTF16("username"); - form_one.password_value = ASCIIToUTF16("one"); - AddLogin(GetPasswordStore(1), form_one); + PasswordForm form1 = form0; + form1.password_value = ASCIIToUTF16("password1"); + AddLogin(GetPasswordStore(1), form1); ASSERT_TRUE(AwaitQuiescence()); - std::vector<PasswordForm> actual_zero; - GetLogins(GetPasswordStore(0), form, actual_zero); - ASSERT_EQ(1U, actual_zero.size()); + std::vector<PasswordForm> forms0; + GetLogins(GetPasswordStore(0), forms0); + ASSERT_EQ(1U, forms0.size()); - std::vector<PasswordForm> actual_one; - GetLogins(GetPasswordStore(1), form, actual_one); - ASSERT_EQ(1U, actual_one.size()); + std::vector<PasswordForm> forms1; + GetLogins(GetPasswordStore(1), forms1); + ASSERT_EQ(1U, forms1.size()); - ASSERT_TRUE(ContainsSamePasswordForms(actual_zero, actual_one)); + ASSERT_TRUE(ContainsSamePasswordForms(forms0, forms1)); } -// TODO(sync): Remove FAILS_ annotation after http://crbug.com/59867 is fixed. -#if defined(OS_MACOSX) -IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, FAILS_SetPassphrase) { -#else IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, SetPassphrase) { -#endif ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - GetClient(0)->service()->SetPassphrase(kValidPassphrase, true, true); - GetClient(0)->AwaitPassphraseAccepted(); - GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)); - ASSERT_TRUE(GetClient(1)->service()->observed_passphrase_required()); - GetClient(1)->service()->SetPassphrase(kValidPassphrase, true, true); - GetClient(1)->AwaitPassphraseAccepted(); - ASSERT_FALSE(GetClient(1)->service()->observed_passphrase_required()); + + SetPassphrase(0, kValidPassphrase, true); + ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + + SetPassphrase(1, kValidPassphrase, false); + ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); } -// TODO(sync): Remove FAILS_ annotation after http://crbug.com/59867 is fixed. -#if defined(OS_MACOSX) -IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, - FAILS_SetPassphraseAndAddPassword) { -#else IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, SetPassphraseAndAddPassword) { -#endif ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - GetClient(0)->service()->SetPassphrase(kValidPassphrase, true, true); - GetClient(0)->AwaitPassphraseAccepted(); - PasswordForm form; - form.origin = GURL("http://www.google.com/"); - form.username_value = ASCIIToUTF16("username"); - form.password_value = ASCIIToUTF16("password"); + SetPassphrase(0, kValidPassphrase, true); + ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + SetPassphrase(1, kValidPassphrase, false); + ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); + + PasswordForm form = CreateTestPasswordForm(0); AddLogin(GetPasswordStore(0), form); - GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)); - ASSERT_TRUE(GetClient(1)->service()->observed_passphrase_required()); - ASSERT_EQ(1, GetClient(1)->GetLastSessionSnapshot()-> - num_conflicting_updates); - - GetClient(1)->service()->SetPassphrase(kValidPassphrase, true, true); - GetClient(1)->AwaitPassphraseAccepted(); - ASSERT_FALSE(GetClient(1)->service()->observed_passphrase_required()); - GetClient(1)->AwaitSyncCycleCompletion("Accept passphrase and decrypt."); - ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> - num_conflicting_updates); + std::vector<PasswordForm> forms0; + GetLogins(GetPasswordStore(0), forms0); + ASSERT_EQ(1U, forms0.size()); + + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + + std::vector<PasswordForm> forms1; + GetLogins(GetPasswordStore(1), forms1); + ASSERT_EQ(1U, forms1.size()); } -// TODO(sync): Remove DISABLED_ annotation after http://crbug.com/59867 and -// http://crbug.com/67862 are fixed. +// TODO(rsimha): This test fails on mac -- see http://crbug.com/77956. +#if defined(OS_MACOSX) +IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, + FAILS_SetPassphraseAndThenSetupSync) { +#else IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, - DISABLED_SetPassphraseAndThenSetupSync) { + SetPassphraseAndThenSetupSync) { +#endif ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; + ASSERT_TRUE(GetClient(0)->SetupSync()); - GetClient(0)->service()->SetPassphrase(kValidPassphrase, true, true); - GetClient(0)->AwaitPassphraseAccepted(); - GetClient(0)->AwaitSyncCycleCompletion("Initial sync."); + SetPassphrase(0, kValidPassphrase, true); + ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); + ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Initial sync.")); + SetPassphrase(1, kValidPassphrase, false); ASSERT_TRUE(GetClient(1)->SetupSync()); - ASSERT_TRUE(AwaitQuiescence()); - ASSERT_TRUE(GetClient(1)->service()->observed_passphrase_required()); - GetClient(1)->service()->SetPassphrase(kValidPassphrase, true, true); - GetClient(1)->AwaitPassphraseAccepted(); - ASSERT_FALSE(GetClient(1)->service()->observed_passphrase_required()); + ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); } -// TODO(sync): Remove DISABLED_ annotation after http://crbug.com/59867 and -// http://crbug.com/67862 are fixed. -IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, - DISABLED_SetPassphraseTwice) { +IN_PROC_BROWSER_TEST_F(TwoClientLivePasswordsSyncTest, SetPassphraseTwice) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; - GetClient(0)->service()->SetPassphrase(kValidPassphrase, true, true); - GetClient(0)->AwaitPassphraseAccepted(); - GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)); - ASSERT_TRUE(GetClient(1)->service()->observed_passphrase_required()); + SetPassphrase(0, kValidPassphrase, true); + ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); - GetClient(1)->service()->SetPassphrase(kValidPassphrase, true, true); - GetClient(1)->AwaitPassphraseAccepted(); - ASSERT_FALSE(GetClient(1)->service()->observed_passphrase_required()); + SetPassphrase(1, kValidPassphrase, false); + ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); - GetClient(1)->service()->SetPassphrase(kValidPassphrase, true, true); - GetClient(1)->AwaitPassphraseAccepted(); - ASSERT_FALSE(GetClient(1)->service()->observed_passphrase_required()); + SetPassphrase(1, kValidPassphrase, false); + ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); } |