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

Side by Side Diff: chrome/browser/payments/payment_request_web_contents_manager_browsertest.cc

Issue 2611253004: [Payment Request] Change the lifetime management of PaymentRequestImpl (Closed)
Patch Set: PaymentRequestImpl -> PaymentRequest Created 3 years, 11 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <vector>
6
7 #include "base/command_line.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h"
12 #include "components/payments/payment_request.h"
13 #include "components/payments/payment_request_web_contents_manager.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/common/content_switches.h"
16 #include "net/test/embedded_test_server/embedded_test_server.h"
17 #include "url/gurl.h"
18
19 namespace payments {
20
21 class PaymentRequestWebContentsManagerBrowserTest
22 : public InProcessBrowserTest {
23 public:
24 PaymentRequestWebContentsManagerBrowserTest() {}
25 ~PaymentRequestWebContentsManagerBrowserTest() override {}
26
27 void SetUpCommandLine(base::CommandLine* command_line) override {
28 InProcessBrowserTest::SetUpCommandLine(command_line);
29 command_line->AppendSwitch(
30 switches::kEnableExperimentalWebPlatformFeatures);
31 }
32
33 void SetUpOnMainThread() override {
34 https_server_.reset(
35 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS));
36 ASSERT_TRUE(https_server_->InitializeAndListen());
37 https_server_->ServeFilesFromSourceDirectory("chrome/test/data");
38 https_server_->StartAcceptingConnections();
39 }
40
41 // Convenience method to get a list of PaymentRequest associated with
42 // |web_contents|.
43 const std::vector<PaymentRequest*> GetPaymentRequests(
44 content::WebContents* web_contents) {
45 PaymentRequestWebContentsManager* manager =
46 PaymentRequestWebContentsManager::GetOrCreateForWebContents(
47 web_contents);
48 if (!manager)
49 return std::vector<PaymentRequest*>();
50
51 std::vector<PaymentRequest*> payment_requests_ptrs;
52 for (const auto& p : manager->payment_requests_) {
53 payment_requests_ptrs.push_back(p.first);
54 }
55 return payment_requests_ptrs;
56 }
57
58 std::unique_ptr<net::EmbeddedTestServer> https_server_;
59
60 private:
61 DISALLOW_COPY_AND_ASSIGN(PaymentRequestWebContentsManagerBrowserTest);
62 };
63
64 IN_PROC_BROWSER_TEST_F(PaymentRequestWebContentsManagerBrowserTest,
65 MultiplePaymentRequests) {
66 GURL url = https_server_->GetURL("/payment_request_multiple_requests.html");
67 ui_test_utils::NavigateToURL(browser(), url);
68
69 const std::vector<PaymentRequest*> payment_requests =
70 GetPaymentRequests(browser()->tab_strip_model()->GetActiveWebContents());
71 EXPECT_EQ(5U, payment_requests.size());
72 }
73
74 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/payments/payment_request_impl.cc ('k') | chrome/browser/payments/site_per_process_payments_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698