BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / two_client_dictionary_sync_test.cc
blob5f9c336634a5093a3f50f3d308d3c1a6d7962220
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/strings/string_number_conversions.h"
6 #include "chrome/browser/sync/test/integration/dictionary_helper.h"
7 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
8 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
9 #include "chrome/browser/sync/test/integration/sync_test.h"
10 #include "chrome/common/spellcheck_common.h"
12 using sync_integration_test_util::AwaitCommitActivityCompletion;
14 class TwoClientDictionarySyncTest : public SyncTest {
15 public:
16 TwoClientDictionarySyncTest() : SyncTest(TWO_CLIENT) {}
17 ~TwoClientDictionarySyncTest() override {}
19 bool TestUsesSelfNotifications() override { return false; }
21 private:
22 DISALLOW_COPY_AND_ASSIGN(TwoClientDictionarySyncTest);
25 IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, Sanity) {
26 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
27 dictionary_helper::LoadDictionaries();
28 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
30 std::vector<std::string> words;
31 words.push_back("foo");
32 words.push_back("bar");
33 ASSERT_EQ(num_clients(), static_cast<int>(words.size()));
35 for (int i = 0; i < num_clients(); ++i) {
36 ASSERT_TRUE(dictionary_helper::AddWord(i, words[i]));
38 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
39 ASSERT_EQ(words.size(), dictionary_helper::GetDictionarySize(0));
41 for (int i = 0; i < num_clients(); ++i) {
42 ASSERT_TRUE(dictionary_helper::RemoveWord(i, words[i]));
44 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
45 ASSERT_EQ(0UL, dictionary_helper::GetDictionarySize(0));
47 DisableVerifier();
48 for (int i = 0; i < num_clients(); ++i)
49 ASSERT_TRUE(dictionary_helper::AddWord(i, words[i]));
50 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
51 ASSERT_EQ(words.size(), dictionary_helper::GetDictionarySize(0));
54 IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, SimultaneousAdd) {
55 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
56 dictionary_helper::LoadDictionaries();
57 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
59 for (int i = 0; i < num_clients(); ++i)
60 dictionary_helper::AddWord(i, "foo");
61 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
62 ASSERT_EQ(1UL, dictionary_helper::GetDictionarySize(0));
65 IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, SimultaneousRemove) {
66 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
67 dictionary_helper::LoadDictionaries();
68 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
70 for (int i = 0; i < num_clients(); ++i)
71 dictionary_helper::AddWord(i, "foo");
72 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
73 ASSERT_EQ(1UL, dictionary_helper::GetDictionarySize(0));
75 for (int i = 0; i < num_clients(); ++i)
76 dictionary_helper::RemoveWord(i, "foo");
77 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
78 ASSERT_EQ(0UL, dictionary_helper::GetDictionarySize(0));
81 IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, RemoveOnAAddOnB) {
82 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
83 dictionary_helper::LoadDictionaries();
84 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
86 std::string word = "foo";
87 // Add on client A, check it appears on B.
88 ASSERT_TRUE(dictionary_helper::AddWord(0, word));
89 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
90 // Remove on client A, check it disappears on B.
91 ASSERT_TRUE(dictionary_helper::RemoveWord(0, word));
92 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
93 // Add on client B, check it appears on A.
94 ASSERT_TRUE(dictionary_helper::AddWord(1, word));
95 ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
96 ASSERT_EQ(1UL, dictionary_helper::GetDictionarySize(0));