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

Side by Side Diff: chrome/browser/notifications/platform_notification_service_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 <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/message_center_display_service.h" 16 #include "chrome/browser/notifications/message_center_display_service.h"
17 #include "chrome/browser/notifications/notification_delegate.h" 17 #include "chrome/browser/notifications/notification_delegate.h"
18 #include "chrome/browser/notifications/notification_display_service_factory.h" 18 #include "chrome/browser/notifications/notification_display_service_factory.h"
19 #include "chrome/browser/notifications/notification_test_util.h" 19 #include "chrome/browser/notifications/notification_test_util.h"
20 #include "chrome/browser/notifications/platform_notification_service_impl.h" 20 #include "chrome/browser/notifications/platform_notification_service_impl.h"
21 #include "chrome/browser/notifications/stub_notification_platform_bridge.h" 21 #include "chrome/browser/notifications/stub_notification_platform_bridge.h"
22 #include "chrome/test/base/testing_browser_process.h" 22 #include "chrome/test/base/testing_browser_process.h"
23 #include "chrome/test/base/testing_profile.h" 23 #include "chrome/test/base/testing_profile.h"
24 #include "chrome/test/base/testing_profile_manager.h" 24 #include "chrome/test/base/testing_profile_manager.h"
25 #include "components/content_settings/core/browser/host_content_settings_map.h" 25 #include "components/content_settings/core/browser/host_content_settings_map.h"
26 #include "components/permissions/permission_status.mojom.h"
26 #include "content/public/browser/desktop_notification_delegate.h" 27 #include "content/public/browser/desktop_notification_delegate.h"
27 #include "content/public/common/notification_resources.h" 28 #include "content/public/common/notification_resources.h"
28 #include "content/public/common/platform_notification_data.h" 29 #include "content/public/common/platform_notification_data.h"
29 #include "content/public/test/test_browser_thread_bundle.h" 30 #include "content/public/test/test_browser_thread_bundle.h"
30 #include "testing/gmock/include/gmock/gmock.h" 31 #include "testing/gmock/include/gmock/gmock.h"
31 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
32 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat us.mojom.h"
33 33
34 #if defined(ENABLE_EXTENSIONS) 34 #if defined(ENABLE_EXTENSIONS)
35 #include "base/command_line.h" 35 #include "base/command_line.h"
36 #include "chrome/browser/extensions/extension_service.h" 36 #include "chrome/browser/extensions/extension_service.h"
37 #include "chrome/browser/extensions/test_extension_system.h" 37 #include "chrome/browser/extensions/test_extension_system.h"
38 #include "extensions/browser/extension_registry.h" 38 #include "extensions/browser/extension_registry.h"
39 #include "extensions/browser/process_map.h" 39 #include "extensions/browser/process_map.h"
40 #include "extensions/common/extension.h" 40 #include "extensions/common/extension.h"
41 #include "extensions/common/extension_builder.h" 41 #include "extensions/common/extension_builder.h"
42 #include "extensions/common/permissions/api_permission.h" 42 #include "extensions/common/permissions/api_permission.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 const int kFakeRenderProcessId = 42; 388 const int kFakeRenderProcessId = 42;
389 389
390 // Mock that the extension is running in a fake render process id. 390 // Mock that the extension is running in a fake render process id.
391 extensions::ProcessMap::Get(profile())->Insert(extension->id(), 391 extensions::ProcessMap::Get(profile())->Insert(extension->id(),
392 kFakeRenderProcessId, 392 kFakeRenderProcessId,
393 -1 /* site_instance_id */); 393 -1 /* site_instance_id */);
394 394
395 // Verify that the service indicates that permission has been granted. We only 395 // Verify that the service indicates that permission has been granted. We only
396 // check the UI thread-method for now, as that's the one guarding the behavior 396 // check the UI thread-method for now, as that's the one guarding the behavior
397 // in the browser process. 397 // in the browser process.
398 EXPECT_EQ(blink::mojom::PermissionStatus::GRANTED, 398 EXPECT_EQ(permissions::mojom::PermissionStatus::GRANTED,
399 service()->CheckPermissionOnUIThread(profile(), 399 service()->CheckPermissionOnUIThread(profile(), extension->url(),
400 extension->url(),
401 kFakeRenderProcessId)); 400 kFakeRenderProcessId));
402 } 401 }
403 402
404 TEST_F(PlatformNotificationServiceTest, CreateNotificationFromData) { 403 TEST_F(PlatformNotificationServiceTest, CreateNotificationFromData) {
405 PlatformNotificationData notification_data; 404 PlatformNotificationData notification_data;
406 notification_data.title = base::ASCIIToUTF16("My Notification"); 405 notification_data.title = base::ASCIIToUTF16("My Notification");
407 notification_data.body = base::ASCIIToUTF16("Hello, world!"); 406 notification_data.body = base::ASCIIToUTF16("Hello, world!");
408 407
409 Notification notification = service()->CreateNotificationFromData( 408 Notification notification = service()->CreateNotificationFromData(
410 profile(), GURL("https://chrome.com/"), notification_data, 409 profile(), GURL("https://chrome.com/"), notification_data,
(...skipping 19 matching lines...) Expand all
430 notification = service()->CreateNotificationFromData( 429 notification = service()->CreateNotificationFromData(
431 profile(), 430 profile(),
432 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), 431 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"),
433 notification_data, NotificationResources(), 432 notification_data, NotificationResources(),
434 new MockNotificationDelegate("hello")); 433 new MockNotificationDelegate("hello"));
435 EXPECT_EQ("NotificationTest", 434 EXPECT_EQ("NotificationTest",
436 base::UTF16ToUTF8(notification.context_message())); 435 base::UTF16ToUTF8(notification.context_message()));
437 } 436 }
438 437
439 #endif // defined(ENABLE_EXTENSIONS) 438 #endif // defined(ENABLE_EXTENSIONS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698