Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: chrome/browser/sync/test/integration/dictionary_helper.h

Issue 2379433002: [Sync] Refactoring of sync integration test checkers to remove boilerplate await methods. (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_DICTIONARY_HELPER_H_ 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_DICTIONARY_HELPER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_DICTIONARY_HELPER_H_ 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_DICTIONARY_HELPER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "chrome/browser/sync/test/integration/multi_client_status_change_checke r.h"
13 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h"
14
12 namespace dictionary_helper { 15 namespace dictionary_helper {
13 16
14 // Synchronously loads the dictionaries across all profiles. Also loads the 17 // Synchronously loads the dictionaries across all profiles. Also loads the
15 // dictionary for the verifier if DisableVerifier() hasn't been called. Returns 18 // dictionary for the verifier if DisableVerifier() hasn't been called. Returns
16 // only after the dictionaries have finished to load. 19 // only after the dictionaries have finished to load.
17 void LoadDictionaries(); 20 void LoadDictionaries();
18 21
19 // Used to check the size of the dictionary within a particular sync profile. 22 // Used to check the size of the dictionary within a particular sync profile.
20 size_t GetDictionarySize(int index); 23 size_t GetDictionarySize(int index);
21 24
22 // Used to check the size of the dictionary within the verifier sync profile. 25 // Used to check the size of the dictionary within the verifier sync profile.
23 size_t GetVerifierDictionarySize(); 26 size_t GetVerifierDictionarySize();
24 27
25 // Used to verify that dictionaries match across all profiles. Also checks 28 // Used to verify that dictionaries match across all profiles. Also checks
26 // verifier if DisableVerifier() hasn't been called. 29 // verifier if DisableVerifier() hasn't been called.
27 bool DictionariesMatch(); 30 bool DictionariesMatch();
28 31
29 // Waits until dictionaries match across all platforms. Returns false
30 // if this operation times out.
31 bool AwaitDictionariesMatch();
32
33 // Waits until the profile at the given index contains exactly |num| dictionary
34 // entries. Returns false if this operation times out.
35 bool AwaitNumDictionaryEntries(int index, size_t num_words);
36
37 // Used to verify that the dictionary within a particular sync profile matches 32 // Used to verify that the dictionary within a particular sync profile matches
38 // the dictionary within the verifier sync profile. 33 // the dictionary within the verifier sync profile.
39 bool DictionaryMatchesVerifier(int index); 34 bool DictionaryMatchesVerifier(int index);
40 35
41 // Adds |word| to the dictionary for profile with index |index|. Also adds 36 // Adds |word| to the dictionary for profile with index |index|. Also adds
42 // |word| to the verifier if DisableVerifier() hasn't been called. Returns true 37 // |word| to the verifier if DisableVerifier() hasn't been called. Returns true
43 // if |word| is valid and not a duplicate. Otherwise returns false. 38 // if |word| is valid and not a duplicate. Otherwise returns false.
44 bool AddWord(int index, const std::string& word); 39 bool AddWord(int index, const std::string& word);
45 40
46 // Add |n| words with the given |prefix| to the specified client |index|. Also 41 // Add |n| words with the given |prefix| to the specified client |index|. Also
47 // adds to the verifier if not disAbled. Return value is true iff all words are 42 // adds to the verifier if not disAbled. Return value is true iff all words are
48 // not duplicates and valid. 43 // not duplicates and valid.
49 bool AddWords(int index, int n, const std::string& prefix); 44 bool AddWords(int index, int n, const std::string& prefix);
50 45
51 // Removes |word| from the dictionary for profile with index |index|. Also 46 // Removes |word| from the dictionary for profile with index |index|. Also
52 // removes |word| from the verifier if DisableVerifier() hasn't been called. 47 // removes |word| from the verifier if DisableVerifier() hasn't been called.
53 // Returns true if |word| was found. Otherwise returns false. 48 // Returns true if |word| was found. Otherwise returns false.
54 bool RemoveWord(int index, const std::string& word); 49 bool RemoveWord(int index, const std::string& word);
55 50
56 } // namespace dictionary_helper 51 } // namespace dictionary_helper
57 52
53 // Checker to block until all services have matching dictionaries.
54 class DictionaryMatchChecker : public MultiClientStatusChangeChecker {
55 public:
56 DictionaryMatchChecker();
57
58 // StatusChangeChecker implementation.
59 bool IsExitConditionSatisfied() override;
60 std::string GetDebugMessage() const override;
61 };
62
63 // Checker to block until the number of dictionary entries to equal to an
64 // expected count.
65 class NumDictionaryEntriesChecker : public SingleClientStatusChangeChecker {
66 public:
67 NumDictionaryEntriesChecker(int index, size_t num_words);
68
69 // StatusChangeChecker implementation.
70 bool IsExitConditionSatisfied() override;
71 std::string GetDebugMessage() const override;
72
73 private:
74 int index_;
75 size_t num_words_;
76 };
77
58 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_DICTIONARY_HELPER_H_ 78 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_DICTIONARY_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/bookmarks_helper.cc ('k') | chrome/browser/sync/test/integration/dictionary_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698