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

Side by Side Diff: chrome/browser/notifications/notification_test_util.h

Issue 2729613006: When navigation focuses a web contents, also activate its window. (Closed)
Patch Set: Created 3 years, 9 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_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_ 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/test/scoped_feature_list.h"
15 #include "chrome/browser/notifications/notification.h" 16 #include "chrome/browser/notifications/notification.h"
16 #include "chrome/browser/notifications/notification_ui_manager.h" 17 #include "chrome/browser/notifications/notification_ui_manager.h"
18 #include "chrome/browser/permissions/permission_request_manager.h"
19 #include "chrome/test/base/in_process_browser_test.h"
20 #include "components/content_settings/core/common/content_settings.h"
17 21
18 class Browser; 22 class Browser;
19 class Profile; 23 class Profile;
20 24
21 // NotificationDelegate which does nothing, useful for testing when 25 // NotificationDelegate which does nothing, useful for testing when
22 // the notification events are not important. 26 // the notification events are not important.
23 class MockNotificationDelegate : public NotificationDelegate { 27 class MockNotificationDelegate : public NotificationDelegate {
24 public: 28 public:
25 explicit MockNotificationDelegate(const std::string& id); 29 explicit MockNotificationDelegate(const std::string& id);
26 30
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 92
89 void Wait(); 93 void Wait();
90 94
91 private: 95 private:
92 Browser* browser_; 96 Browser* browser_;
93 bool desired_state_; 97 bool desired_state_;
94 98
95 DISALLOW_COPY_AND_ASSIGN(FullscreenStateWaiter); 99 DISALLOW_COPY_AND_ASSIGN(FullscreenStateWaiter);
96 }; 100 };
97 101
102 class MessageCenterChangeObserver {
103 public:
104 MessageCenterChangeObserver();
105 ~MessageCenterChangeObserver();
106
107 bool Wait();
108
109 private:
110 class Impl;
111 std::unique_ptr<Impl> impl_;
112
113 DISALLOW_COPY_AND_ASSIGN(MessageCenterChangeObserver);
114 };
115
116 class NotificationsTest : public InProcessBrowserTest {
117 public:
118 NotificationsTest() {}
119
120 protected:
121 int GetNotificationCount();
122 int GetNotificationPopupCount();
123
124 void CloseBrowserWindow(Browser* browser);
125 void CrashTab(Browser* browser, int index);
126
127 void DenyOrigin(const GURL& origin);
128 void AllowOrigin(const GURL& origin);
129 void AllowAllOrigins();
130 void SetDefaultContentSetting(ContentSetting setting);
131
132 std::string CreateNotification(Browser* browser,
133 bool wait_for_new_balloon,
134 const char* icon,
135 const char* title,
136 const char* body,
137 const char* replace_id,
138 const char* onclick = "");
139 std::string CreateSimpleNotification(Browser* browser,
140 bool wait_for_new_balloon);
141 bool RequestAndAcceptPermission(Browser* browser);
142 bool RequestAndDenyPermission(Browser* browser);
143 bool RequestAndDismissPermission(Browser* browser);
144 bool RequestPermissionAndWait(Browser* browser);
145 bool CancelNotification(const char* notification_id, Browser* browser);
146 void GetPrefsByContentSetting(ContentSetting setting,
147 ContentSettingsForOneType* settings);
148 bool CheckOriginInSetting(const ContentSettingsForOneType& settings,
149 const GURL& origin);
150
151 GURL GetTestPageURLForFile(const std::string& file) const;
152 GURL GetTestPageURL() const;
153 content::WebContents* GetActiveWebContents(Browser* browser);
154
155 protected:
156 void EnableFullscreenNotifications();
157 void DisableFullscreenNotifications();
158
159 private:
160 void DropOriginPreference(const GURL& origin);
161 std::string RequestAndRespondToPermission(
162 Browser* browser,
163 PermissionRequestManager::AutoResponseType bubble_response);
164
165 base::test::ScopedFeatureList feature_list_;
166 };
167
98 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_ 168 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698