OLD | NEW |
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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "chrome/browser/extensions/extension_service.h" | 41 #include "chrome/browser/extensions/extension_service.h" |
42 #include "chrome/browser/extensions/test_extension_system.h" | 42 #include "chrome/browser/extensions/test_extension_system.h" |
43 #include "extensions/browser/extension_registry.h" | 43 #include "extensions/browser/extension_registry.h" |
44 #include "extensions/browser/process_map.h" | 44 #include "extensions/browser/process_map.h" |
45 #include "extensions/common/extension.h" | 45 #include "extensions/common/extension.h" |
46 #include "extensions/common/extension_builder.h" | 46 #include "extensions/common/extension_builder.h" |
47 #include "extensions/common/permissions/api_permission.h" | 47 #include "extensions/common/permissions/api_permission.h" |
48 #include "extensions/common/value_builder.h" | 48 #include "extensions/common/value_builder.h" |
49 #endif | 49 #endif |
50 | 50 |
51 #if BUILDFLAG(ENABLE_EXTENSIONS) && defined(OS_CHROMEOS) | |
52 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" | |
53 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
54 #include "chrome/browser/chromeos/settings/device_settings_service.h" | |
55 #endif | |
56 | |
57 using content::NotificationResources; | 51 using content::NotificationResources; |
58 using content::PlatformNotificationData; | 52 using content::PlatformNotificationData; |
59 | 53 |
60 namespace { | 54 namespace { |
61 | 55 |
62 const char kNotificationId[] = "my-notification-id"; | 56 const char kNotificationId[] = "my-notification-id"; |
63 const int kNotificationVibrationPattern[] = { 100, 200, 300 }; | 57 const int kNotificationVibrationPattern[] = { 100, 200, 300 }; |
64 | 58 |
65 class MockDesktopNotificationDelegate | 59 class MockDesktopNotificationDelegate |
66 : public content::DesktopNotificationDelegate { | 60 : public content::DesktopNotificationDelegate { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 extensions::ExtensionRegistry::Get(profile()); | 332 extensions::ExtensionRegistry::Get(profile()); |
339 EXPECT_TRUE(registry->AddEnabled(extension)); | 333 EXPECT_TRUE(registry->AddEnabled(extension)); |
340 | 334 |
341 display_name = service()->DisplayNameForContextMessage( | 335 display_name = service()->DisplayNameForContextMessage( |
342 profile(), | 336 profile(), |
343 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html")); | 337 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html")); |
344 EXPECT_EQ("NotificationTest", base::UTF16ToUTF8(display_name)); | 338 EXPECT_EQ("NotificationTest", base::UTF16ToUTF8(display_name)); |
345 } | 339 } |
346 | 340 |
347 TEST_F(PlatformNotificationServiceTest, ExtensionPermissionChecks) { | 341 TEST_F(PlatformNotificationServiceTest, ExtensionPermissionChecks) { |
348 #if defined(OS_CHROMEOS) | |
349 // The ExtensionService on Chrome OS requires these objects to be initialized. | |
350 chromeos::ScopedTestDeviceSettingsService test_device_settings_service; | |
351 chromeos::ScopedTestCrosSettings test_cros_settings; | |
352 chromeos::ScopedTestUserManager test_user_manager; | |
353 #endif | |
354 | |
355 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 342 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
356 extensions::TestExtensionSystem* test_extension_system = | 343 extensions::TestExtensionSystem* test_extension_system = |
357 static_cast<extensions::TestExtensionSystem*>( | 344 static_cast<extensions::TestExtensionSystem*>( |
358 extensions::ExtensionSystem::Get(profile())); | 345 extensions::ExtensionSystem::Get(profile())); |
359 | 346 |
360 ExtensionService* extension_service = | 347 ExtensionService* extension_service = |
361 test_extension_system->CreateExtensionService( | 348 test_extension_system->CreateExtensionService( |
362 &command_line, base::FilePath() /* install_directory */, | 349 &command_line, base::FilePath() /* install_directory */, |
363 false /* autoupdate_enabled */); | 350 false /* autoupdate_enabled */); |
364 | 351 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 profile(), | 420 profile(), |
434 GURL() /* service_worker_scope */, | 421 GURL() /* service_worker_scope */, |
435 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), | 422 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), |
436 notification_data, NotificationResources(), | 423 notification_data, NotificationResources(), |
437 new MockNotificationDelegate("hello")); | 424 new MockNotificationDelegate("hello")); |
438 EXPECT_EQ("NotificationTest", | 425 EXPECT_EQ("NotificationTest", |
439 base::UTF16ToUTF8(notification.context_message())); | 426 base::UTF16ToUTF8(notification.context_message())); |
440 } | 427 } |
441 | 428 |
442 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 429 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
OLD | NEW |