Chromium Code Reviews| Index: chrome/browser/ui/views/payments/payment_request_browsertest_base.cc |
| diff --git a/chrome/browser/ui/views/payments/payment_request_browsertest_base.cc b/chrome/browser/ui/views/payments/payment_request_browsertest_base.cc |
| index 1be7e708bdd776cfb21e2cd655077b8e9177d711..f601a821a7a0810431cd3da658ecd5fcc92156ef 100644 |
| --- a/chrome/browser/ui/views/payments/payment_request_browsertest_base.cc |
| +++ b/chrome/browser/ui/views/payments/payment_request_browsertest_base.cc |
| @@ -4,6 +4,7 @@ |
| #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" |
| +#include <algorithm> |
| #include <memory> |
| #include <string> |
| #include <utility> |
| @@ -96,6 +97,11 @@ void PaymentRequestBrowserTestBase::OnCanMakePaymentCalled() { |
| event_observer_->Observe(DialogEvent::CAN_MAKE_PAYMENT_CALLED); |
| } |
| +void PaymentRequestBrowserTestBase::OnNotSupportedError() { |
| + if (event_observer_) |
| + event_observer_->Observe(DialogEvent::NOT_SUPPORTED_ERROR); |
| +} |
| + |
| void PaymentRequestBrowserTestBase::OnDialogOpened() { |
| if (event_observer_) |
| event_observer_->Observe(DialogEvent::DIALOG_OPENED); |
| @@ -188,7 +194,7 @@ void PaymentRequestBrowserTestBase::InvokePaymentRequestUI() { |
| } |
| void PaymentRequestBrowserTestBase::ExpectBodyContains( |
| - const std::vector<base::string16>& expected_strings) { |
| + const std::vector<std::string>& expected_strings) { |
| content::WebContents* web_contents = GetActiveWebContents(); |
| const std::string extract_contents_js = |
| "(function() { " |
| @@ -197,13 +203,21 @@ void PaymentRequestBrowserTestBase::ExpectBodyContains( |
| std::string contents; |
| EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| web_contents, extract_contents_js, &contents)); |
| - for (const auto expected_string : expected_strings) { |
| - EXPECT_NE(std::string::npos, |
| - contents.find(base::UTF16ToUTF8(expected_string))) |
| + for (const auto& expected_string : expected_strings) { |
|
Mathieu
2017/04/17 03:20:45
Thanks :) let's use const std::string&
please use gerrit instead
2017/04/17 18:19:54
Done.
|
| + EXPECT_NE(std::string::npos, contents.find(expected_string)) |
| << "String not present: " << expected_string; |
| } |
| } |
| +void PaymentRequestBrowserTestBase::ExpectBodyContains( |
| + const std::vector<base::string16>& expected_strings) { |
| + std::vector<std::string> converted(expected_strings.size()); |
| + std::transform(expected_strings.begin(), expected_strings.end(), |
| + converted.begin(), |
| + [](const base::string16& s) { return base::UTF16ToUTF8(s); }); |
| + ExpectBodyContains(converted); |
| +} |
| + |
| void PaymentRequestBrowserTestBase::OpenOrderSummaryScreen() { |
| ResetEventObserver(DialogEvent::ORDER_SUMMARY_OPENED); |