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

Unified Diff: chrome/browser/ui/views/payments/payment_request_interactive_uitest_base.cc

Issue 2649683002: [Payments] Improve the closing of the PR dialog. (Closed)
Patch Set: addressed comments from sky 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/ui/views/payments/payment_request_interactive_uitest_base.cc
diff --git a/chrome/browser/ui/views/payments/payment_request_interactive_uitest_base.cc b/chrome/browser/ui/views/payments/payment_request_interactive_uitest_base.cc
index b1e7f2720c378b3203ce46800656549520ab24e8..c88f0a33c409e907977fcc50ef57031c70088eb2 100644
--- a/chrome/browser/ui/views/payments/payment_request_interactive_uitest_base.cc
+++ b/chrome/browser/ui/views/payments/payment_request_interactive_uitest_base.cc
@@ -63,6 +63,12 @@ void PaymentRequestInteractiveTestBase::OnDialogOpened() {
event_observer_->Observe(DialogEvent::DIALOG_OPENED);
}
+void PaymentRequestInteractiveTestBase::OnWidgetDestroyed(
+ views::Widget* widget) {
+ if (event_observer_)
+ event_observer_->Observe(DialogEvent::DIALOG_CLOSED);
+}
+
void PaymentRequestInteractiveTestBase::InvokePaymentRequestUI() {
event_observer_.reset(new DialogEventObserver(DialogEvent::DIALOG_OPENED));
@@ -103,10 +109,11 @@ void PaymentRequestInteractiveTestBase::CreatePaymentRequestForTest(
mojo::InterfaceRequest<payments::mojom::PaymentRequest> request) {
DCHECK(web_contents);
PaymentRequestWebContentsManager::GetOrCreateForWebContents(web_contents)
- ->CreatePaymentRequest(web_contents,
- base::MakeUnique<TestChromePaymentRequestDelegate>(
- web_contents, this /* observer */),
- std::move(request));
+ ->CreatePaymentRequest(
+ web_contents,
+ base::MakeUnique<TestChromePaymentRequestDelegate>(
+ web_contents, this /* observer */, this /* widget_observer */),
+ std::move(request));
}
PaymentRequestInteractiveTestBase::DialogEventObserver::DialogEventObserver(
@@ -125,9 +132,21 @@ void PaymentRequestInteractiveTestBase::DialogEventObserver::Wait() {
void PaymentRequestInteractiveTestBase::DialogEventObserver::Observe(
PaymentRequestInteractiveTestBase::DialogEvent event) {
+ if (seen_)
+ return;
+
+ DCHECK_EQ(event_, event);
seen_ = true;
- if (event == event_ && run_loop_.running())
+ if (run_loop_.running())
run_loop_.Quit();
}
+void PaymentRequestInteractiveTestBase::ResetEventObserver(DialogEvent event) {
+ event_observer_.reset(new DialogEventObserver(event));
+}
+
+void PaymentRequestInteractiveTestBase::WaitForObservedEvent() {
+ event_observer_->Wait();
+}
+
} // namespace payments

Powered by Google App Engine
This is Rietveld 408576698