OLD | NEW |
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/PaymentTestHelper.h" | 5 #include "modules/payments/PaymentTestHelper.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "modules/payments/PaymentCurrencyAmount.h" | 9 #include "modules/payments/PaymentCurrencyAmount.h" |
10 #include "modules/payments/PaymentMethodData.h" | 10 #include "modules/payments/PaymentMethodData.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 | 147 |
148 PaymentRequestMockFunctionScope::~PaymentRequestMockFunctionScope() | 148 PaymentRequestMockFunctionScope::~PaymentRequestMockFunctionScope() |
149 { | 149 { |
150 v8::MicrotasksScope::PerformCheckpoint(m_scriptState->isolate()); | 150 v8::MicrotasksScope::PerformCheckpoint(m_scriptState->isolate()); |
151 for (MockFunction* mockFunction : m_mockFunctions) { | 151 for (MockFunction* mockFunction : m_mockFunctions) { |
152 testing::Mock::VerifyAndClearExpectations(mockFunction); | 152 testing::Mock::VerifyAndClearExpectations(mockFunction); |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
| 156 v8::Local<v8::Function> PaymentRequestMockFunctionScope::expectCall(String* capt
or) |
| 157 { |
| 158 m_mockFunctions.append(new MockFunction(m_scriptState, captor)); |
| 159 return m_mockFunctions.last()->bind(); |
| 160 } |
| 161 |
156 v8::Local<v8::Function> PaymentRequestMockFunctionScope::expectCall() | 162 v8::Local<v8::Function> PaymentRequestMockFunctionScope::expectCall() |
157 { | 163 { |
158 m_mockFunctions.append(new MockFunction(m_scriptState)); | 164 m_mockFunctions.append(new MockFunction(m_scriptState)); |
159 EXPECT_CALL(*m_mockFunctions.last(), call(testing::_)); | 165 EXPECT_CALL(*m_mockFunctions.last(), call(testing::_)); |
160 return m_mockFunctions.last()->bind(); | 166 return m_mockFunctions.last()->bind(); |
161 } | 167 } |
162 | 168 |
163 v8::Local<v8::Function> PaymentRequestMockFunctionScope::expectNoCall() | 169 v8::Local<v8::Function> PaymentRequestMockFunctionScope::expectNoCall() |
164 { | 170 { |
165 m_mockFunctions.append(new MockFunction(m_scriptState)); | 171 m_mockFunctions.append(new MockFunction(m_scriptState)); |
166 EXPECT_CALL(*m_mockFunctions.last(), call(testing::_)).Times(0); | 172 EXPECT_CALL(*m_mockFunctions.last(), call(testing::_)).Times(0); |
167 return m_mockFunctions.last()->bind(); | 173 return m_mockFunctions.last()->bind(); |
168 } | 174 } |
169 | 175 |
| 176 ACTION_P(SaveValueIn, captor) |
| 177 { |
| 178 *captor = toCoreString(arg0.v8Value()->ToString(arg0.getScriptState()->conte
xt()).ToLocalChecked()); |
| 179 } |
| 180 |
170 PaymentRequestMockFunctionScope::MockFunction::MockFunction(ScriptState* scriptS
tate) | 181 PaymentRequestMockFunctionScope::MockFunction::MockFunction(ScriptState* scriptS
tate) |
171 : ScriptFunction(scriptState) | 182 : ScriptFunction(scriptState) |
172 { | 183 { |
173 ON_CALL(*this, call(testing::_)).WillByDefault(testing::ReturnArg<0>()); | 184 ON_CALL(*this, call(testing::_)).WillByDefault(testing::ReturnArg<0>()); |
174 } | 185 } |
175 | 186 |
| 187 PaymentRequestMockFunctionScope::MockFunction::MockFunction(ScriptState* scriptS
tate, String* captor) |
| 188 : ScriptFunction(scriptState) |
| 189 , m_value(captor) |
| 190 { |
| 191 ON_CALL(*this, call(testing::_)).WillByDefault( |
| 192 testing::DoAll(SaveValueIn(m_value), testing::ReturnArg<0>())); |
| 193 } |
| 194 |
176 v8::Local<v8::Function> PaymentRequestMockFunctionScope::MockFunction::bind() | 195 v8::Local<v8::Function> PaymentRequestMockFunctionScope::MockFunction::bind() |
177 { | 196 { |
178 return bindToV8Function(); | 197 return bindToV8Function(); |
179 } | 198 } |
180 | 199 |
181 } // namespace blink | 200 } // namespace blink |
OLD | NEW |