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

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: Windows Fix and Rebase Fix 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase( 53 PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase(
54 const std::string& test_file_path) 54 const std::string& test_file_path)
55 : test_file_path_(test_file_path), 55 : test_file_path_(test_file_path),
56 delegate_(nullptr), 56 delegate_(nullptr),
57 is_incognito_(false), 57 is_incognito_(false),
58 is_valid_ssl_(true) {} 58 is_valid_ssl_(true) {}
59 PaymentRequestBrowserTestBase::~PaymentRequestBrowserTestBase() {} 59 PaymentRequestBrowserTestBase::~PaymentRequestBrowserTestBase() {}
60 60
61 void PaymentRequestBrowserTestBase::SetUpOnMainThread() { 61 void PaymentRequestBrowserTestBase::SetUpOnMainThread() {
62 // Setup the https server.
62 https_server_ = base::MakeUnique<net::EmbeddedTestServer>( 63 https_server_ = base::MakeUnique<net::EmbeddedTestServer>(
63 net::EmbeddedTestServer::TYPE_HTTPS); 64 net::EmbeddedTestServer::TYPE_HTTPS);
64 ASSERT_TRUE(https_server_->InitializeAndListen()); 65 ASSERT_TRUE(https_server_->InitializeAndListen());
65 https_server_->ServeFilesFromSourceDirectory("chrome/test/data/payments"); 66 https_server_->ServeFilesFromSourceDirectory("chrome/test/data/payments");
66 https_server_->StartAcceptingConnections(); 67 https_server_->StartAcceptingConnections();
67 68
68 GURL url = https_server()->GetURL(test_file_path_); 69 NavigateTo(test_file_path_);
69 ui_test_utils::NavigateToURL(browser(), url);
70 70
71 // Starting now, PaymentRequest Mojo messages sent by the renderer will 71 // Starting now, PaymentRequest Mojo messages sent by the renderer will
72 // create PaymentRequest objects via this test's CreatePaymentRequestForTest, 72 // create PaymentRequest objects via this test's CreatePaymentRequestForTest,
73 // allowing the test to inject itself as a dialog observer. 73 // allowing the test to inject itself as a dialog observer.
74 content::WebContents* web_contents = GetActiveWebContents(); 74 content::WebContents* web_contents = GetActiveWebContents();
75 service_manager::BinderRegistry* registry = 75 service_manager::BinderRegistry* registry =
76 web_contents->GetMainFrame()->GetInterfaceRegistry(); 76 web_contents->GetMainFrame()->GetInterfaceRegistry();
77 registry->RemoveInterface(payments::mojom::PaymentRequest::Name_); 77 registry->RemoveInterface(payments::mojom::PaymentRequest::Name_);
78 registry->AddInterface( 78 registry->AddInterface(
79 base::Bind(&PaymentRequestBrowserTestBase::CreatePaymentRequestForTest, 79 base::Bind(&PaymentRequestBrowserTestBase::CreatePaymentRequestForTest,
80 base::Unretained(this), web_contents)); 80 base::Unretained(this), web_contents));
81 } 81 }
82 82
83 void PaymentRequestBrowserTestBase::NavigateTo(const std::string& file_path) {
84 ui_test_utils::NavigateToURL(browser(), https_server()->GetURL(file_path));
85 }
86
83 void PaymentRequestBrowserTestBase::SetIncognito() { 87 void PaymentRequestBrowserTestBase::SetIncognito() {
84 is_incognito_ = true; 88 is_incognito_ = true;
85 } 89 }
86 90
87 void PaymentRequestBrowserTestBase::SetInvalidSsl() { 91 void PaymentRequestBrowserTestBase::SetInvalidSsl() {
88 is_valid_ssl_ = false; 92 is_valid_ssl_ = false;
89 } 93 }
90 94
91 void PaymentRequestBrowserTestBase::OnCanMakePaymentCalled() { 95 void PaymentRequestBrowserTestBase::OnCanMakePaymentCalled() {
92 if (event_observer_) 96 if (event_observer_)
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 EXPECT_TRUE(view); 329 EXPECT_TRUE(view);
326 ClickOnDialogViewAndWait(view); 330 ClickOnDialogViewAndWait(view);
327 } 331 }
328 332
329 void PaymentRequestBrowserTestBase::ClickOnBackArrow() { 333 void PaymentRequestBrowserTestBase::ClickOnBackArrow() {
330 ResetEventObserver(DialogEvent::BACK_NAVIGATION); 334 ResetEventObserver(DialogEvent::BACK_NAVIGATION);
331 335
332 ClickOnDialogViewAndWait(DialogViewID::BACK_BUTTON); 336 ClickOnDialogViewAndWait(DialogViewID::BACK_BUTTON);
333 } 337 }
334 338
339 void PaymentRequestBrowserTestBase::ClickOnCancel() {
340 ResetEventObserver(DialogEvent::DIALOG_CLOSED);
341
342 ClickOnDialogViewAndWait(DialogViewID::CANCEL_BUTTON, false);
343 }
344
335 content::WebContents* PaymentRequestBrowserTestBase::GetActiveWebContents() { 345 content::WebContents* PaymentRequestBrowserTestBase::GetActiveWebContents() {
336 return browser()->tab_strip_model()->GetActiveWebContents(); 346 return browser()->tab_strip_model()->GetActiveWebContents();
337 } 347 }
338 348
339 const std::vector<PaymentRequest*> 349 const std::vector<PaymentRequest*>
340 PaymentRequestBrowserTestBase::GetPaymentRequests( 350 PaymentRequestBrowserTestBase::GetPaymentRequests(
341 content::WebContents* web_contents) { 351 content::WebContents* web_contents) {
342 PaymentRequestWebContentsManager* manager = 352 PaymentRequestWebContentsManager* manager =
343 PaymentRequestWebContentsManager::GetOrCreateForWebContents(web_contents); 353 PaymentRequestWebContentsManager::GetOrCreateForWebContents(web_contents);
344 if (!manager) 354 if (!manager)
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 std::list<DialogEvent> event_sequence) { 647 std::list<DialogEvent> event_sequence) {
638 event_observer_ = 648 event_observer_ =
639 base::MakeUnique<DialogEventObserver>(std::move(event_sequence)); 649 base::MakeUnique<DialogEventObserver>(std::move(event_sequence));
640 } 650 }
641 651
642 void PaymentRequestBrowserTestBase::WaitForObservedEvent() { 652 void PaymentRequestBrowserTestBase::WaitForObservedEvent() {
643 event_observer_->Wait(); 653 event_observer_->Wait();
644 } 654 }
645 655
646 } // namespace payments 656 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698