diff options
author | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-30 21:05:39 +0000 |
---|---|---|
committer | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-30 21:05:39 +0000 |
commit | ba1b34a685bc29ef05bfea61b4ca8f801c5146f9 (patch) | |
tree | 229077bb53b9e55489e28ececcb419d8c610e651 /chrome/test/live_sync | |
parent | cc63601ef120dcc54f6e8ac38feb7102aceeed51 (diff) | |
download | chromium_src-ba1b34a685bc29ef05bfea61b4ca8f801c5146f9.zip chromium_src-ba1b34a685bc29ef05bfea61b4ca8f801c5146f9.tar.gz chromium_src-ba1b34a685bc29ef05bfea61b4ca8f801c5146f9.tar.bz2 |
Refactor and rewrite of the password and passphrase sync integration tests
The sync password and passphrase integration tests have been in need of an overhaul due to the fact that the implementation of password and passphrase sync has changed significantly over the past couple months.
This patch updates the LivePasswordsSyncTest class, optimizes the wait methods in ProfileSyncServiceHarness related to passphrases, and simplifies the state machine used by SetupSync(). It also contains a partial rewrite of the password integration tests based on the updated framework.
BUG=59867, 67862, 77956
TEST=sync_integration_tests
Review URL: http://codereview.chromium.org/6698072
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79892 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/live_sync')
6 files changed, 256 insertions, 212 deletions
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()); } |