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

Side by Side Diff: chrome/browser/sync/test/integration/themes_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_THEMES_HELPER_H_ 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_THEMES_HELPER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_THEMES_HELPER_H_ 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_THEMES_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h"
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "chrome/browser/sync/test/integration/status_change_checker.h"
11 #include "chrome/browser/sync/test/integration/sync_test.h" 13 #include "chrome/browser/sync/test/integration/sync_test.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
12 16
13 class Profile; 17 class Profile;
18 class ThemeService;
14 19
15 namespace themes_helper { 20 namespace themes_helper {
16 21
17 // Gets the unique ID of the custom theme with the given index. 22 // Gets the unique ID of the custom theme with the given index.
18 std::string GetCustomTheme(int index) WARN_UNUSED_RESULT; 23 std::string GetCustomTheme(int index) WARN_UNUSED_RESULT;
19 24
20 // Gets the ID of |profile|'s theme. 25 // Gets the ID of |profile|'s theme.
21 std::string GetThemeID(Profile* profile) WARN_UNUSED_RESULT; 26 std::string GetThemeID(Profile* profile) WARN_UNUSED_RESULT;
22 27
23 // Returns true iff |profile| is using a custom theme. 28 // Returns true iff |profile| is using a custom theme.
(...skipping 12 matching lines...) Expand all
36 41
37 // Sets |profile| to use the custom theme with the given index. 42 // Sets |profile| to use the custom theme with the given index.
38 void UseCustomTheme(Profile* profile, int index); 43 void UseCustomTheme(Profile* profile, int index);
39 44
40 // Sets |profile| to use the default theme. 45 // Sets |profile| to use the default theme.
41 void UseDefaultTheme(Profile* profile); 46 void UseDefaultTheme(Profile* profile);
42 47
43 // Sets |profile| to use the system theme. 48 // Sets |profile| to use the system theme.
44 void UseSystemTheme(Profile* profile); 49 void UseSystemTheme(Profile* profile);
45 50
46 // Waits until |theme| is pending for install on |profile|. 51 } // namespace themes_helper
47 // Returns false in case of timeout.
48 bool AwaitThemeIsPendingInstall(Profile* profile, const std::string& theme);
49 52
50 // Waits until |profile| is using the system theme. 53 // Waits until |profile| is using the system theme.
51 // Returns false in case of timeout. 54 // Returns false in case of timeout.
52 bool AwaitUsingSystemTheme(Profile* profile);
53 55
54 // Waits until |profile| is using the default theme. 56 // Waits until |profile| is using the default theme.
55 // Returns false in case of timeout. 57 // Returns false in case of timeout.
56 bool AwaitUsingDefaultTheme(Profile* profile);
57 58
58 } // namespace themes_helper 59 // Helper to wait until a given condition is met, checking every time the
60 // current theme changes.
61 //
62 // The |exit_condition_| closure may be invoked zero or more times.
63 class ThemeConditionChecker : public StatusChangeChecker,
64 public content::NotificationObserver {
65 public:
66 ThemeConditionChecker(Profile* profile,
67 const std::string& debug_message_,
68 base::Callback<bool(ThemeService*)> exit_condition);
69 ~ThemeConditionChecker() override;
70
71 // Implementation of StatusChangeChecker.
72 std::string GetDebugMessage() const override;
73 bool IsExitConditionSatisfied() override;
74
75 // Implementation of content::NotificationObserver.
76 void Observe(int type,
77 const content::NotificationSource& source,
78 const content::NotificationDetails& details) override;
79
80 private:
81 Profile* profile_;
82 const std::string debug_message_;
83 base::Callback<bool(ThemeService*)> exit_condition_;
84
85 content::NotificationRegistrar registrar_;
86 };
87
88 // Waits until |theme| is pending for install on |profile|.
89 // Returns false in case of timeout.
90
91 // Helper to wait until the specified theme is pending for install on the
92 // specified profile.
93 //
94 // The themes sync integration tests don't actually install any custom themes,
95 // but they do occasionally check that the ThemeService attempts to install
96 // synced themes.
97 class ThemePendingInstallChecker : public StatusChangeChecker,
98 public content::NotificationObserver {
99 public:
100 ThemePendingInstallChecker(Profile* profile, const std::string& theme);
101 ~ThemePendingInstallChecker() override;
102
103 // Implementation of StatusChangeChecker.
104 std::string GetDebugMessage() const override;
105 bool IsExitConditionSatisfied() override;
106
107 // Implementation of content::NotificationObserver.
108 void Observe(int type,
109 const content::NotificationSource& source,
110 const content::NotificationDetails& details) override;
111
112 private:
113 Profile* profile_;
114 const std::string& theme_;
115
116 content::NotificationRegistrar registrar_;
117 };
118
119 class SystemThemeChecker : public ThemeConditionChecker {
120 public:
121 explicit SystemThemeChecker(Profile* profile);
122 };
123
124 class DefaultThemeChecker : public ThemeConditionChecker {
125 public:
126 explicit DefaultThemeChecker(Profile* profile);
127 };
59 128
60 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_THEMES_HELPER_H_ 129 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_THEMES_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.cc ('k') | chrome/browser/sync/test/integration/themes_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698