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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_permission_context_unittest.cc

Issue 1942353002: (reland) Move permission.mojom from WebKit/public/platform/ to components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/push_messaging/push_messaging_permission_context.h" 5 #include "chrome/browser/push_messaging/push_messaging_permission_context.h"
6 6
7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
8 #include "chrome/browser/permissions/permission_request_id.h" 8 #include "chrome/browser/permissions/permission_request_id.h"
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 159
160 TEST_F(PushMessagingPermissionContextTest, DecidePushPermission) { 160 TEST_F(PushMessagingPermissionContextTest, DecidePushPermission) {
161 TestingProfile profile; 161 TestingProfile profile;
162 TestPushMessagingPermissionContext context(&profile); 162 TestPushMessagingPermissionContext context(&profile);
163 PermissionRequestID request_id(-1, -1, -1); 163 PermissionRequestID request_id(-1, -1, -1);
164 BrowserPermissionCallback callback = base::Bind(DoNothing); 164 BrowserPermissionCallback callback = base::Bind(DoNothing);
165 165
166 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), 166 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA),
167 callback, 167 callback,
168 blink::mojom::PermissionStatus::DENIED); 168 permissions::mojom::PermissionStatus::DENIED);
169 EXPECT_FALSE(context.was_persisted()); 169 EXPECT_FALSE(context.was_persisted());
170 EXPECT_FALSE(context.was_granted()); 170 EXPECT_FALSE(context.was_granted());
171 171
172 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, 172 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
173 CONTENT_SETTING_ALLOW); 173 CONTENT_SETTING_ALLOW);
174 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), 174 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA),
175 callback, 175 callback,
176 blink::mojom::PermissionStatus::GRANTED); 176 permissions::mojom::PermissionStatus::GRANTED);
177 EXPECT_TRUE(context.was_persisted()); 177 EXPECT_TRUE(context.was_persisted());
178 EXPECT_TRUE(context.was_granted()); 178 EXPECT_TRUE(context.was_granted());
179 179
180 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, 180 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
181 CONTENT_SETTING_BLOCK); 181 CONTENT_SETTING_BLOCK);
182 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), 182 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA),
183 callback, 183 callback,
184 blink::mojom::PermissionStatus::GRANTED); 184 permissions::mojom::PermissionStatus::GRANTED);
185 EXPECT_TRUE(context.was_persisted()); 185 EXPECT_TRUE(context.was_persisted());
186 EXPECT_FALSE(context.was_granted()); 186 EXPECT_FALSE(context.was_granted());
187 187
188 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, 188 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
189 CONTENT_SETTING_ASK); 189 CONTENT_SETTING_ASK);
190 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA), 190 context.DecidePushPermission(request_id, GURL(kOriginA), GURL(kOriginA),
191 callback, 191 callback,
192 blink::mojom::PermissionStatus::GRANTED); 192 permissions::mojom::PermissionStatus::GRANTED);
193 EXPECT_TRUE(context.was_persisted()); 193 EXPECT_TRUE(context.was_persisted());
194 EXPECT_TRUE(context.was_granted()); 194 EXPECT_TRUE(context.was_granted());
195 } 195 }
196 196
197 TEST_F(PushMessagingPermissionContextTest, DecidePermission) { 197 TEST_F(PushMessagingPermissionContextTest, DecidePermission) {
198 TestingProfile profile; 198 TestingProfile profile;
199 TestPushMessagingPermissionContext context(&profile); 199 TestPushMessagingPermissionContext context(&profile);
200 PermissionRequestID request_id(-1, -1, -1); 200 PermissionRequestID request_id(-1, -1, -1);
201 BrowserPermissionCallback callback = base::Bind(DoNothing); 201 BrowserPermissionCallback callback = base::Bind(DoNothing);
202 202
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 EXPECT_EQ(CONTENT_SETTING_BLOCK, 305 EXPECT_EQ(CONTENT_SETTING_BLOCK,
306 context.GetPermissionStatus(GURL(kInsecureOrigin), 306 context.GetPermissionStatus(GURL(kInsecureOrigin),
307 GURL(kInsecureOrigin))); 307 GURL(kInsecureOrigin)));
308 308
309 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, 309 SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
310 CONTENT_SETTING_ASK); 310 CONTENT_SETTING_ASK);
311 EXPECT_EQ(CONTENT_SETTING_BLOCK, 311 EXPECT_EQ(CONTENT_SETTING_BLOCK,
312 context.GetPermissionStatus(GURL(kInsecureOrigin), 312 context.GetPermissionStatus(GURL(kInsecureOrigin),
313 GURL(kInsecureOrigin))); 313 GURL(kInsecureOrigin)));
314 } 314 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698