| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/service_worker/service_worker_storage.h" | 5 #include "content/browser/service_worker/service_worker_storage.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 ClearUserData(kRegistrationId, std::vector<std::string>())); | 1089 ClearUserData(kRegistrationId, std::vector<std::string>())); |
| 1090 EXPECT_EQ(SERVICE_WORKER_ERROR_FAILED, | 1090 EXPECT_EQ(SERVICE_WORKER_ERROR_FAILED, |
| 1091 ClearUserData(kRegistrationId, {std::string()})); | 1091 ClearUserData(kRegistrationId, {std::string()})); |
| 1092 EXPECT_EQ(SERVICE_WORKER_ERROR_FAILED, | 1092 EXPECT_EQ(SERVICE_WORKER_ERROR_FAILED, |
| 1093 ClearUserData(kRegistrationId, {std::string(), "key"})); | 1093 ClearUserData(kRegistrationId, {std::string(), "key"})); |
| 1094 data_list_out.clear(); | 1094 data_list_out.clear(); |
| 1095 EXPECT_EQ(SERVICE_WORKER_ERROR_FAILED, | 1095 EXPECT_EQ(SERVICE_WORKER_ERROR_FAILED, |
| 1096 GetUserDataForAllRegistrations(std::string(), &data_list_out)); | 1096 GetUserDataForAllRegistrations(std::string(), &data_list_out)); |
| 1097 } | 1097 } |
| 1098 | 1098 |
| 1099 // The *_BeforeInitialize tests exercise the API before LazyInitialize() is |
| 1100 // called. |
| 1101 TEST_P(ServiceWorkerStorageTestP, StoreUserData_BeforeInitialize) { |
| 1102 const int kRegistrationId = 0; |
| 1103 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, |
| 1104 StoreUserData(kRegistrationId, GURL("https://example.com"), |
| 1105 {{"key", "data"}})); |
| 1106 } |
| 1107 |
| 1108 TEST_P(ServiceWorkerStorageTestP, GetUserData_BeforeInitialize) { |
| 1109 const int kRegistrationId = 0; |
| 1110 std::vector<std::string> data_out; |
| 1111 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, |
| 1112 GetUserData(kRegistrationId, {"key"}, &data_out)); |
| 1113 } |
| 1114 |
| 1115 TEST_P(ServiceWorkerStorageTestP, ClearUserData_BeforeInitialize) { |
| 1116 const int kRegistrationId = 0; |
| 1117 EXPECT_EQ(SERVICE_WORKER_OK, ClearUserData(kRegistrationId, {"key"})); |
| 1118 } |
| 1119 |
| 1120 TEST_P(ServiceWorkerStorageTestP, |
| 1121 GetUserDataForAllRegistrations_BeforeInitialize) { |
| 1122 std::vector<std::pair<int64_t, std::string>> data_list_out; |
| 1123 EXPECT_EQ(SERVICE_WORKER_OK, |
| 1124 GetUserDataForAllRegistrations("key", &data_list_out)); |
| 1125 EXPECT_TRUE(data_list_out.empty()); |
| 1126 } |
| 1127 |
| 1099 class ServiceWorkerResourceStorageTest : public ServiceWorkerStorageTestP { | 1128 class ServiceWorkerResourceStorageTest : public ServiceWorkerStorageTestP { |
| 1100 public: | 1129 public: |
| 1101 void SetUp() override { | 1130 void SetUp() override { |
| 1102 ServiceWorkerStorageTestP::SetUp(); | 1131 ServiceWorkerStorageTestP::SetUp(); |
| 1103 LazyInitialize(); | 1132 LazyInitialize(); |
| 1104 | 1133 |
| 1105 scope_ = GURL("http://www.test.not/scope/"); | 1134 scope_ = GURL("http://www.test.not/scope/"); |
| 1106 script_ = GURL("http://www.test.not/script.js"); | 1135 script_ = GURL("http://www.test.not/script.js"); |
| 1107 import_ = GURL("http://www.test.not/import.js"); | 1136 import_ = GURL("http://www.test.not/import.js"); |
| 1108 document_url_ = GURL("http://www.test.not/scope/document.html"); | 1137 document_url_ = GURL("http://www.test.not/scope/document.html"); |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2118 ServiceWorkerStorageDiskTest, | 2147 ServiceWorkerStorageDiskTest, |
| 2119 testing::Bool()); | 2148 testing::Bool()); |
| 2120 INSTANTIATE_TEST_CASE_P(ServiceWorkerStorageOriginTrialsDiskTest, | 2149 INSTANTIATE_TEST_CASE_P(ServiceWorkerStorageOriginTrialsDiskTest, |
| 2121 ServiceWorkerStorageOriginTrialsDiskTest, | 2150 ServiceWorkerStorageOriginTrialsDiskTest, |
| 2122 testing::Bool()); | 2151 testing::Bool()); |
| 2123 INSTANTIATE_TEST_CASE_P(ServiceWorkerStorageTestP, | 2152 INSTANTIATE_TEST_CASE_P(ServiceWorkerStorageTestP, |
| 2124 ServiceWorkerStorageTestP, | 2153 ServiceWorkerStorageTestP, |
| 2125 testing::Bool()); | 2154 testing::Bool()); |
| 2126 | 2155 |
| 2127 } // namespace content | 2156 } // namespace content |
| OLD | NEW |