Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "components/payments/mojom/payment_app.mojom.h" | 8 #include "components/payments/mojom/payment_app.mojom.h" |
| 9 #include "content/browser/storage_partition_impl.h" | |
| 10 #include "content/public/browser/browser_context.h" | |
| 9 #include "content/public/browser/payment_app_provider.h" | 11 #include "content/public/browser/payment_app_provider.h" |
| 10 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 11 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 12 #include "content/public/test/browser_test_utils.h" | 14 #include "content/public/test/browser_test_utils.h" |
| 13 #include "content/public/test/content_browser_test.h" | 15 #include "content/public/test/content_browser_test.h" |
| 14 #include "content/public/test/content_browser_test_utils.h" | 16 #include "content/public/test/content_browser_test_utils.h" |
| 15 #include "content/shell/browser/shell.h" | 17 #include "content/shell/browser/shell.h" |
| 16 #include "net/test/embedded_test_server/embedded_test_server.h" | 18 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 20 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 PaymentAppProvider::GetInstance()->InvokePaymentApp( | 109 PaymentAppProvider::GetInstance()->InvokePaymentApp( |
| 108 shell()->web_contents()->GetBrowserContext(), registration_id, | 110 shell()->web_contents()->GetBrowserContext(), registration_id, |
| 109 std::move(app_request), | 111 std::move(app_request), |
| 110 base::Bind(&InvokePaymentAppCallback, run_loop.QuitClosure(), | 112 base::Bind(&InvokePaymentAppCallback, run_loop.QuitClosure(), |
| 111 &response)); | 113 &response)); |
| 112 run_loop.Run(); | 114 run_loop.Run(); |
| 113 | 115 |
| 114 return response; | 116 return response; |
| 115 } | 117 } |
| 116 | 118 |
| 119 void ClearStoragePartitionData() { | |
| 120 // Clear data from the storage partition. Parameters are set to clear data | |
| 121 // for service workers, for all origins, for an unbounded time range. | |
| 122 StoragePartitionImpl* storage = static_cast<StoragePartitionImpl*>( | |
| 123 content::BrowserContext::GetDefaultStoragePartition( | |
| 124 shell()->web_contents()->GetBrowserContext())); | |
| 125 | |
| 126 uint32_t storage_partition_mask = | |
| 127 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS; | |
| 128 uint32_t quota_storage_mask = | |
| 129 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL; | |
| 130 const GURL& delete_origin = GURL(); | |
| 131 const base::Time delete_begin = base::Time(); | |
| 132 base::Time delete_end = base::Time::Max(); | |
| 133 | |
| 134 base::RunLoop run_loop; | |
| 135 | |
| 136 storage->ClearData(storage_partition_mask, quota_storage_mask, | |
| 137 delete_origin, StoragePartition::OriginMatcherFunction(), | |
| 138 delete_begin, delete_end, run_loop.QuitClosure()); | |
| 139 | |
| 140 run_loop.Run(); | |
|
please use gerrit instead
2017/05/19 14:23:43
Can you replace this implementation with these thr
zino
2017/05/21 11:52:57
Done.
| |
| 141 } | |
| 142 | |
| 117 private: | 143 private: |
| 118 std::unique_ptr<net::EmbeddedTestServer> https_server_; | 144 std::unique_ptr<net::EmbeddedTestServer> https_server_; |
| 119 | 145 |
| 120 DISALLOW_COPY_AND_ASSIGN(PaymentAppBrowserTest); | 146 DISALLOW_COPY_AND_ASSIGN(PaymentAppBrowserTest); |
| 121 }; | 147 }; |
| 122 | 148 |
| 123 IN_PROC_BROWSER_TEST_F(PaymentAppBrowserTest, PaymentAppInvocation) { | 149 IN_PROC_BROWSER_TEST_F(PaymentAppBrowserTest, PaymentAppInvocation) { |
| 124 RegisterPaymentApp(); | 150 RegisterPaymentApp(); |
| 125 | 151 |
| 126 std::vector<int64_t> ids = GetAllPaymentAppIDs(); | 152 std::vector<int64_t> ids = GetAllPaymentAppIDs(); |
| 127 ASSERT_EQ(1U, ids.size()); | 153 ASSERT_EQ(1U, ids.size()); |
| 128 | 154 |
| 129 payments::mojom::PaymentAppResponsePtr response(InvokePaymentApp(ids[0])); | 155 payments::mojom::PaymentAppResponsePtr response(InvokePaymentApp(ids[0])); |
| 130 ASSERT_EQ("test", response->method_name); | 156 ASSERT_EQ("test", response->method_name); |
| 157 | |
| 158 ClearStoragePartitionData(); | |
| 159 | |
| 160 ids = GetAllPaymentAppIDs(); | |
| 161 ASSERT_EQ(0U, ids.size()); | |
| 131 } | 162 } |
| 132 | 163 |
| 133 } // namespace content | 164 } // namespace content |
| OLD | NEW |