Commit 3c2c21e2 authored by sebsg's avatar sebsg Committed by Commit Bot

Add two-clients sync integration tests for autofill profiles.

Also move the autocomplete sync tests to their own file.

Bug: 869526
Change-Id: I49d75e522c41bce8aca8179c8adbdc475354dd58
Reviewed-on: https://chromium-review.googlesource.com/1157184
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580263}
parent b493ea70
......@@ -341,11 +341,11 @@ std::vector<AutofillProfile*> GetAllAutoFillProfiles(int profile) {
return pdm->GetProfiles();
}
int GetProfileCount(int profile) {
size_t GetProfileCount(int profile) {
return GetAllAutoFillProfiles(profile).size();
}
int GetKeyCount(int profile) {
size_t GetKeyCount(int profile) {
return GetAllKeys(profile).size();
}
......
......@@ -96,10 +96,10 @@ std::vector<autofill::AutofillProfile*> GetAllAutoFillProfiles(int profile)
// Returns the number of autofill profiles contained by sync profile
// |profile|.
int GetProfileCount(int profile);
size_t GetProfileCount(int profile);
// Returns the number of autofill keys contained by sync profile |profile|.
int GetKeyCount(int profile);
size_t GetKeyCount(int profile);
// Compares the Autofill profiles in the PersonalDataManagers of sync profiles
// |profile_a| and |profile_b|. Returns true if they match.
......
......@@ -36,8 +36,8 @@ using sync_timing_helper::TimeMutualSyncCycle;
//
// TODO(akalin): If this works, decomp the magic number calculation
// into a macro and have all the perf tests use it.
static const int kNumKeys = 163;
static const int kNumProfiles = 163;
constexpr size_t kNumKeys = 163;
constexpr size_t kNumProfiles = 163;
std::string IntToName(int n) {
return base::StringPrintf("Name%d", n);
......@@ -166,7 +166,7 @@ IN_PROC_BROWSER_TEST_P(AutofillProfileSyncPerfTest, P0) {
RemoveProfiles(0);
dt = TimeMutualSyncCycle(GetClient(0), GetClient(1));
ASSERT_EQ(0, GetProfileCount(1));
ASSERT_EQ(0U, GetProfileCount(1));
PrintResult("autofill", "delete_autofill_profiles", dt);
}
......@@ -224,7 +224,7 @@ IN_PROC_BROWSER_TEST_F(AutocompleteSyncPerfTest, P0) {
// TODO(lipalani): fix this. The following line is added to force sync.
ForceSync(0);
dt = TimeMutualSyncCycle(GetClient(0), GetClient(1));
ASSERT_EQ(0, GetKeyCount(1));
ASSERT_EQ(0U, GetKeyCount(1));
PrintResult("autofill", "delete_autofill_keys", dt);
}
......
// Copyright 2018 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/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/sync/test/integration/autofill_helper.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "components/autofill/core/browser/webdata/autofill_entry.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
using autofill::AutofillKey;
using autofill_helper::AddKeys;
using autofill_helper::GetAllKeys;
using autofill_helper::KeysMatch;
using autofill_helper::RemoveKey;
class TwoClientAutocompleteSyncTest : public SyncTest {
public:
TwoClientAutocompleteSyncTest() : SyncTest(TWO_CLIENT) {}
~TwoClientAutocompleteSyncTest() override {}
bool TestUsesSelfNotifications() override { return false; }
private:
DISALLOW_COPY_AND_ASSIGN(TwoClientAutocompleteSyncTest);
};
IN_PROC_BROWSER_TEST_F(TwoClientAutocompleteSyncTest, WebDataServiceSanity) {
ASSERT_TRUE(SetupSync());
// Client0 adds a key.
AddKeys(0, {AutofillKey("name0", "value0")});
EXPECT_TRUE(AutofillKeysChecker(0, 1).Wait());
EXPECT_EQ(1U, GetAllKeys(0).size());
// Client1 adds a key.
AddKeys(1, {AutofillKey("name1", "value1-0")});
EXPECT_TRUE(AutofillKeysChecker(0, 1).Wait());
EXPECT_EQ(2U, GetAllKeys(0).size());
// Client0 adds a key with the same name.
AddKeys(0, {AutofillKey("name1", "value1-1")});
EXPECT_TRUE(AutofillKeysChecker(0, 1).Wait());
EXPECT_EQ(3U, GetAllKeys(0).size());
// Client1 removes a key.
RemoveKey(1, AutofillKey("name1", "value1-0"));
EXPECT_TRUE(AutofillKeysChecker(0, 1).Wait());
EXPECT_EQ(2U, GetAllKeys(0).size());
// Client0 removes the rest.
RemoveKey(0, AutofillKey("name0", "value0"));
RemoveKey(0, AutofillKey("name1", "value1-1"));
EXPECT_TRUE(AutofillKeysChecker(0, 1).Wait());
EXPECT_EQ(0U, GetAllKeys(0).size());
}
IN_PROC_BROWSER_TEST_F(TwoClientAutocompleteSyncTest, AddUnicodeProfile) {
ASSERT_TRUE(SetupClients());
std::set<AutofillKey> keys;
keys.insert(AutofillKey(base::WideToUTF16(L"Sigur R\u00F3s"),
base::WideToUTF16(L"\u00C1g\u00E6tis byrjun")));
AddKeys(0, keys);
ASSERT_TRUE(SetupSync());
EXPECT_TRUE(AutofillKeysChecker(0, 1).Wait());
}
IN_PROC_BROWSER_TEST_F(TwoClientAutocompleteSyncTest,
AddDuplicateNamesToSameProfile) {
ASSERT_TRUE(SetupClients());
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());
EXPECT_TRUE(AutofillKeysChecker(0, 1).Wait());
EXPECT_EQ(2U, GetAllKeys(0).size());
}
IN_PROC_BROWSER_TEST_F(TwoClientAutocompleteSyncTest,
AddDuplicateNamesToDifferentProfiles) {
ASSERT_TRUE(SetupClients());
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());
EXPECT_TRUE(AutofillKeysChecker(0, 1).Wait());
EXPECT_EQ(5U, GetAllKeys(0).size());
}
} // namespace
......@@ -5441,6 +5441,7 @@ if (!is_android && !is_fuchsia) {
"../browser/sync/test/integration/two_client_app_list_sync_test.cc",
"../browser/sync/test/integration/two_client_apps_sync_test.cc",
"../browser/sync/test/integration/two_client_arc_package_sync_test.cc",
"../browser/sync/test/integration/two_client_autocomplete_sync_test.cc",
"../browser/sync/test/integration/two_client_autofill_sync_test.cc",
"../browser/sync/test/integration/two_client_bookmarks_sync_test.cc",
"../browser/sync/test/integration/two_client_dictionary_sync_test.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment