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

Unified Diff: chrome/browser/payments/site_per_process_payments_browsertest.cc

Issue 2611253004: [Payment Request] Change the lifetime management of PaymentRequestImpl (Closed)
Patch Set: added a browser test 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/payments/site_per_process_payments_browsertest.cc
diff --git a/chrome/browser/payments/site_per_process_payments_browsertest.cc b/chrome/browser/payments/site_per_process_payments_browsertest.cc
index 4007ee099090cbd16bc6220413a0652b8ebede0b..51a488b489c85487188d5045c1f965caf74307fa 100644
--- a/chrome/browser/payments/site_per_process_payments_browsertest.cc
+++ b/chrome/browser/payments/site_per_process_payments_browsertest.cc
@@ -2,12 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <vector>
+
#include "base/command_line.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/payments/payment_request_impl.h"
+#include "components/payments/payment_request_web_contents_manager.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
@@ -47,6 +51,23 @@ class SitePerProcessPaymentsBrowserTest : public InProcessBrowserTest {
https_server_->StartAcceptingConnections();
}
+ // Convenience method to get a list of PaymentRequestImpl associated with
+ // |web_contents|.
+ const std::vector<PaymentRequestImpl*> GetPaymentRequestImpls(
+ content::WebContents* web_contents) {
+ PaymentRequestWebContentsManager* manager =
+ PaymentRequestWebContentsManager::GetOrCreateForWebContents(
+ web_contents);
+ if (!manager)
+ return std::vector<PaymentRequestImpl*>();
+
+ std::vector<PaymentRequestImpl*> payment_requests_ptrs;
+ for (const auto& p : manager->payment_requests_) {
+ payment_requests_ptrs.push_back(p.first);
+ }
+ return payment_requests_ptrs;
+ }
+
std::unique_ptr<net::EmbeddedTestServer> https_server_;
private:
@@ -70,4 +91,16 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessPaymentsBrowserTest,
EXPECT_NE(frame->GetSiteInstance(), tab->GetMainFrame()->GetSiteInstance());
}
+IN_PROC_BROWSER_TEST_F(SitePerProcessPaymentsBrowserTest,
+ MultiplePaymentRequests) {
+ GURL url =
+ https_server_->GetURL("a.com", "/payment_request_multiple_requests.html");
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ const std::vector<PaymentRequestImpl*> payment_requests =
+ GetPaymentRequestImpls(
+ browser()->tab_strip_model()->GetActiveWebContents());
+ EXPECT_EQ(5U, payment_requests.size());
please use gerrit instead 2017/01/06 21:49:09 Would you mind adding a different browser test fil
Mathieu 2017/01/07 05:03:07 Done.
+}
+
} // namespace payments

Powered by Google App Engine
This is Rietveld 408576698