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

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

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 years, 1 month 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 "content/public/browser/desktop_notification_delegate.h" 26 #include "content/public/browser/desktop_notification_delegate.h"
27 #include "content/public/common/notification_resources.h" 27 #include "content/public/common/notification_resources.h"
28 #include "content/public/common/platform_notification_data.h" 28 #include "content/public/common/platform_notification_data.h"
29 #include "content/public/test/test_browser_thread_bundle.h" 29 #include "content/public/test/test_browser_thread_bundle.h"
30 #include "extensions/features/features.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 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat us.mojom.h"
33 34
34 #if defined(ENABLE_EXTENSIONS) 35 #if BUILDFLAG(ENABLE_EXTENSIONS)
35 #include "base/command_line.h" 36 #include "base/command_line.h"
36 #include "chrome/browser/extensions/extension_service.h" 37 #include "chrome/browser/extensions/extension_service.h"
37 #include "chrome/browser/extensions/test_extension_system.h" 38 #include "chrome/browser/extensions/test_extension_system.h"
38 #include "extensions/browser/extension_registry.h" 39 #include "extensions/browser/extension_registry.h"
39 #include "extensions/browser/process_map.h" 40 #include "extensions/browser/process_map.h"
40 #include "extensions/common/extension.h" 41 #include "extensions/common/extension.h"
41 #include "extensions/common/extension_builder.h" 42 #include "extensions/common/extension_builder.h"
42 #include "extensions/common/permissions/api_permission.h" 43 #include "extensions/common/permissions/api_permission.h"
43 #include "extensions/common/value_builder.h" 44 #include "extensions/common/value_builder.h"
44 #endif 45 #endif
45 46
46 #if defined(ENABLE_EXTENSIONS) && defined(OS_CHROMEOS) 47 #if BUILDFLAG(ENABLE_EXTENSIONS) && defined(OS_CHROMEOS)
47 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" 48 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
48 #include "chrome/browser/chromeos/settings/cros_settings.h" 49 #include "chrome/browser/chromeos/settings/cros_settings.h"
49 #include "chrome/browser/chromeos/settings/device_settings_service.h" 50 #include "chrome/browser/chromeos/settings/device_settings_service.h"
50 #endif 51 #endif
51 52
52 using content::NotificationResources; 53 using content::NotificationResources;
53 using content::PlatformNotificationData; 54 using content::PlatformNotificationData;
54 55
55 namespace { 56 namespace {
56 57
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 service()->DisplayPersistentNotification( 310 service()->DisplayPersistentNotification(
310 profile(), kNotificationId, GURL() /* service_worker_scope */, origin, 311 profile(), kNotificationId, GURL() /* service_worker_scope */, origin,
311 PlatformNotificationData(), NotificationResources()); 312 PlatformNotificationData(), NotificationResources());
312 313
313 base::Time after_persistent_notification = 314 base::Time after_persistent_notification =
314 HostContentSettingsMapFactory::GetForProfile(profile())->GetLastUsage( 315 HostContentSettingsMapFactory::GetForProfile(profile())->GetLastUsage(
315 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 316 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
316 EXPECT_GT(after_persistent_notification, after_page_notification); 317 EXPECT_GT(after_persistent_notification, after_page_notification);
317 } 318 }
318 319
319 #if defined(ENABLE_EXTENSIONS) 320 #if BUILDFLAG(ENABLE_EXTENSIONS)
320 321
321 TEST_F(PlatformNotificationServiceTest, DisplayNameForContextMessage) { 322 TEST_F(PlatformNotificationServiceTest, DisplayNameForContextMessage) {
322 base::string16 display_name = service()->DisplayNameForContextMessage( 323 base::string16 display_name = service()->DisplayNameForContextMessage(
323 profile(), GURL("https://chrome.com/")); 324 profile(), GURL("https://chrome.com/"));
324 325
325 EXPECT_TRUE(display_name.empty()); 326 EXPECT_TRUE(display_name.empty());
326 327
327 // Create a mocked extension. 328 // Create a mocked extension.
328 scoped_refptr<extensions::Extension> extension = 329 scoped_refptr<extensions::Extension> extension =
329 extensions::ExtensionBuilder() 330 extensions::ExtensionBuilder()
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 notification = service()->CreateNotificationFromData( 435 notification = service()->CreateNotificationFromData(
435 profile(), 436 profile(),
436 GURL() /* service_worker_scope */, 437 GURL() /* service_worker_scope */,
437 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), 438 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"),
438 notification_data, NotificationResources(), 439 notification_data, NotificationResources(),
439 new MockNotificationDelegate("hello")); 440 new MockNotificationDelegate("hello"));
440 EXPECT_EQ("NotificationTest", 441 EXPECT_EQ("NotificationTest",
441 base::UTF16ToUTF8(notification.context_message())); 442 base::UTF16ToUTF8(notification.context_message()));
442 } 443 }
443 444
444 #endif // defined(ENABLE_EXTENSIONS) 445 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698