OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/gcm/fake_gcm_profile_service.h" | 13 #include "chrome/browser/gcm/fake_gcm_profile_service.h" |
14 #include "chrome/browser/gcm/gcm_profile_service_factory.h" | 14 #include "chrome/browser/gcm/gcm_profile_service_factory.h" |
15 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 15 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| 16 #include "chrome/browser/notifications/notification_display_service_factory.h" |
| 17 #include "chrome/browser/notifications/stub_notification_display_service.h" |
16 #include "chrome/browser/permissions/permission_manager.h" | 18 #include "chrome/browser/permissions/permission_manager.h" |
17 #include "chrome/browser/permissions/permission_result.h" | 19 #include "chrome/browser/permissions/permission_result.h" |
18 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" | 20 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" |
19 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" | 21 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" |
20 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" | 22 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
22 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
23 #include "components/content_settings/core/common/content_settings_types.h" | 25 #include "components/content_settings/core/common/content_settings_types.h" |
24 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" | 26 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" |
25 #include "components/version_info/version_info.h" | 27 #include "components/version_info/version_info.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 return app_identifier; | 244 return app_identifier; |
243 } | 245 } |
244 | 246 |
245 // ExtensionApiTest overrides. | 247 // ExtensionApiTest overrides. |
246 void SetUpCommandLine(base::CommandLine* command_line) override { | 248 void SetUpCommandLine(base::CommandLine* command_line) override { |
247 command_line->AppendSwitch( | 249 command_line->AppendSwitch( |
248 switches::kEnableExperimentalWebPlatformFeatures); | 250 switches::kEnableExperimentalWebPlatformFeatures); |
249 ServiceWorkerTest::SetUpCommandLine(command_line); | 251 ServiceWorkerTest::SetUpCommandLine(command_line); |
250 } | 252 } |
251 void SetUpOnMainThread() override { | 253 void SetUpOnMainThread() override { |
| 254 NotificationDisplayServiceFactory::GetInstance()->SetTestingFactory( |
| 255 profile(), &StubNotificationDisplayService::FactoryForTests); |
| 256 |
252 gcm::FakeGCMProfileService* gcm_service = | 257 gcm::FakeGCMProfileService* gcm_service = |
253 static_cast<gcm::FakeGCMProfileService*>( | 258 static_cast<gcm::FakeGCMProfileService*>( |
254 gcm::GCMProfileServiceFactory::GetInstance() | 259 gcm::GCMProfileServiceFactory::GetInstance() |
255 ->SetTestingFactoryAndUse(profile(), | 260 ->SetTestingFactoryAndUse(profile(), |
256 &gcm::FakeGCMProfileService::Build)); | 261 &gcm::FakeGCMProfileService::Build)); |
257 gcm_driver_ = static_cast<instance_id::FakeGCMDriverForInstanceID*>( | 262 gcm_driver_ = static_cast<instance_id::FakeGCMDriverForInstanceID*>( |
258 gcm_service->driver()); | 263 gcm_service->driver()); |
259 push_service_ = PushMessagingServiceFactory::GetForProfile(profile()); | 264 push_service_ = PushMessagingServiceFactory::GetForProfile(profile()); |
260 | 265 |
261 ServiceWorkerTest::SetUpOnMainThread(); | 266 ServiceWorkerTest::SetUpOnMainThread(); |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 message.sender_id = "1234567890"; | 875 message.sender_id = "1234567890"; |
871 message.raw_data = "testdata"; | 876 message.raw_data = "testdata"; |
872 message.decrypted = true; | 877 message.decrypted = true; |
873 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); | 878 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); |
874 push_service()->OnMessage(app_identifier.app_id(), message); | 879 push_service()->OnMessage(app_identifier.app_id(), message); |
875 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); | 880 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); |
876 run_loop.Run(); // Wait until the message is handled by push service. | 881 run_loop.Run(); // Wait until the message is handled by push service. |
877 } | 882 } |
878 | 883 |
879 } // namespace extensions | 884 } // namespace extensions |
OLD | NEW |