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

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_browsertest_base.cc

Issue 2851893002: [Payments] Record CanMakePayment metrics on Desktop. (Closed)
Patch Set: Addressed Mathp's comments 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
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 "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" 5 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 void PaymentRequestBrowserTestBase::SetUpCommandLine( 62 void PaymentRequestBrowserTestBase::SetUpCommandLine(
63 base::CommandLine* command_line) { 63 base::CommandLine* command_line) {
64 InProcessBrowserTest::SetUpCommandLine(command_line); 64 InProcessBrowserTest::SetUpCommandLine(command_line);
65 command_line->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures); 65 command_line->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures);
66 command_line->AppendSwitchASCII(switches::kEnableFeatures, 66 command_line->AppendSwitchASCII(switches::kEnableFeatures,
67 features::kWebPayments.name); 67 features::kWebPayments.name);
68 } 68 }
69 69
70 void PaymentRequestBrowserTestBase::SetUpOnMainThread() { 70 void PaymentRequestBrowserTestBase::SetUpOnMainThread() {
71 // Setup the https server.
71 https_server_ = base::MakeUnique<net::EmbeddedTestServer>( 72 https_server_ = base::MakeUnique<net::EmbeddedTestServer>(
72 net::EmbeddedTestServer::TYPE_HTTPS); 73 net::EmbeddedTestServer::TYPE_HTTPS);
73 ASSERT_TRUE(https_server_->InitializeAndListen()); 74 ASSERT_TRUE(https_server_->InitializeAndListen());
74 https_server_->ServeFilesFromSourceDirectory("chrome/test/data/payments"); 75 https_server_->ServeFilesFromSourceDirectory("chrome/test/data/payments");
75 https_server_->StartAcceptingConnections(); 76 https_server_->StartAcceptingConnections();
76 77
77 GURL url = https_server()->GetURL(test_file_path_); 78 NavigateTo(test_file_path_);
78 ui_test_utils::NavigateToURL(browser(), url);
79 79
80 // Starting now, PaymentRequest Mojo messages sent by the renderer will 80 // Starting now, PaymentRequest Mojo messages sent by the renderer will
81 // create PaymentRequest objects via this test's CreatePaymentRequestForTest, 81 // create PaymentRequest objects via this test's CreatePaymentRequestForTest,
82 // allowing the test to inject itself as a dialog observer. 82 // allowing the test to inject itself as a dialog observer.
83 content::WebContents* web_contents = GetActiveWebContents(); 83 content::WebContents* web_contents = GetActiveWebContents();
84 service_manager::InterfaceRegistry* registry = 84 service_manager::InterfaceRegistry* registry =
85 web_contents->GetMainFrame()->GetInterfaceRegistry(); 85 web_contents->GetMainFrame()->GetInterfaceRegistry();
86 registry->RemoveInterface(payments::mojom::PaymentRequest::Name_); 86 registry->RemoveInterface(payments::mojom::PaymentRequest::Name_);
87 registry->AddInterface( 87 registry->AddInterface(
88 base::Bind(&PaymentRequestBrowserTestBase::CreatePaymentRequestForTest, 88 base::Bind(&PaymentRequestBrowserTestBase::CreatePaymentRequestForTest,
89 base::Unretained(this), web_contents)); 89 base::Unretained(this), web_contents));
90 } 90 }
91 91
92 void PaymentRequestBrowserTestBase::NavigateTo(const std::string& file_path) {
93 ui_test_utils::NavigateToURL(browser(), https_server()->GetURL(file_path));
Mathieu 2017/05/03 02:22:49 can you use NavigateTo in other tests where we wer
sebsg 2017/05/03 17:10:11 Done.
94 }
95
92 void PaymentRequestBrowserTestBase::SetIncognito() { 96 void PaymentRequestBrowserTestBase::SetIncognito() {
93 is_incognito_ = true; 97 is_incognito_ = true;
94 } 98 }
95 99
96 void PaymentRequestBrowserTestBase::SetInvalidSsl() { 100 void PaymentRequestBrowserTestBase::SetInvalidSsl() {
97 is_valid_ssl_ = false; 101 is_valid_ssl_ = false;
98 } 102 }
99 103
100 void PaymentRequestBrowserTestBase::OnCanMakePaymentCalled() { 104 void PaymentRequestBrowserTestBase::OnCanMakePaymentCalled() {
101 if (event_observer_) 105 if (event_observer_)
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 314
311 ClickOnDialogViewAndWait(DialogViewID::PAYMENT_METHOD_ADD_CONTACT_BUTTON); 315 ClickOnDialogViewAndWait(DialogViewID::PAYMENT_METHOD_ADD_CONTACT_BUTTON);
312 } 316 }
313 317
314 void PaymentRequestBrowserTestBase::ClickOnBackArrow() { 318 void PaymentRequestBrowserTestBase::ClickOnBackArrow() {
315 ResetEventObserver(DialogEvent::BACK_NAVIGATION); 319 ResetEventObserver(DialogEvent::BACK_NAVIGATION);
316 320
317 ClickOnDialogViewAndWait(DialogViewID::BACK_BUTTON); 321 ClickOnDialogViewAndWait(DialogViewID::BACK_BUTTON);
318 } 322 }
319 323
324 void PaymentRequestBrowserTestBase::ClickOnCancel() {
325 ResetEventObserver(DialogEvent::DIALOG_CLOSED);
326
327 ClickOnDialogViewAndWait(DialogViewID::CANCEL_BUTTON, false);
328 }
329
320 content::WebContents* PaymentRequestBrowserTestBase::GetActiveWebContents() { 330 content::WebContents* PaymentRequestBrowserTestBase::GetActiveWebContents() {
321 return browser()->tab_strip_model()->GetActiveWebContents(); 331 return browser()->tab_strip_model()->GetActiveWebContents();
322 } 332 }
323 333
324 const std::vector<PaymentRequest*> 334 const std::vector<PaymentRequest*>
325 PaymentRequestBrowserTestBase::GetPaymentRequests( 335 PaymentRequestBrowserTestBase::GetPaymentRequests(
326 content::WebContents* web_contents) { 336 content::WebContents* web_contents) {
327 PaymentRequestWebContentsManager* manager = 337 PaymentRequestWebContentsManager* manager =
328 PaymentRequestWebContentsManager::GetOrCreateForWebContents(web_contents); 338 PaymentRequestWebContentsManager::GetOrCreateForWebContents(web_contents);
329 if (!manager) 339 if (!manager)
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 std::list<DialogEvent> event_sequence) { 627 std::list<DialogEvent> event_sequence) {
618 event_observer_ = 628 event_observer_ =
619 base::MakeUnique<DialogEventObserver>(std::move(event_sequence)); 629 base::MakeUnique<DialogEventObserver>(std::move(event_sequence));
620 } 630 }
621 631
622 void PaymentRequestBrowserTestBase::WaitForObservedEvent() { 632 void PaymentRequestBrowserTestBase::WaitForObservedEvent() {
623 event_observer_->Wait(); 633 event_observer_->Wait();
624 } 634 }
625 635
626 } // namespace payments 636 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698