| Index: chrome/browser/sync/test/integration/themes_helper.h
|
| diff --git a/chrome/browser/sync/test/integration/themes_helper.h b/chrome/browser/sync/test/integration/themes_helper.h
|
| index dce9cbbb1ca7e18fe5753ee095983466693002e6..feee0e041744ef7968be325ad422b2999ee1bdda 100644
|
| --- a/chrome/browser/sync/test/integration/themes_helper.h
|
| +++ b/chrome/browser/sync/test/integration/themes_helper.h
|
| @@ -7,10 +7,15 @@
|
|
|
| #include <string>
|
|
|
| +#include "base/callback.h"
|
| #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"
|
|
|
| class Profile;
|
| +class ThemeService;
|
|
|
| namespace themes_helper {
|
|
|
| @@ -43,18 +48,82 @@ void UseDefaultTheme(Profile* profile);
|
| // Sets |profile| to use the system theme.
|
| void UseSystemTheme(Profile* profile);
|
|
|
| -// Waits until |theme| is pending for install on |profile|.
|
| -// Returns false in case of timeout.
|
| -bool AwaitThemeIsPendingInstall(Profile* profile, const std::string& theme);
|
| +} // namespace themes_helper
|
|
|
| // Waits until |profile| is using the system theme.
|
| // Returns false in case of timeout.
|
| -bool AwaitUsingSystemTheme(Profile* profile);
|
|
|
| // Waits until |profile| is using the default theme.
|
| // Returns false in case of timeout.
|
| -bool AwaitUsingDefaultTheme(Profile* profile);
|
|
|
| -} // namespace themes_helper
|
| +// Helper to wait until a given condition is met, checking every time the
|
| +// current theme changes.
|
| +//
|
| +// The |exit_condition_| closure may be invoked zero or more times.
|
| +class ThemeConditionChecker : public StatusChangeChecker,
|
| + public content::NotificationObserver {
|
| + public:
|
| + ThemeConditionChecker(Profile* profile,
|
| + const std::string& debug_message_,
|
| + base::Callback<bool(ThemeService*)> exit_condition);
|
| + ~ThemeConditionChecker() override;
|
| +
|
| + // Implementation of StatusChangeChecker.
|
| + std::string GetDebugMessage() const override;
|
| + bool IsExitConditionSatisfied() override;
|
| +
|
| + // Implementation of content::NotificationObserver.
|
| + void Observe(int type,
|
| + const content::NotificationSource& source,
|
| + const content::NotificationDetails& details) override;
|
| +
|
| + private:
|
| + Profile* profile_;
|
| + const std::string debug_message_;
|
| + base::Callback<bool(ThemeService*)> exit_condition_;
|
| +
|
| + content::NotificationRegistrar registrar_;
|
| +};
|
| +
|
| +// Waits until |theme| is pending for install on |profile|.
|
| +// Returns false in case of timeout.
|
| +
|
| +// Helper to wait until the specified theme is pending for install on the
|
| +// specified profile.
|
| +//
|
| +// The themes sync integration tests don't actually install any custom themes,
|
| +// but they do occasionally check that the ThemeService attempts to install
|
| +// synced themes.
|
| +class ThemePendingInstallChecker : public StatusChangeChecker,
|
| + public content::NotificationObserver {
|
| + public:
|
| + ThemePendingInstallChecker(Profile* profile, const std::string& theme);
|
| + ~ThemePendingInstallChecker() override;
|
| +
|
| + // Implementation of StatusChangeChecker.
|
| + std::string GetDebugMessage() const override;
|
| + bool IsExitConditionSatisfied() override;
|
| +
|
| + // Implementation of content::NotificationObserver.
|
| + void Observe(int type,
|
| + const content::NotificationSource& source,
|
| + const content::NotificationDetails& details) override;
|
| +
|
| + private:
|
| + Profile* profile_;
|
| + const std::string& theme_;
|
| +
|
| + content::NotificationRegistrar registrar_;
|
| +};
|
| +
|
| +class SystemThemeChecker : public ThemeConditionChecker {
|
| + public:
|
| + explicit SystemThemeChecker(Profile* profile);
|
| +};
|
| +
|
| +class DefaultThemeChecker : public ThemeConditionChecker {
|
| + public:
|
| + explicit DefaultThemeChecker(Profile* profile);
|
| +};
|
|
|
| #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_THEMES_HELPER_H_
|
|
|