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

Side by Side Diff: chrome/browser/sync/test/integration/extensions_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_EXTENSIONS_HELPER_H_ 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_EXTENSIONS_HELPER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_EXTENSIONS_HELPER_H_ 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_EXTENSIONS_HELPER_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "chrome/browser/sync/test/integration/status_change_checker.h"
12 #include "chrome/browser/sync/test/integration/sync_test.h" 14 #include "chrome/browser/sync/test/integration/sync_test.h"
15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
17 #include "extensions/browser/extension_registry_observer.h"
18 #include "extensions/common/extension.h"
13 19
14 class Profile; 20 class Profile;
21 class SyncedExtensionInstaller;
15 22
16 namespace extensions_helper { 23 namespace extensions_helper {
17 24
18 // Returns true iff profiles with indices |index1| and |index2| have the same 25 // Returns true iff profiles with indices |index1| and |index2| have the same
19 // extensions. 26 // extensions.
20 bool HasSameExtensions(int index1, int index2) WARN_UNUSED_RESULT; 27 bool HasSameExtensions(int index1, int index2) WARN_UNUSED_RESULT;
21 28
22 // Returns true iff the profile with index |index| has the same extensions 29 // Returns true iff the profile with index |index| has the same extensions
23 // as the verifier. 30 // as the verifier.
24 bool HasSameExtensionsAsVerifier(int index) WARN_UNUSED_RESULT; 31 bool HasSameExtensionsAsVerifier(int index) WARN_UNUSED_RESULT;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Returns true if the extension with index |index| is enabled in incognito 74 // Returns true if the extension with index |index| is enabled in incognito
68 // mode on |profile|. 75 // mode on |profile|.
69 bool IsIncognitoEnabled(Profile* profile, int index); 76 bool IsIncognitoEnabled(Profile* profile, int index);
70 77
71 // Runs the message loop until all profiles have same extensions. Returns false 78 // Runs the message loop until all profiles have same extensions. Returns false
72 // on timeout. 79 // on timeout.
73 bool AwaitAllProfilesHaveSameExtensions(); 80 bool AwaitAllProfilesHaveSameExtensions();
74 81
75 } // namespace extensions_helper 82 } // namespace extensions_helper
76 83
84 // A helper class to implement waiting for a set of profiles to have matching
85 // extensions lists. It waits for calls on both interfaces:
86 // ExtensionRegistryObserver and NotificationObserver. Observing
87 // NOTIFICATION_EXTENSION_UPDATING_STARTED notification is needed for tests
88 // against local server because in such tests extensions are not installed and
89 // ExtensionRegistryObserver methods are not called.
90 class ExtensionsMatchChecker : public StatusChangeChecker,
91 public extensions::ExtensionRegistryObserver,
92 public content::NotificationObserver {
93 public:
94 ExtensionsMatchChecker();
95 ~ExtensionsMatchChecker() override;
96
97 // StatusChangeChecker implementation.
98 std::string GetDebugMessage() const override;
99 bool IsExitConditionSatisfied() override;
100
101 // extensions::ExtensionRegistryObserver implementation.
102 void OnExtensionLoaded(content::BrowserContext* context,
103 const extensions::Extension* extension) override;
104 void OnExtensionUnloaded(
105 content::BrowserContext* context,
106 const extensions::Extension* extenion,
107 extensions::UnloadedExtensionInfo::Reason reason) override;
108 void OnExtensionInstalled(content::BrowserContext* browser_context,
109 const extensions::Extension* extension,
110 bool is_update) override;
111 void OnExtensionUninstalled(content::BrowserContext* browser_context,
112 const extensions::Extension* extension,
113 extensions::UninstallReason reason) override;
114
115 // content::NotificationObserver implementation.
116 void Observe(int type,
117 const content::NotificationSource& source,
118 const content::NotificationDetails& details) override;
119
120 private:
121 std::vector<Profile*> profiles_;
122 std::vector<std::unique_ptr<SyncedExtensionInstaller>>
123 synced_extension_installers_;
124 content::NotificationRegistrar registrar_;
125
126 DISALLOW_COPY_AND_ASSIGN(ExtensionsMatchChecker);
127 };
128
77 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_EXTENSIONS_HELPER_H_ 129 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_EXTENSIONS_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/dictionary_helper.cc ('k') | chrome/browser/sync/test/integration/extensions_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698