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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/thread_task_runner_handle.h" |
9 #include "content/browser/notifications/platform_notification_context_impl.h" | 10 #include "content/browser/notifications/platform_notification_context_impl.h" |
10 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 11 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
11 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 12 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
12 #include "content/common/service_worker/service_worker_types.h" | 13 #include "content/common/service_worker/service_worker_types.h" |
13 #include "content/public/browser/notification_database_data.h" | 14 #include "content/public/browser/notification_database_data.h" |
14 #include "content/public/test/test_browser_context.h" | 15 #include "content/public/test/test_browser_context.h" |
15 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 | 19 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 nullptr); | 93 nullptr); |
93 context->Initialize(); | 94 context->Initialize(); |
94 | 95 |
95 OverrideTaskRunnerForTesting(context); | 96 OverrideTaskRunnerForTesting(context); |
96 return context; | 97 return context; |
97 } | 98 } |
98 | 99 |
99 // Overrides the task runner in |context| with the current message loop | 100 // Overrides the task runner in |context| with the current message loop |
100 // proxy, to reduce the number of threads involved in the tests. | 101 // proxy, to reduce the number of threads involved in the tests. |
101 void OverrideTaskRunnerForTesting(PlatformNotificationContextImpl* context) { | 102 void OverrideTaskRunnerForTesting(PlatformNotificationContextImpl* context) { |
102 context->SetTaskRunnerForTesting(base::MessageLoopProxy::current()); | 103 context->SetTaskRunnerForTesting(base::ThreadTaskRunnerHandle::Get()); |
103 } | 104 } |
104 | 105 |
105 // Returns the testing browsing context that can be used for this test. | 106 // Returns the testing browsing context that can be used for this test. |
106 BrowserContext* browser_context() { return &browser_context_; } | 107 BrowserContext* browser_context() { return &browser_context_; } |
107 | 108 |
108 // Returns whether the last invoked callback finished successfully. | 109 // Returns whether the last invoked callback finished successfully. |
109 bool success() const { return success_; } | 110 bool success() const { return success_; } |
110 | 111 |
111 // Returns the NotificationDatabaseData associated with the last invoked | 112 // Returns the NotificationDatabaseData associated with the last invoked |
112 // ReadNotificationData callback. | 113 // ReadNotificationData callback. |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 ASSERT_EQ(10u, notification_database_datas.size()); | 440 ASSERT_EQ(10u, notification_database_datas.size()); |
440 | 441 |
441 for (int i = 0; i < 10; ++i) { | 442 for (int i = 0; i < 10; ++i) { |
442 EXPECT_EQ(origin, notification_database_datas[i].origin); | 443 EXPECT_EQ(origin, notification_database_datas[i].origin); |
443 EXPECT_EQ(kFakeServiceWorkerRegistrationId, | 444 EXPECT_EQ(kFakeServiceWorkerRegistrationId, |
444 notification_database_datas[i].service_worker_registration_id); | 445 notification_database_datas[i].service_worker_registration_id); |
445 } | 446 } |
446 } | 447 } |
447 | 448 |
448 } // namespace content | 449 } // namespace content |
OLD | NEW |