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

Side by Side Diff: chrome/browser/notifications/platform_notification_service_unittest.cc

Issue 1898153002: Migrate notifications to use the PermissionStatus enum (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix type traits conflicts Created 4 years, 8 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
16 #include "chrome/browser/notifications/notification_delegate.h" 16 #include "chrome/browser/notifications/notification_delegate.h"
17 #include "chrome/browser/notifications/notification_test_util.h" 17 #include "chrome/browser/notifications/notification_test_util.h"
18 #include "chrome/browser/notifications/platform_notification_service_impl.h" 18 #include "chrome/browser/notifications/platform_notification_service_impl.h"
19 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
20 #include "components/content_settings/core/browser/host_content_settings_map.h" 20 #include "components/content_settings/core/browser/host_content_settings_map.h"
21 #include "content/public/browser/desktop_notification_delegate.h" 21 #include "content/public/browser/desktop_notification_delegate.h"
22 #include "content/public/common/notification_resources.h" 22 #include "content/public/common/notification_resources.h"
23 #include "content/public/common/platform_notification_data.h" 23 #include "content/public/common/platform_notification_data.h"
24 #include "content/public/test/test_browser_thread_bundle.h" 24 #include "content/public/test/test_browser_thread_bundle.h"
25 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat us.mojom.h"
27 28
28 #if defined(ENABLE_EXTENSIONS) 29 #if defined(ENABLE_EXTENSIONS)
29 #include "base/command_line.h" 30 #include "base/command_line.h"
30 #include "chrome/browser/extensions/extension_service.h" 31 #include "chrome/browser/extensions/extension_service.h"
31 #include "chrome/browser/extensions/test_extension_system.h" 32 #include "chrome/browser/extensions/test_extension_system.h"
32 #include "extensions/browser/extension_registry.h" 33 #include "extensions/browser/extension_registry.h"
33 #include "extensions/browser/process_map.h" 34 #include "extensions/browser/process_map.h"
34 #include "extensions/common/extension.h" 35 #include "extensions/common/extension.h"
35 #include "extensions/common/extension_builder.h" 36 #include "extensions/common/extension_builder.h"
36 #include "extensions/common/permissions/api_permission.h" 37 #include "extensions/common/permissions/api_permission.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 const int kFakeRenderProcessId = 42; 359 const int kFakeRenderProcessId = 42;
359 360
360 // Mock that the extension is running in a fake render process id. 361 // Mock that the extension is running in a fake render process id.
361 extensions::ProcessMap::Get(profile())->Insert(extension->id(), 362 extensions::ProcessMap::Get(profile())->Insert(extension->id(),
362 kFakeRenderProcessId, 363 kFakeRenderProcessId,
363 -1 /* site_instance_id */); 364 -1 /* site_instance_id */);
364 365
365 // Verify that the service indicates that permission has been granted. We only 366 // Verify that the service indicates that permission has been granted. We only
366 // check the UI thread-method for now, as that's the one guarding the behavior 367 // check the UI thread-method for now, as that's the one guarding the behavior
367 // in the browser process. 368 // in the browser process.
368 EXPECT_EQ(blink::WebNotificationPermissionAllowed, 369 EXPECT_EQ(blink::mojom::PermissionStatus::GRANTED,
369 service()->CheckPermissionOnUIThread(profile(), 370 service()->CheckPermissionOnUIThread(profile(),
370 extension->url(), 371 extension->url(),
371 kFakeRenderProcessId)); 372 kFakeRenderProcessId));
372 } 373 }
373 374
374 TEST_F(PlatformNotificationServiceTest, CreateNotificationFromData) { 375 TEST_F(PlatformNotificationServiceTest, CreateNotificationFromData) {
375 PlatformNotificationData notification_data; 376 PlatformNotificationData notification_data;
376 notification_data.title = base::ASCIIToUTF16("My Notification"); 377 notification_data.title = base::ASCIIToUTF16("My Notification");
377 notification_data.body = base::ASCIIToUTF16("Hello, world!"); 378 notification_data.body = base::ASCIIToUTF16("Hello, world!");
378 379
(...skipping 21 matching lines...) Expand all
400 notification = service()->CreateNotificationFromData( 401 notification = service()->CreateNotificationFromData(
401 profile(), 402 profile(),
402 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), 403 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"),
403 notification_data, NotificationResources(), 404 notification_data, NotificationResources(),
404 new MockNotificationDelegate("hello")); 405 new MockNotificationDelegate("hello"));
405 EXPECT_EQ("NotificationTest", 406 EXPECT_EQ("NotificationTest",
406 base::UTF16ToUTF8(notification.context_message())); 407 base::UTF16ToUTF8(notification.context_message()));
407 } 408 }
408 409
409 #endif // defined(ENABLE_EXTENSIONS) 410 #endif // defined(ENABLE_EXTENSIONS)
OLDNEW
« no previous file with comments | « chrome/browser/notifications/platform_notification_service_impl.cc ('k') | content/browser/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698