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

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentResponseTest.cpp

Issue 2054823002: PaymentRequest: complete() method should take PaymentComplete enum value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "modules/payments/PaymentResponse.h" 5 #include "modules/payments/PaymentResponse.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "bindings/core/v8/ScriptValue.h" 9 #include "bindings/core/v8/ScriptValue.h"
10 #include "bindings/core/v8/V8Binding.h" 10 #include "bindings/core/v8/V8Binding.h"
(...skipping 14 matching lines...) Expand all
25 25
26 public: 26 public:
27 MockPaymentCompleter() 27 MockPaymentCompleter()
28 { 28 {
29 ON_CALL(*this, complete(testing::_, testing::_)) 29 ON_CALL(*this, complete(testing::_, testing::_))
30 .WillByDefault(testing::ReturnPointee(&m_dummyPromise)); 30 .WillByDefault(testing::ReturnPointee(&m_dummyPromise));
31 } 31 }
32 32
33 ~MockPaymentCompleter() override {} 33 ~MockPaymentCompleter() override {}
34 34
35 MOCK_METHOD2(complete, ScriptPromise(ScriptState*, bool success)); 35 MOCK_METHOD2(complete, ScriptPromise(ScriptState*, PaymentComplete result));
36 36
37 DEFINE_INLINE_TRACE() {} 37 DEFINE_INLINE_TRACE() {}
38 38
39 private: 39 private:
40 ScriptPromise m_dummyPromise; 40 ScriptPromise m_dummyPromise;
41 }; 41 };
42 42
43 TEST(PaymentResponseTest, DataCopiedOver) 43 TEST(PaymentResponseTest, DataCopiedOver)
44 { 44 {
45 V8TestingScope scope; 45 V8TestingScope scope;
(...skipping 30 matching lines...) Expand all
76 76
77 TEST(PaymentResponseTest, CompleteCalledWithSuccess) 77 TEST(PaymentResponseTest, CompleteCalledWithSuccess)
78 { 78 {
79 V8TestingScope scope; 79 V8TestingScope scope;
80 mojom::blink::PaymentResponsePtr input = buildPaymentResponseForTest(); 80 mojom::blink::PaymentResponsePtr input = buildPaymentResponseForTest();
81 input->method_name = "foo"; 81 input->method_name = "foo";
82 input->stringified_details = "{\"transactionId\": 123}"; 82 input->stringified_details = "{\"transactionId\": 123}";
83 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; 83 MockPaymentCompleter* completeCallback = new MockPaymentCompleter;
84 PaymentResponse output(std::move(input), completeCallback); 84 PaymentResponse output(std::move(input), completeCallback);
85 85
86 EXPECT_CALL(*completeCallback, complete(scope.getScriptState(), true)); 86 EXPECT_CALL(*completeCallback, complete(scope.getScriptState(), Success));
87 87
88 output.complete(scope.getScriptState(), true); 88 output.complete(scope.getScriptState(), "success");
89 } 89 }
90 90
91 TEST(PaymentResponseTest, CompleteCalledWithFailure) 91 TEST(PaymentResponseTest, CompleteCalledWithFailure)
92 { 92 {
93 V8TestingScope scope; 93 V8TestingScope scope;
94 mojom::blink::PaymentResponsePtr input = buildPaymentResponseForTest(); 94 mojom::blink::PaymentResponsePtr input = buildPaymentResponseForTest();
95 input->method_name = "foo"; 95 input->method_name = "foo";
96 input->stringified_details = "{\"transactionId\": 123}"; 96 input->stringified_details = "{\"transactionId\": 123}";
97 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; 97 MockPaymentCompleter* completeCallback = new MockPaymentCompleter;
98 PaymentResponse output(std::move(input), completeCallback); 98 PaymentResponse output(std::move(input), completeCallback);
99 99
100 EXPECT_CALL(*completeCallback, complete(scope.getScriptState(), false)); 100 EXPECT_CALL(*completeCallback, complete(scope.getScriptState(), Fail));
101 101
102 output.complete(scope.getScriptState(), false); 102 output.complete(scope.getScriptState(), "fail");
103 } 103 }
104 104
105 } // namespace 105 } // namespace
106 } // namespace blink 106 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698