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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/test/integration/extensions_helper.h
diff --git a/chrome/browser/sync/test/integration/extensions_helper.h b/chrome/browser/sync/test/integration/extensions_helper.h
index f807abfcb16ad2c3cd753517570f689a82e6d35a..eabab5123ca80fb246a8921366a48c1059c4e448 100644
--- a/chrome/browser/sync/test/integration/extensions_helper.h
+++ b/chrome/browser/sync/test/integration/extensions_helper.h
@@ -5,13 +5,20 @@
#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_EXTENSIONS_HELPER_H_
#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_EXTENSIONS_HELPER_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/compiler_specific.h"
+#include "chrome/browser/sync/test/integration/status_change_checker.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "extensions/browser/extension_registry_observer.h"
+#include "extensions/common/extension.h"
class Profile;
+class SyncedExtensionInstaller;
namespace extensions_helper {
@@ -74,4 +81,49 @@ bool AwaitAllProfilesHaveSameExtensions();
} // namespace extensions_helper
+// A helper class to implement waiting for a set of profiles to have matching
+// extensions lists. It waits for calls on both interfaces:
+// ExtensionRegistryObserver and NotificationObserver. Observing
+// NOTIFICATION_EXTENSION_UPDATING_STARTED notification is needed for tests
+// against local server because in such tests extensions are not installed and
+// ExtensionRegistryObserver methods are not called.
+class ExtensionsMatchChecker : public StatusChangeChecker,
+ public extensions::ExtensionRegistryObserver,
+ public content::NotificationObserver {
+ public:
+ ExtensionsMatchChecker();
+ ~ExtensionsMatchChecker() override;
+
+ // StatusChangeChecker implementation.
+ std::string GetDebugMessage() const override;
+ bool IsExitConditionSatisfied() override;
+
+ // extensions::ExtensionRegistryObserver implementation.
+ void OnExtensionLoaded(content::BrowserContext* context,
+ const extensions::Extension* extension) override;
+ void OnExtensionUnloaded(
+ content::BrowserContext* context,
+ const extensions::Extension* extenion,
+ extensions::UnloadedExtensionInfo::Reason reason) override;
+ void OnExtensionInstalled(content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ bool is_update) override;
+ void OnExtensionUninstalled(content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ extensions::UninstallReason reason) override;
+
+ // content::NotificationObserver implementation.
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
+
+ private:
+ std::vector<Profile*> profiles_;
+ std::vector<std::unique_ptr<SyncedExtensionInstaller>>
+ synced_extension_installers_;
+ content::NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionsMatchChecker);
+};
+
#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_EXTENSIONS_HELPER_H_
« 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