Chromium Code Reviews| Index: third_party/WebKit/Source/modules/payments/PaymentRequestUpdateEventTest.cpp |
| diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequestUpdateEventTest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequestUpdateEventTest.cpp |
| index ce0d4a7f888e9e75a05883b91e23d1eb2eadf2ff..8e0437750211b5051d47d2bceff0e1b350c3cbe3 100644 |
| --- a/third_party/WebKit/Source/modules/payments/PaymentRequestUpdateEventTest.cpp |
| +++ b/third_party/WebKit/Source/modules/payments/PaymentRequestUpdateEventTest.cpp |
| @@ -10,6 +10,7 @@ |
| #include "bindings/core/v8/V8BindingForTesting.h" |
| #include "core/EventTypeNames.h" |
| #include "modules/payments/PaymentUpdater.h" |
| +#include "platform/testing/UnitTestHelpers.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include <memory> |
| @@ -31,6 +32,44 @@ public: |
| DEFINE_INLINE_TRACE() {} |
| }; |
| +ACTION(exitLoop) |
| +{ |
| + testing::exitRunLoop(); |
| +} |
| + |
| +class MockPaymentUpdaterForTimeout : public GarbageCollectedFinalized<MockPaymentUpdater>, public PaymentUpdater { |
| + USING_GARBAGE_COLLECTED_MIXIN(MockPaymentUpdaterForTimeout); |
| + WTF_MAKE_NONCOPYABLE(MockPaymentUpdaterForTimeout); |
| + |
| +public: |
| + MockPaymentUpdaterForTimeout() |
| + { |
| + ON_CALL(*this, onUpdatePaymentDetailsFailure(::testing::_)).WillByDefault( |
| + ::testing::DoAll(exitLoop(), ::testing::Return())); |
| + } |
| + ~MockPaymentUpdaterForTimeout() override {} |
| + |
| + MOCK_METHOD1(onUpdatePaymentDetails, void(const ScriptValue& detailsScriptValue)); |
| + MOCK_METHOD1(onUpdatePaymentDetailsFailure, void(const ScriptValue& error)); |
| + |
| + DEFINE_INLINE_TRACE() {} |
| +}; |
| + |
| +TEST(PaymentRequestUpdateEventTest, OnUpdatePaymentDetailsTimeout) |
| +{ |
| + V8TestingScope scope; |
| + PaymentRequestUpdateEvent* event = PaymentRequestUpdateEvent::create(); |
| + String errorMessage; |
| + MockPaymentUpdaterForTimeout* updater = new MockPaymentUpdaterForTimeout; |
| + event->setPaymentDetailsUpdater(updater); |
| + event->setEventPhase(Event::CAPTURING_PHASE); |
| + |
| + EXPECT_CALL(*updater, onUpdatePaymentDetails(::testing::_)).Times(0); |
| + EXPECT_CALL(*updater, onUpdatePaymentDetailsFailure(::testing::_)); |
| + |
| + testing::enterRunLoop(); |
|
please use gerrit instead
2016/07/21 16:35:24
This test will run 5 seconds. If I want to change
pals
2016/07/22 04:06:19
Done.
|
| +} |
| + |
| TEST(PaymentRequestUpdateEventTest, OnUpdatePaymentDetailsCalled) |
| { |
| V8TestingScope scope; |
| @@ -42,8 +81,8 @@ TEST(PaymentRequestUpdateEventTest, OnUpdatePaymentDetailsCalled) |
| event->updateWith(scope.getScriptState(), paymentDetails->promise(), scope.getExceptionState()); |
| EXPECT_FALSE(scope.getExceptionState().hadException()); |
| - EXPECT_CALL(*updater, onUpdatePaymentDetails(testing::_)); |
| - EXPECT_CALL(*updater, onUpdatePaymentDetailsFailure(testing::_)).Times(0); |
| + EXPECT_CALL(*updater, onUpdatePaymentDetails(::testing::_)); |
| + EXPECT_CALL(*updater, onUpdatePaymentDetailsFailure(::testing::_)).Times(0); |
| paymentDetails->resolve("foo"); |
| } |
| @@ -59,8 +98,8 @@ TEST(PaymentRequestUpdateEventTest, OnUpdatePaymentDetailsFailureCalled) |
| event->updateWith(scope.getScriptState(), paymentDetails->promise(), scope.getExceptionState()); |
| EXPECT_FALSE(scope.getExceptionState().hadException()); |
| - EXPECT_CALL(*updater, onUpdatePaymentDetails(testing::_)).Times(0); |
| - EXPECT_CALL(*updater, onUpdatePaymentDetailsFailure(testing::_)); |
| + EXPECT_CALL(*updater, onUpdatePaymentDetails(::testing::_)).Times(0); |
| + EXPECT_CALL(*updater, onUpdatePaymentDetailsFailure(::testing::_)); |
| paymentDetails->reject("oops"); |
| } |