summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autofill/personal_data_manager.h2
-rw-r--r--chrome/chrome_tests.gypi10
-rw-r--r--chrome/test/live_sync/autofill_helper.cc (renamed from chrome/test/live_sync/live_autofill_sync_test.cc)83
-rw-r--r--chrome/test/live_sync/autofill_helper.h (renamed from chrome/test/live_sync/live_autofill_sync_test.h)70
-rw-r--r--chrome/test/live_sync/performance/autofill_sync_perf_test.cc37
-rw-r--r--chrome/test/live_sync/two_client_autofill_sync_test.cc437
-rw-r--r--chrome/test/live_sync/two_client_live_autofill_sync_test.cc360
7 files changed, 545 insertions, 454 deletions
diff --git a/chrome/browser/autofill/personal_data_manager.h b/chrome/browser/autofill/personal_data_manager.h
index da7b0b8..3e945ec 100644
--- a/chrome/browser/autofill/personal_data_manager.h
+++ b/chrome/browser/autofill/personal_data_manager.h
@@ -141,8 +141,8 @@ class PersonalDataManager
// Make sure that only Profile and certain tests can create an instance of
// PersonalDataManager.
friend class base::RefCountedThreadSafe<PersonalDataManager>;
+ friend class AutofillHelper;
friend class AutofillMergeTest;
- friend class LiveAutofillSyncTest;
friend class PersonalDataManagerTest;
friend class ProfileImpl;
friend class ProfileSyncServiceAutofillTest;
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 6b1accd..d0356e1 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -3503,12 +3503,12 @@
'test/base/test_notification_tracker.cc',
'test/base/test_notification_tracker.h',
'test/data/resource.rc',
+ 'test/live_sync/autofill_helper.cc',
+ 'test/live_sync/autofill_helper.h',
'test/live_sync/bookmarks_helper.cc',
'test/live_sync/bookmarks_helper.h',
'test/live_sync/live_apps_sync_test.cc',
'test/live_sync/live_apps_sync_test.h',
- 'test/live_sync/live_autofill_sync_test.cc',
- 'test/live_sync/live_autofill_sync_test.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',
@@ -3545,9 +3545,9 @@
'test/live_sync/sync_datatype_helper.cc',
'test/live_sync/sync_datatype_helper.h',
'test/live_sync/sync_errors_test.cc',
+ 'test/live_sync/two_client_autofill_sync_test.cc',
'test/live_sync/two_client_bookmarks_sync_test.cc',
'test/live_sync/two_client_live_apps_sync_test.cc',
- 'test/live_sync/two_client_live_autofill_sync_test.cc',
'test/live_sync/two_client_live_extensions_sync_test.cc',
'test/live_sync/two_client_live_passwords_sync_test.cc',
'test/live_sync/two_client_live_sessions_sync_test.cc',
@@ -3640,10 +3640,10 @@
'sources': [
'browser/password_manager/password_form_data.cc',
'test/base/out_of_proc_test_runner.cc',
+ 'test/live_sync/autofill_helper.cc',
+ 'test/live_sync/autofill_helper.h',
'test/live_sync/bookmarks_helper.cc',
'test/live_sync/bookmarks_helper.h',
- 'test/live_sync/live_autofill_sync_test.cc',
- 'test/live_sync/live_autofill_sync_test.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',
diff --git a/chrome/test/live_sync/live_autofill_sync_test.cc b/chrome/test/live_sync/autofill_helper.cc
index 5ee55c6..b81d8e2 100644
--- a/chrome/test/live_sync/live_autofill_sync_test.cc
+++ b/chrome/test/live_sync/autofill_helper.cc
@@ -2,7 +2,7 @@
// 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_autofill_sync_test.h"
+#include "chrome/test/live_sync/autofill_helper.h"
#include "chrome/browser/autofill/autofill_common_test.h"
#include "chrome/browser/autofill/autofill_profile.h"
@@ -14,6 +14,7 @@
#include "chrome/browser/webdata/autofill_table.h"
#include "chrome/browser/webdata/web_database.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/test/live_sync/live_sync_test.h"
#include "chrome/test/base/thread_observer_helper.h"
#include "webkit/glue/form_field.h"
@@ -79,10 +80,15 @@ class MockPersonalDataManagerObserver : public PersonalDataManager::Observer {
} // namespace
-AutofillProfile CreateAutofillProfile(LiveAutofillSyncTest::ProfileType type) {
+AutofillHelper::AutofillHelper() {}
+
+AutofillHelper::~AutofillHelper() {}
+
+// static
+AutofillProfile AutofillHelper::CreateAutofillProfile(ProfileType type) {
AutofillProfile profile;
switch (type) {
- case LiveAutofillSyncTest::PROFILE_MARION:
+ case PROFILE_MARION:
autofill_test::SetProfileInfoWithGuid(&profile,
"C837507A-6C3B-4872-AC14-5113F157D668",
"Marion", "Mitchell", "Morrison",
@@ -90,7 +96,7 @@ AutofillProfile CreateAutofillProfile(LiveAutofillSyncTest::ProfileType type) {
"123 Zoo St.", "unit 5", "Hollywood", "CA",
"91601", "US", "12345678910", "01987654321");
break;
- case LiveAutofillSyncTest::PROFILE_HOMER:
+ case PROFILE_HOMER:
autofill_test::SetProfileInfoWithGuid(&profile,
"137DE1C3-6A30-4571-AC86-109B1ECFBE7F",
"Homer", "J.", "Simpson",
@@ -98,14 +104,14 @@ AutofillProfile CreateAutofillProfile(LiveAutofillSyncTest::ProfileType type) {
"1 Main St", "PO Box 1", "Springfield", "MA",
"94101", "US", "14155551212", "14155551313");
break;
- case LiveAutofillSyncTest::PROFILE_FRASIER:
+ case PROFILE_FRASIER:
autofill_test::SetProfileInfoWithGuid(&profile,
"9A5E6872-6198-4688-BF75-0016E781BB0A",
"Frasier", "Winslow", "Crane",
"", "randomness", "", "Apt. 4", "Seattle", "WA",
"99121", "US", "0000000000", "ABCDEFGHIJK");
break;
- case LiveAutofillSyncTest::PROFILE_NULL:
+ case PROFILE_NULL:
autofill_test::SetProfileInfoWithGuid(&profile,
"FE461507-7E13-4198-8E66-74C7DB6D8322",
"", "", "", "", "", "", "", "", "", "", "", "", "");
@@ -114,21 +120,19 @@ AutofillProfile CreateAutofillProfile(LiveAutofillSyncTest::ProfileType type) {
return profile;
}
-LiveAutofillSyncTest::LiveAutofillSyncTest(TestType test_type)
- : LiveSyncTest(test_type) {}
-
-LiveAutofillSyncTest::~LiveAutofillSyncTest() {}
-
-WebDataService* LiveAutofillSyncTest::GetWebDataService(int index) {
- return GetProfile(index)->GetWebDataService(Profile::EXPLICIT_ACCESS);
+// static
+WebDataService* AutofillHelper::GetWebDataService(int index) {
+ return test()->GetProfile(index)->GetWebDataService(Profile::EXPLICIT_ACCESS);
}
-PersonalDataManager* LiveAutofillSyncTest::GetPersonalDataManager(int index) {
- return GetProfile(index)->GetPersonalDataManager();
+// static
+PersonalDataManager* AutofillHelper::GetPersonalDataManager(int index) {
+ return test()->GetProfile(index)->GetPersonalDataManager();
}
-void LiveAutofillSyncTest::AddKeys(int profile,
- const std::set<AutofillKey>& keys) {
+// static
+void AutofillHelper::AddKeys(int profile,
+ const std::set<AutofillKey>& keys) {
std::vector<webkit_glue::FormField> form_fields;
for (std::set<AutofillKey>::const_iterator i = keys.begin();
i != keys.end();
@@ -153,7 +157,8 @@ void LiveAutofillSyncTest::AddKeys(int profile,
done_event.Wait();
}
-void LiveAutofillSyncTest::RemoveKey(int profile, const AutofillKey& key) {
+// static
+void AutofillHelper::RemoveKey(int profile, const AutofillKey& key) {
WaitableEvent done_event(false, false);
scoped_refptr<AutofillDBThreadObserverHelper> observer_helper(
new AutofillDBThreadObserverHelper());
@@ -166,7 +171,8 @@ void LiveAutofillSyncTest::RemoveKey(int profile, const AutofillKey& key) {
done_event.Wait();
}
-std::set<AutofillEntry> LiveAutofillSyncTest::GetAllKeys(int profile) {
+// static
+std::set<AutofillEntry> AutofillHelper::GetAllKeys(int profile) {
WebDataService* wds = GetWebDataService(profile);
scoped_refptr<GetAllAutofillEntries> get_all_entries =
new GetAllAutofillEntries(wds);
@@ -180,11 +186,13 @@ std::set<AutofillEntry> LiveAutofillSyncTest::GetAllKeys(int profile) {
return all_keys;
}
-bool LiveAutofillSyncTest::KeysMatch(int profile_a, int profile_b) {
+// static
+bool AutofillHelper::KeysMatch(int profile_a, int profile_b) {
return GetAllKeys(profile_a) == GetAllKeys(profile_b);
}
-void LiveAutofillSyncTest::SetProfiles(
+// static
+void AutofillHelper::SetProfiles(
int profile, std::vector<AutofillProfile>* autofill_profiles) {
MockPersonalDataManagerObserver observer;
EXPECT_CALL(observer, OnPersonalDataChanged()).
@@ -196,8 +204,9 @@ void LiveAutofillSyncTest::SetProfiles(
pdm->RemoveObserver(&observer);
}
-void LiveAutofillSyncTest::AddProfile(int profile,
- const AutofillProfile& autofill_profile) {
+// static
+void AutofillHelper::AddProfile(int profile,
+ const AutofillProfile& autofill_profile) {
const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
std::vector<AutofillProfile> autofill_profiles;
for (size_t i = 0; i < all_profiles.size(); ++i)
@@ -206,7 +215,8 @@ void LiveAutofillSyncTest::AddProfile(int profile,
SetProfiles(profile, &autofill_profiles);
}
-void LiveAutofillSyncTest::RemoveProfile(int profile, const std::string& guid) {
+// static
+void AutofillHelper::RemoveProfile(int profile, const std::string& guid) {
const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
std::vector<AutofillProfile> autofill_profiles;
for (size_t i = 0; i < all_profiles.size(); ++i) {
@@ -216,10 +226,11 @@ void LiveAutofillSyncTest::RemoveProfile(int profile, const std::string& guid) {
SetProfiles(profile, &autofill_profiles);
}
-void LiveAutofillSyncTest::UpdateProfile(int profile,
- const std::string& guid,
- const AutofillType& type,
- const string16& value) {
+// static
+void AutofillHelper::UpdateProfile(int profile,
+ const std::string& guid,
+ const AutofillType& type,
+ const string16& value) {
const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
std::vector<AutofillProfile> profiles;
for (size_t i = 0; i < all_profiles.size(); ++i) {
@@ -230,7 +241,8 @@ void LiveAutofillSyncTest::UpdateProfile(int profile,
SetProfiles(profile, &profiles);
}
-const std::vector<AutofillProfile*>& LiveAutofillSyncTest::GetAllProfiles(
+// static
+const std::vector<AutofillProfile*>& AutofillHelper::GetAllProfiles(
int profile) {
MockPersonalDataManagerObserver observer;
EXPECT_CALL(observer, OnPersonalDataChanged()).
@@ -243,11 +255,13 @@ const std::vector<AutofillProfile*>& LiveAutofillSyncTest::GetAllProfiles(
return pdm->web_profiles();
}
-int LiveAutofillSyncTest::GetProfileCount(int profile) {
+// static
+int AutofillHelper::GetProfileCount(int profile) {
return GetAllProfiles(profile).size();
}
-bool LiveAutofillSyncTest::ProfilesMatch(int profile_a, int profile_b) {
+// static
+bool AutofillHelper::ProfilesMatch(int profile_a, int profile_b) {
const std::vector<AutofillProfile*>& autofill_profiles_a =
GetAllProfiles(profile_a);
std::map<std::string, AutofillProfile> autofill_profiles_a_map;
@@ -276,14 +290,15 @@ bool LiveAutofillSyncTest::ProfilesMatch(int profile_a, int profile_b) {
if (autofill_profiles_a_map.size()) {
LOG(ERROR) << "Entries present in Profile " << profile_a
- << " but not in " << profile_b << ".";
+ << " but not in " << profile_b << ".";
return false;
}
return true;
}
-bool LiveAutofillSyncTest::AllProfilesMatch() {
- for (int i = 1; i < num_clients(); ++i) {
+// static
+bool AutofillHelper::AllProfilesMatch() {
+ for (int i = 1; i < test()->num_clients(); ++i) {
if (!ProfilesMatch(0, i)) {
LOG(ERROR) << "Profile " << i << "does not contain the same autofill "
"profiles as profile 0.";
diff --git a/chrome/test/live_sync/live_autofill_sync_test.h b/chrome/test/live_sync/autofill_helper.h
index c5bb58a..0c3dee4 100644
--- a/chrome/test/live_sync/live_autofill_sync_test.h
+++ b/chrome/test/live_sync/autofill_helper.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_TEST_LIVE_SYNC_LIVE_AUTOFILL_SYNC_TEST_H_
-#define CHROME_TEST_LIVE_SYNC_LIVE_AUTOFILL_SYNC_TEST_H_
+#ifndef CHROME_TEST_LIVE_SYNC_AUTOFILL_HELPER_H_
+#define CHROME_TEST_LIVE_SYNC_AUTOFILL_HELPER_H_
#pragma once
#include <set>
@@ -11,14 +11,14 @@
#include "base/compiler_specific.h"
#include "chrome/browser/autofill/personal_data_manager.h"
-#include "chrome/test/live_sync/live_sync_test.h"
+#include "chrome/test/live_sync/sync_datatype_helper.h"
class AutofillEntry;
class AutofillKey;
class AutofillProfile;
class WebDataService;
-class LiveAutofillSyncTest : public LiveSyncTest {
+class AutofillHelper : public SyncDatatypeHelper {
public:
enum ProfileType {
PROFILE_MARION,
@@ -27,78 +27,72 @@ class LiveAutofillSyncTest : public LiveSyncTest {
PROFILE_NULL
};
- explicit LiveAutofillSyncTest(TestType test_type);
- virtual ~LiveAutofillSyncTest();
-
// Used to access the web data service within a particular sync profile.
- WebDataService* GetWebDataService(int index) WARN_UNUSED_RESULT;
+ static WebDataService* GetWebDataService(int index) WARN_UNUSED_RESULT;
// Used to access the personal data manager within a particular sync profile.
- PersonalDataManager* GetPersonalDataManager(int index) WARN_UNUSED_RESULT;
+ static PersonalDataManager* GetPersonalDataManager(
+ int index) WARN_UNUSED_RESULT;
// Adds the form fields in |keys| to the WebDataService of sync profile
// |profile|.
- void AddKeys(int profile, const std::set<AutofillKey>& keys);
+ static void AddKeys(int profile, const std::set<AutofillKey>& keys);
+
// Removes the form field in |key| from the WebDataService of sync profile
// |profile|.
- void RemoveKey(int profile, const AutofillKey& key);
+ static void RemoveKey(int profile, const AutofillKey& key);
// Gets all the form fields in the WebDataService of sync profile |profile|.
- std::set<AutofillEntry> GetAllKeys(int profile) WARN_UNUSED_RESULT;
+ static std::set<AutofillEntry> GetAllKeys(int profile) WARN_UNUSED_RESULT;
// Compares the form fields in the WebDataServices of sync profiles
// |profile_a| and |profile_b|. Returns true if they match.
- bool KeysMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT;
+ static bool KeysMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT;
// Replaces the Autofill profiles in sync profile |profile| with
// |autofill_profiles|.
- void SetProfiles(
- int profile, std::vector<AutofillProfile>* autofill_profiles);
+ static void SetProfiles(int profile,
+ std::vector<AutofillProfile>* autofill_profiles);
// Adds the autofill profile |autofill_profile| to sync profile |profile|.
- void AddProfile(int profile, const AutofillProfile& autofill_profile);
+ static void AddProfile(int profile, const AutofillProfile& autofill_profile);
// Removes the autofill profile with guid |guid| from sync profile
// |profile|.
- void RemoveProfile(int profile, const std::string& guid);
+ static void RemoveProfile(int profile, const std::string& guid);
// Updates the autofill profile with guid |guid| in sync profile |profile|
// to |type| and |value|.
- void UpdateProfile(int profile,
- const std::string& guid,
- const AutofillType& type,
- const string16& value);
+ static void UpdateProfile(int profile,
+ const std::string& guid,
+ const AutofillType& type,
+ const string16& value);
// Gets all the Autofill profiles in the PersonalDataManager of sync profile
// |profile|.
- const std::vector<AutofillProfile*>& GetAllProfiles(int profile)
- WARN_UNUSED_RESULT;
+ static const std::vector<AutofillProfile*>& GetAllProfiles(
+ int profile) WARN_UNUSED_RESULT;
// Returns the number of autofill profiles contained by sync profile
// |profile|.
- int GetProfileCount(int profile);
+ static int GetProfileCount(int profile);
// Compares the Autofill profiles in the PersonalDataManagers of sync profiles
// |profile_a| and |profile_b|. Returns true if they match.
- bool ProfilesMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT;
+ static bool ProfilesMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT;
// Compares the autofill profiles for all sync profiles, and returns true if
// they all match.
- bool AllProfilesMatch() WARN_UNUSED_RESULT;
+ static bool AllProfilesMatch() WARN_UNUSED_RESULT;
- private:
- DISALLOW_COPY_AND_ASSIGN(LiveAutofillSyncTest);
-};
-
-AutofillProfile CreateAutofillProfile(LiveAutofillSyncTest::ProfileType type);
-
-class TwoClientLiveAutofillSyncTest : public LiveAutofillSyncTest {
- public:
- TwoClientLiveAutofillSyncTest() : LiveAutofillSyncTest(TWO_CLIENT) {}
- virtual ~TwoClientLiveAutofillSyncTest() {}
+ // Creates a test autofill profile based on the persona specified in |type|.
+ static AutofillProfile CreateAutofillProfile(ProfileType type);
+ protected:
+ AutofillHelper();
+ virtual ~AutofillHelper();
private:
- DISALLOW_COPY_AND_ASSIGN(TwoClientLiveAutofillSyncTest);
+ DISALLOW_COPY_AND_ASSIGN(AutofillHelper);
};
-#endif // CHROME_TEST_LIVE_SYNC_LIVE_AUTOFILL_SYNC_TEST_H_
+#endif // CHROME_TEST_LIVE_SYNC_AUTOFILL_HELPER_H_
diff --git a/chrome/test/live_sync/performance/autofill_sync_perf_test.cc b/chrome/test/live_sync/performance/autofill_sync_perf_test.cc
index 685d7c4..f37d01c 100644
--- a/chrome/test/live_sync/performance/autofill_sync_perf_test.cc
+++ b/chrome/test/live_sync/performance/autofill_sync_perf_test.cc
@@ -6,7 +6,8 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/autofill/autofill_common_test.h"
#include "chrome/browser/sync/profile_sync_service_harness.h"
-#include "chrome/test/live_sync/live_autofill_sync_test.h"
+#include "chrome/test/live_sync/autofill_helper.h"
+#include "chrome/test/live_sync/live_sync_test.h"
#include "chrome/test/live_sync/performance/sync_timing_helper.h"
// TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all
@@ -17,9 +18,12 @@ static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125,
150, 175, 200, 225, 250, 300, 350, 400,
500};
-class AutofillSyncPerfTest : public TwoClientLiveAutofillSyncTest {
+class AutofillSyncPerfTest : public LiveSyncTest {
public:
- AutofillSyncPerfTest() : guid_number_(0), name_number_(0) {}
+ AutofillSyncPerfTest()
+ : LiveSyncTest(TWO_CLIENT),
+ guid_number_(0),
+ name_number_(0) {}
// Adds |num_profiles| new autofill profiles to the sync profile |profile|.
void AddProfiles(int profile, int num_profiles);
@@ -55,9 +59,9 @@ class AutofillSyncPerfTest : public TwoClientLiveAutofillSyncTest {
DISALLOW_COPY_AND_ASSIGN(AutofillSyncPerfTest);
};
-void AutofillSyncPerfTest::AddProfiles(int profile,
- int num_profiles) {
- const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
+void AutofillSyncPerfTest::AddProfiles(int profile, int num_profiles) {
+ const std::vector<AutofillProfile*>& all_profiles =
+ AutofillHelper::GetAllProfiles(profile);
std::vector<AutofillProfile> autofill_profiles;
for (size_t i = 0; i < all_profiles.size(); ++i) {
autofill_profiles.push_back(*all_profiles[i]);
@@ -65,23 +69,24 @@ void AutofillSyncPerfTest::AddProfiles(int profile,
for (int i = 0; i < num_profiles; ++i) {
autofill_profiles.push_back(NextAutofillProfile());
}
- SetProfiles(profile, &autofill_profiles);
+ AutofillHelper::SetProfiles(profile, &autofill_profiles);
}
void AutofillSyncPerfTest::UpdateProfiles(int profile) {
- const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
+ const std::vector<AutofillProfile*>& all_profiles =
+ AutofillHelper::GetAllProfiles(profile);
std::vector<AutofillProfile> autofill_profiles;
for (size_t i = 0; i < all_profiles.size(); ++i) {
autofill_profiles.push_back(*all_profiles[i]);
autofill_profiles.back().SetInfo(AutofillFieldType(NAME_FIRST),
UTF8ToUTF16(NextName()));
}
- SetProfiles(profile, &autofill_profiles);
+ AutofillHelper::SetProfiles(profile, &autofill_profiles);
}
void AutofillSyncPerfTest::RemoveProfiles(int profile) {
std::vector<AutofillProfile> empty;
- SetProfiles(profile, &empty);
+ AutofillHelper::SetProfiles(profile, &empty);
}
void AutofillSyncPerfTest::Cleanup() {
@@ -146,24 +151,24 @@ IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, DISABLED_Benchmark) {
AddProfiles(0, num_profiles);
base::TimeDelta dt_add =
SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
- ASSERT_EQ(num_profiles, GetProfileCount(0));
- ASSERT_TRUE(AllProfilesMatch());
+ ASSERT_EQ(num_profiles, AutofillHelper::GetProfileCount(0));
+ ASSERT_TRUE(AutofillHelper::AllProfilesMatch());
VLOG(0) << std::endl << "Add: " << num_profiles << " "
<< dt_add.InSecondsF();
UpdateProfiles(0);
base::TimeDelta dt_update =
SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
- ASSERT_EQ(num_profiles, GetProfileCount(0));
- ASSERT_TRUE(AllProfilesMatch());
+ ASSERT_EQ(num_profiles, AutofillHelper::GetProfileCount(0));
+ ASSERT_TRUE(AutofillHelper::AllProfilesMatch());
VLOG(0) << std::endl << "Update: " << num_profiles << " "
<< dt_update.InSecondsF();
RemoveProfiles(0);
base::TimeDelta dt_delete =
SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
- ASSERT_EQ(0, GetProfileCount(0));
- ASSERT_TRUE(AllProfilesMatch());
+ ASSERT_EQ(0, AutofillHelper::GetProfileCount(0));
+ ASSERT_TRUE(AutofillHelper::AllProfilesMatch());
VLOG(0) << std::endl << "Delete: " << num_profiles << " "
<< dt_delete.InSecondsF();
diff --git a/chrome/test/live_sync/two_client_autofill_sync_test.cc b/chrome/test/live_sync/two_client_autofill_sync_test.cc
new file mode 100644
index 0000000..9925e46
--- /dev/null
+++ b/chrome/test/live_sync/two_client_autofill_sync_test.cc
@@ -0,0 +1,437 @@
+// 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 "base/utf_string_conversions.h"
+#include "chrome/browser/sync/profile_sync_service_harness.h"
+#include "chrome/browser/webdata/autofill_entry.h"
+#include "chrome/test/live_sync/autofill_helper.h"
+#include "chrome/test/live_sync/live_sync_test.h"
+
+// Autofill entry length is limited to 1024. See http://crbug.com/49332.
+const size_t kMaxDataLength = 1024;
+
+class TwoClientAutofillSyncTest : public LiveSyncTest {
+ public:
+ TwoClientAutofillSyncTest() : LiveSyncTest(TWO_CLIENT) {}
+ virtual ~TwoClientAutofillSyncTest() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TwoClientAutofillSyncTest);
+};
+
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, WebDataServiceSanity) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ // Client0 adds a key.
+ std::set<AutofillKey> keys;
+ keys.insert(AutofillKey("name0", "value0"));
+ AutofillHelper::AddKeys(0, keys);
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::KeysMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllKeys(0).size());
+
+ // Client1 adds a key.
+ keys.clear();
+ keys.insert(AutofillKey("name1", "value1-0"));
+ AutofillHelper::AddKeys(1, keys);
+ ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
+ ASSERT_TRUE(AutofillHelper::KeysMatch(0, 1));
+ ASSERT_EQ(2U, AutofillHelper::GetAllKeys(0).size());
+
+ // Client0 adds a key with the same name.
+ keys.clear();
+ keys.insert(AutofillKey("name1", "value1-1"));
+ AutofillHelper::AddKeys(0, keys);
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::KeysMatch(0, 1));
+ ASSERT_EQ(3U, AutofillHelper::GetAllKeys(0).size());
+
+ // Client1 removes a key.
+ AutofillHelper::RemoveKey(1, AutofillKey("name1", "value1-0"));
+ ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
+ ASSERT_TRUE(AutofillHelper::KeysMatch(0, 1));
+ ASSERT_EQ(2U, AutofillHelper::GetAllKeys(0).size());
+
+ // Client0 removes the rest.
+ AutofillHelper::RemoveKey(0, AutofillKey("name0", "value0"));
+ AutofillHelper::RemoveKey(0, AutofillKey("name1", "value1-1"));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::KeysMatch(0, 1));
+ ASSERT_EQ(0U, AutofillHelper::GetAllKeys(0).size());
+}
+
+// TCM ID - 3678296.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddUnicodeProfile) {
+ ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
+
+ std::set<AutofillKey> keys;
+ keys.insert(AutofillKey(WideToUTF16(L"Sigur R\u00F3s"),
+ WideToUTF16(L"\u00C1g\u00E6tis byrjun")));
+ AutofillHelper::AddKeys(0, keys);
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ ASSERT_TRUE(AwaitQuiescence());
+ ASSERT_TRUE(AutofillHelper::KeysMatch(0, 1));
+}
+
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest,
+ AddDuplicateNamesToSameProfile) {
+ ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
+
+ std::set<AutofillKey> keys;
+ keys.insert(AutofillKey("name0", "value0-0"));
+ keys.insert(AutofillKey("name0", "value0-1"));
+ keys.insert(AutofillKey("name1", "value1"));
+ AutofillHelper::AddKeys(0, keys);
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ ASSERT_TRUE(AwaitQuiescence());
+ ASSERT_TRUE(AutofillHelper::KeysMatch(0, 1));
+ ASSERT_EQ(2U, AutofillHelper::GetAllKeys(0).size());
+}
+
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest,
+ AddDuplicateNamesToDifferentProfiles) {
+ ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
+
+ std::set<AutofillKey> keys0;
+ keys0.insert(AutofillKey("name0", "value0-0"));
+ keys0.insert(AutofillKey("name1", "value1"));
+ AutofillHelper::AddKeys(0, keys0);
+
+ std::set<AutofillKey> keys1;
+ keys1.insert(AutofillKey("name0", "value0-1"));
+ keys1.insert(AutofillKey("name2", "value2"));
+ keys1.insert(AutofillKey("name3", "value3"));
+ AutofillHelper::AddKeys(1, keys1);
+
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ ASSERT_TRUE(AwaitQuiescence());
+ ASSERT_TRUE(AutofillHelper::KeysMatch(0, 1));
+ ASSERT_EQ(5U, AutofillHelper::GetAllKeys(0).size());
+}
+
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest,
+ PersonalDataManagerSanity) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ // Client0 adds a profile.
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+
+ // Client1 adds a profile.
+ AutofillHelper::AddProfile(
+ 1, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_MARION));
+ ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(2U, AutofillHelper::GetAllProfiles(0).size());
+
+ // Client0 adds the same profile.
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_MARION));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(2U, AutofillHelper::GetAllProfiles(0).size());
+
+ // Client1 removes a profile.
+ AutofillHelper::RemoveProfile(
+ 1, AutofillHelper::GetAllProfiles(1)[0]->guid());
+ ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+
+ // Client0 updates a profile.
+ AutofillHelper::UpdateProfile(
+ 0,
+ AutofillHelper::GetAllProfiles(0)[0]->guid(),
+ AutofillType(NAME_FIRST),
+ ASCIIToUTF16("Bart"));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+
+ // Client1 removes remaining profile.
+ AutofillHelper::RemoveProfile(
+ 1, AutofillHelper::GetAllProfiles(1)[0]->guid());
+ ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(0U, AutofillHelper::GetAllProfiles(0).size());
+}
+
+// TCM ID - 7261786.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddDuplicateProfiles) {
+ ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
+
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ ASSERT_TRUE(AwaitQuiescence());
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+}
+
+// TCM ID - 3636294.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, SameProfileWithConflict) {
+ ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
+
+ AutofillProfile profile0 =
+ AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER);
+ AutofillProfile profile1 =
+ AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER);
+ profile1.SetInfo(PHONE_FAX_WHOLE_NUMBER, ASCIIToUTF16("1234567890"));
+
+ AutofillHelper::AddProfile(0, profile0);
+ AutofillHelper::AddProfile(1, profile1);
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ ASSERT_TRUE(AwaitQuiescence());
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+}
+
+// TCM ID - 3626291.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddEmptyProfile) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_NULL));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(0U, AutofillHelper::GetAllProfiles(0).size());
+}
+
+// TCM ID - 3616283.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddProfile) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+}
+
+// TCM ID - 3632260.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddMultipleProfiles) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_MARION));
+ AutofillHelper::AddProfile(
+ 0,
+ AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_FRASIER));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(3U, AutofillHelper::GetAllProfiles(0).size());
+}
+
+// TCM ID - 3602257.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DeleteProfile) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+
+ AutofillHelper::RemoveProfile(
+ 1, AutofillHelper::GetAllProfiles(1)[0]->guid());
+ ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(0U, AutofillHelper::GetAllProfiles(0).size());
+}
+
+// TCM ID - 3627300.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MergeProfiles) {
+ ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
+
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ AutofillHelper::AddProfile(
+ 1, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_MARION));
+ AutofillHelper::AddProfile(
+ 1,
+ AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_FRASIER));
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ ASSERT_TRUE(AwaitQuiescence());
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(3U, AutofillHelper::GetAllProfiles(0).size());
+}
+
+// TCM ID - 3665264.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, UpdateFields) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+
+ AutofillHelper::UpdateProfile(
+ 0,
+ AutofillHelper::GetAllProfiles(0)[0]->guid(),
+ AutofillType(NAME_FIRST),
+ ASCIIToUTF16("Lisa"));
+ AutofillHelper::UpdateProfile(
+ 0,
+ AutofillHelper::GetAllProfiles(0)[0]->guid(),
+ AutofillType(EMAIL_ADDRESS),
+ ASCIIToUTF16("grrrl@TV.com"));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+}
+
+// TCM ID - 3628299.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ConflictingFields) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+ AutofillHelper::UpdateProfile(
+ 0,
+ AutofillHelper::GetAllProfiles(0)[0]->guid(),
+ AutofillType(NAME_FIRST),
+ ASCIIToUTF16("Lisa"));
+ AutofillHelper::UpdateProfile(
+ 1,
+ AutofillHelper::GetAllProfiles(1)[0]->guid(),
+ AutofillType(NAME_FIRST),
+ ASCIIToUTF16("Bart"));
+ ASSERT_TRUE(AwaitQuiescence());
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+}
+
+// TCM ID - 3663293.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DisableAutofill) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+
+ ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncable::AUTOFILL));
+ AutofillHelper::AddProfile(
+ 0,
+ AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_FRASIER));
+ ASSERT_TRUE(AwaitQuiescence());
+ ASSERT_FALSE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(2U, AutofillHelper::GetAllProfiles(0).size());
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(1).size());
+
+ ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncable::AUTOFILL));
+ ASSERT_TRUE(AwaitQuiescence());
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(2U, AutofillHelper::GetAllProfiles(0).size());
+}
+
+// TCM ID - 3661291.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DisableSync) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+
+ ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes());
+ AutofillHelper::AddProfile(
+ 0,
+ AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_FRASIER));
+ ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Added a profile."));
+ ASSERT_FALSE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(2U, AutofillHelper::GetAllProfiles(0).size());
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(1).size());
+
+ ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes());
+ ASSERT_TRUE(AwaitQuiescence());
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(2U, AutofillHelper::GetAllProfiles(0).size());
+}
+
+// TCM ID - 3608295.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MaxLength) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+
+ string16 max_length_string(kMaxDataLength, '.');
+ AutofillHelper::UpdateProfile(
+ 0,
+ AutofillHelper::GetAllProfiles(0)[0]->guid(),
+ AutofillType(NAME_FIRST),
+ max_length_string);
+ AutofillHelper::UpdateProfile(
+ 0,
+ AutofillHelper::GetAllProfiles(0)[0]->guid(),
+ AutofillType(NAME_LAST),
+ max_length_string);
+ AutofillHelper::UpdateProfile(
+ 0,
+ AutofillHelper::GetAllProfiles(0)[0]->guid(),
+ AutofillType(EMAIL_ADDRESS),
+ max_length_string);
+ AutofillHelper::UpdateProfile(
+ 0,
+ AutofillHelper::GetAllProfiles(0)[0]->guid(),
+ AutofillType(ADDRESS_HOME_LINE1),
+ max_length_string);
+
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+}
+
+// TODO(braffert): Remove FAILS annotation when crbug.com/85769 is resolved.
+// TCM ID - 7735472.
+IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, FAILS_ExceedsMaxLength) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ AutofillHelper::AddProfile(
+ 0, AutofillHelper::CreateAutofillProfile(AutofillHelper::PROFILE_HOMER));
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AutofillHelper::ProfilesMatch(0, 1));
+ ASSERT_EQ(1U, AutofillHelper::GetAllProfiles(0).size());
+
+ string16 exceeds_max_length_string(kMaxDataLength + 1, '.');
+ AutofillHelper::UpdateProfile(
+ 0,
+ AutofillHelper::GetAllProfiles(0)[0]->guid(),
+ AutofillType(NAME_FIRST),
+ exceeds_max_length_string);
+ AutofillHelper::UpdateProfile(
+ 0,
+ AutofillHelper::GetAllProfiles(0)[0]->guid(),
+ AutofillType(NAME_LAST),
+ exceeds_max_length_string);
+ AutofillHelper::UpdateProfile(
+ 0,
+ AutofillHelper::GetAllProfiles(0)[0]->guid(),
+ AutofillType(EMAIL_ADDRESS),
+ exceeds_max_length_string);
+ AutofillHelper::UpdateProfile(
+ 0,
+ AutofillHelper::GetAllProfiles(0)[0]->guid(),
+ AutofillType(ADDRESS_HOME_LINE1),
+ exceeds_max_length_string);
+
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_FALSE(AutofillHelper::ProfilesMatch(0, 1));
+}
diff --git a/chrome/test/live_sync/two_client_live_autofill_sync_test.cc b/chrome/test/live_sync/two_client_live_autofill_sync_test.cc
deleted file mode 100644
index 1d891fb..0000000
--- a/chrome/test/live_sync/two_client_live_autofill_sync_test.cc
+++ /dev/null
@@ -1,360 +0,0 @@
-// 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 "base/utf_string_conversions.h"
-#include "chrome/browser/sync/profile_sync_service_harness.h"
-#include "chrome/browser/webdata/autofill_entry.h"
-#include "chrome/test/live_sync/live_autofill_sync_test.h"
-
-// Autofill entry length is limited to 1024. See http://crbug.com/49332.
-const size_t kMaxDataLength = 1024;
-
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, WebDataServiceSanity) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- // Client0 adds a key.
- std::set<AutofillKey> keys;
- keys.insert(AutofillKey("name0", "value0"));
- AddKeys(0, keys);
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(KeysMatch(0, 1));
- ASSERT_EQ(1U, GetAllKeys(0).size());
-
- // Client1 adds a key.
- keys.clear();
- keys.insert(AutofillKey("name1", "value1-0"));
- AddKeys(1, keys);
- ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
- ASSERT_TRUE(KeysMatch(0, 1));
- ASSERT_EQ(2U, GetAllKeys(0).size());
-
- // Client0 adds a key with the same name.
- keys.clear();
- keys.insert(AutofillKey("name1", "value1-1"));
- AddKeys(0, keys);
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(KeysMatch(0, 1));
- ASSERT_EQ(3U, GetAllKeys(0).size());
-
- // Client1 removes a key.
- RemoveKey(1, AutofillKey("name1", "value1-0"));
- ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
- ASSERT_TRUE(KeysMatch(0, 1));
- ASSERT_EQ(2U, GetAllKeys(0).size());
-
- // Client0 removes the rest.
- RemoveKey(0, AutofillKey("name0", "value0"));
- RemoveKey(0, AutofillKey("name1", "value1-1"));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(KeysMatch(0, 1));
- ASSERT_EQ(0U, GetAllKeys(0).size());
-}
-
-// TCM ID - 3678296.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddUnicodeProfile) {
- ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
-
- std::set<AutofillKey> keys;
- keys.insert(AutofillKey(WideToUTF16(L"Sigur R\u00F3s"),
- WideToUTF16(L"\u00C1g\u00E6tis byrjun")));
- AddKeys(0, keys);
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
- ASSERT_TRUE(AwaitQuiescence());
- ASSERT_TRUE(KeysMatch(0, 1));
-}
-
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest,
- AddDuplicateNamesToSameProfile) {
- ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
-
- std::set<AutofillKey> keys;
- keys.insert(AutofillKey("name0", "value0-0"));
- keys.insert(AutofillKey("name0", "value0-1"));
- keys.insert(AutofillKey("name1", "value1"));
- AddKeys(0, keys);
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
- ASSERT_TRUE(AwaitQuiescence());
- ASSERT_TRUE(KeysMatch(0, 1));
- ASSERT_EQ(2U, GetAllKeys(0).size());
-}
-
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest,
- AddDuplicateNamesToDifferentProfiles) {
- ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
-
- std::set<AutofillKey> keys0;
- keys0.insert(AutofillKey("name0", "value0-0"));
- keys0.insert(AutofillKey("name1", "value1"));
- AddKeys(0, keys0);
-
- std::set<AutofillKey> keys1;
- keys1.insert(AutofillKey("name0", "value0-1"));
- keys1.insert(AutofillKey("name2", "value2"));
- keys1.insert(AutofillKey("name3", "value3"));
- AddKeys(1, keys1);
-
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
- ASSERT_TRUE(AwaitQuiescence());
- ASSERT_TRUE(KeysMatch(0, 1));
- ASSERT_EQ(5U, GetAllKeys(0).size());
-}
-
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest,
- PersonalDataManagerSanity) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- // Client0 adds a profile.
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-
- // Client1 adds a profile.
- AddProfile(1, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_MARION));
- ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(2U, GetAllProfiles(0).size());
-
- // Client0 adds the same profile.
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_MARION));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(2U, GetAllProfiles(0).size());
-
- // Client1 removes a profile.
- RemoveProfile(1, GetAllProfiles(1)[0]->guid());
- ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-
- // Client0 updates a profile.
- UpdateProfile(0, GetAllProfiles(0)[0]->guid(), AutofillType(NAME_FIRST),
- ASCIIToUTF16("Bart"));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-
- // Client1 removes remaining profile.
- RemoveProfile(1, GetAllProfiles(1)[0]->guid());
- ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(0U, GetAllProfiles(0).size());
-}
-
-// TCM ID - 7261786.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddDuplicateProfiles) {
- ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
-
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
- ASSERT_TRUE(AwaitQuiescence());
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-}
-
-// TCM ID - 3636294.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, SameProfileWithConflict) {
- ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
-
- AutofillProfile profile0 =
- CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER);
- AutofillProfile profile1 =
- CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER);
- profile1.SetInfo(PHONE_FAX_WHOLE_NUMBER, ASCIIToUTF16("1234567890"));
-
- AddProfile(0, profile0);
- AddProfile(1, profile1);
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
- ASSERT_TRUE(AwaitQuiescence());
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-}
-
-// TCM ID - 3626291.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddEmptyProfile) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_NULL));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(0U, GetAllProfiles(0).size());
-}
-
-// TCM ID - 3616283.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddProfile) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-}
-
-// TCM ID - 3632260.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddMultipleProfiles) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_MARION));
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_FRASIER));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(3U, GetAllProfiles(0).size());
-}
-
-// TCM ID - 3602257.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, DeleteProfile) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-
- RemoveProfile(1, GetAllProfiles(1)[0]->guid());
- ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(0U, GetAllProfiles(0).size());
-}
-
-// TCM ID - 3627300.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, MergeProfiles) {
- ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
-
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- AddProfile(1, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_MARION));
- AddProfile(1, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_FRASIER));
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
- ASSERT_TRUE(AwaitQuiescence());
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(3U, GetAllProfiles(0).size());
-}
-
-// TCM ID - 3665264.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, UpdateFields) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-
- UpdateProfile(0, GetAllProfiles(0)[0]->guid(), AutofillType(NAME_FIRST),
- ASCIIToUTF16("Lisa"));
- UpdateProfile(0, GetAllProfiles(0)[0]->guid(), AutofillType(EMAIL_ADDRESS),
- ASCIIToUTF16("grrrl@TV.com"));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-}
-
-// TCM ID - 3628299.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, ConflictingFields) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
- UpdateProfile(0, GetAllProfiles(0)[0]->guid(), AutofillType(NAME_FIRST),
- ASCIIToUTF16("Lisa"));
- UpdateProfile(1, GetAllProfiles(1)[0]->guid(), AutofillType(NAME_FIRST),
- ASCIIToUTF16("Bart"));
- ASSERT_TRUE(AwaitQuiescence());
- ASSERT_TRUE(ProfilesMatch(0,1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-}
-
-// TCM ID - 3663293.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, DisableAutofill) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0, 1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-
- ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncable::AUTOFILL));
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_FRASIER));
- ASSERT_TRUE(AwaitQuiescence());
- ASSERT_FALSE(ProfilesMatch(0, 1));
- ASSERT_EQ(2U, GetAllProfiles(0).size());
- ASSERT_EQ(1U, GetAllProfiles(1).size());
-
- ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncable::AUTOFILL));
- ASSERT_TRUE(AwaitQuiescence());
- ASSERT_TRUE(ProfilesMatch(0, 1));
- ASSERT_EQ(2U, GetAllProfiles(0).size());
-}
-
-// TCM ID - 3661291.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, DisableSync) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0, 1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-
- ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes());
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_FRASIER));
- ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Added a profile."));
- ASSERT_FALSE(ProfilesMatch(0, 1));
- ASSERT_EQ(2U, GetAllProfiles(0).size());
- ASSERT_EQ(1U, GetAllProfiles(1).size());
-
- ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes());
- ASSERT_TRUE(AwaitQuiescence());
- ASSERT_TRUE(ProfilesMatch(0, 1));
- ASSERT_EQ(2U, GetAllProfiles(0).size());
-}
-
-// TCM ID - 3608295.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, MaxLength) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0, 1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-
- string16 max_length_string(kMaxDataLength, '.');
- UpdateProfile(0, GetAllProfiles(0)[0]->guid(),
- AutofillType(NAME_FIRST), max_length_string);
- UpdateProfile(0, GetAllProfiles(0)[0]->guid(),
- AutofillType(NAME_LAST), max_length_string);
- UpdateProfile(0, GetAllProfiles(0)[0]->guid(),
- AutofillType(EMAIL_ADDRESS), max_length_string);
- UpdateProfile(0, GetAllProfiles(0)[0]->guid(),
- AutofillType(ADDRESS_HOME_LINE1), max_length_string);
-
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0, 1));
-}
-
-// See http://crbug.com/85769.
-// TODO(braffert): Remove FAILS annotation when bug 85769 is resolved.
-// TCM ID - 7735472.
-IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, FAILS_ExceedsMaxLength) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(ProfilesMatch(0, 1));
- ASSERT_EQ(1U, GetAllProfiles(0).size());
-
- string16 exceeds_max_length_string(kMaxDataLength + 1, '.');
- UpdateProfile(0, GetAllProfiles(0)[0]->guid(),
- AutofillType(NAME_FIRST), exceeds_max_length_string);
- UpdateProfile(0, GetAllProfiles(0)[0]->guid(),
- AutofillType(NAME_LAST), exceeds_max_length_string);
- UpdateProfile(0, GetAllProfiles(0)[0]->guid(),
- AutofillType(EMAIL_ADDRESS), exceeds_max_length_string);
- UpdateProfile(0, GetAllProfiles(0)[0]->guid(),
- AutofillType(ADDRESS_HOME_LINE1), exceeds_max_length_string);
-
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_FALSE(ProfilesMatch(0, 1));
-}