This source file includes following definitions.
- TestUsesSelfNotifications
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/sync/test/integration/dictionary_helper.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/common/spellcheck_common.h"
using dictionary_helper::AwaitNumDictionaryEntries;
using chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS;
class MultipleClientDictionarySyncTest : public SyncTest {
public:
MultipleClientDictionarySyncTest() : SyncTest(MULTIPLE_CLIENT) {}
virtual ~MultipleClientDictionarySyncTest() {}
virtual bool TestUsesSelfNotifications() OVERRIDE { return false; }
private:
DISALLOW_COPY_AND_ASSIGN(MultipleClientDictionarySyncTest);
};
IN_PROC_BROWSER_TEST_F(MultipleClientDictionarySyncTest, AddToOne) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
dictionary_helper::LoadDictionaries();
ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
ASSERT_TRUE(dictionary_helper::AddWord(0, "foo"));
ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
}
IN_PROC_BROWSER_TEST_F(MultipleClientDictionarySyncTest, AddSameToAll) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
dictionary_helper::LoadDictionaries();
ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
for (int i = 0; i < num_clients(); ++i)
dictionary_helper::AddWord(i, "foo");
ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
ASSERT_EQ(1UL, dictionary_helper::GetDictionarySize(0));
}
IN_PROC_BROWSER_TEST_F(MultipleClientDictionarySyncTest, AddDifferentToAll) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
dictionary_helper::LoadDictionaries();
ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
for (int i = 0; i < num_clients(); ++i)
dictionary_helper::AddWord(i, "foo" + base::IntToString(i));
ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
ASSERT_EQ(num_clients(),
static_cast<int>(dictionary_helper::GetDictionarySize(0)));
}
IN_PROC_BROWSER_TEST_F(MultipleClientDictionarySyncTest, Limit) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
dictionary_helper::LoadDictionaries();
ASSERT_TRUE(dictionary_helper::AwaitDictionariesMatch());
const int n = num_clients();
size_t initial_words =
(MAX_SYNCABLE_DICTIONARY_WORDS + n) / n;
for (int i = 0; i < n; ++i) {
GetClient(i)->DisableSyncForAllDatatypes();
for (size_t j = 0; j < initial_words; ++j) {
ASSERT_TRUE(dictionary_helper::AddWord(
i, "foo-" + base::IntToString(i) + "-" + base::Uint64ToString(j)));
}
ASSERT_EQ(initial_words, dictionary_helper::GetDictionarySize(i));
}
for (int i = 0; i < n-1; ++i) {
SCOPED_TRACE(i);
ASSERT_EQ(initial_words, dictionary_helper::GetDictionarySize(i));
ASSERT_TRUE(GetClient(i)->EnableSyncForAllDatatypes());
}
for (int i = 0; i < n-1; ++i) {
SCOPED_TRACE(i);
ASSERT_TRUE(AwaitNumDictionaryEntries(i, initial_words*(n-1)));
}
ASSERT_EQ(initial_words, dictionary_helper::GetDictionarySize(n-1));
ASSERT_TRUE(GetClient(n-1)->EnableSyncForAllDatatypes());
ASSERT_TRUE(AwaitNumDictionaryEntries(n-1, initial_words*n));
for (int i = 0; i < n-1; ++i) {
SCOPED_TRACE(i);
ASSERT_TRUE(AwaitNumDictionaryEntries(i, MAX_SYNCABLE_DICTIONARY_WORDS));
}
}