Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: content/browser/payments/payment_app_browsertest.cc

Issue 2895583002: PaymentHandler: Clear storage partition data during content_browsertests. (Closed)
Patch Set: PaymentHandler: Clear storage partition data during content_browsertests. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 base::RunLoop run_loop;
123
124 static_cast<StoragePartitionImpl*>(
125 content::BrowserContext::GetDefaultStoragePartition(
126 shell()->web_contents()->GetBrowserContext()))
127 ->ClearData(StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS,
128 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, GURL(),
129 StoragePartition::OriginMatcherFunction(), base::Time(),
130 base::Time::Max(), run_loop.QuitClosure());
131
132 run_loop.Run();
133 }
134
117 private: 135 private:
118 std::unique_ptr<net::EmbeddedTestServer> https_server_; 136 std::unique_ptr<net::EmbeddedTestServer> https_server_;
119 137
120 DISALLOW_COPY_AND_ASSIGN(PaymentAppBrowserTest); 138 DISALLOW_COPY_AND_ASSIGN(PaymentAppBrowserTest);
121 }; 139 };
122 140
123 IN_PROC_BROWSER_TEST_F(PaymentAppBrowserTest, PaymentAppInvocation) { 141 IN_PROC_BROWSER_TEST_F(PaymentAppBrowserTest, PaymentAppInvocation) {
124 RegisterPaymentApp(); 142 RegisterPaymentApp();
125 143
126 std::vector<int64_t> ids = GetAllPaymentAppIDs(); 144 std::vector<int64_t> ids = GetAllPaymentAppIDs();
127 ASSERT_EQ(1U, ids.size()); 145 ASSERT_EQ(1U, ids.size());
128 146
129 payments::mojom::PaymentAppResponsePtr response(InvokePaymentApp(ids[0])); 147 payments::mojom::PaymentAppResponsePtr response(InvokePaymentApp(ids[0]));
130 ASSERT_EQ("test", response->method_name); 148 ASSERT_EQ("test", response->method_name);
149
150 ClearStoragePartitionData();
151
152 ids = GetAllPaymentAppIDs();
153 ASSERT_EQ(0U, ids.size());
131 } 154 }
132 155
133 } // namespace content 156 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698