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 "core/testing/CallbackFunctionTest.h" | 5 #include "core/testing/CallbackFunctionTest.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
| 8 #include "bindings/core/v8/TestCallback.h" |
| 9 #include "bindings/core/v8/TestInterfaceCallback.h" |
| 10 #include "bindings/core/v8/TestReceiverObjectCallback.h" |
| 11 #include "bindings/core/v8/TestSequenceCallback.h" |
8 #include "bindings/core/v8/V8Binding.h" | 12 #include "bindings/core/v8/V8Binding.h" |
9 #include "bindings/core/v8/V8TestCallback.h" | |
10 #include "bindings/core/v8/V8TestInterfaceCallback.h" | |
11 #include "bindings/core/v8/V8TestReceiverObjectCallback.h" | |
12 #include "bindings/core/v8/V8TestSequenceCallback.h" | |
13 #include "core/html/HTMLDivElement.h" | 13 #include "core/html/HTMLDivElement.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 DEFINE_TRACE(CallbackFunctionTest) | 17 DEFINE_TRACE(CallbackFunctionTest) |
18 { | 18 { |
19 } | 19 } |
20 | 20 |
21 String CallbackFunctionTest::testCallback(ScriptState* scriptState, V8TestCallba
ck* callback, const String& message1, const String& message2, ExceptionState& ex
ceptionState) | 21 String CallbackFunctionTest::testCallback(ScriptState* scriptState, TestCallback
* callback, const String& message1, const String& message2, ExceptionState& exce
ptionState) |
22 { | 22 { |
23 ScriptWrappable* scriptWrappable; | 23 ScriptWrappable* scriptWrappable; |
24 String returnValue; | 24 String returnValue; |
25 | 25 |
26 if (callback->call(scriptState, scriptWrappable = nullptr, exceptionState, m
essage1, message2, returnValue)) { | 26 if (callback->call(scriptState, scriptWrappable = nullptr, exceptionState, m
essage1, message2, returnValue)) { |
27 return String("SUCCESS: ") + returnValue; | 27 return String("SUCCESS: ") + returnValue; |
28 } | 28 } |
29 return String("Error!"); | 29 return String("Error!"); |
30 } | 30 } |
31 | 31 |
32 void CallbackFunctionTest::testInterfaceCallback(ScriptState* scriptState, V8Tes
tInterfaceCallback* callback, HTMLDivElement* divElement, ExceptionState& except
ionState) | 32 void CallbackFunctionTest::testInterfaceCallback(ScriptState* scriptState, TestI
nterfaceCallback* callback, HTMLDivElement* divElement, ExceptionState& exceptio
nState) |
33 { | 33 { |
34 ScriptWrappable* scriptWrappable; | 34 ScriptWrappable* scriptWrappable; |
35 | 35 |
36 callback->call(scriptState, scriptWrappable = nullptr, exceptionState, divEl
ement); | 36 callback->call(scriptState, scriptWrappable = nullptr, exceptionState, divEl
ement); |
37 return; | 37 return; |
38 } | 38 } |
39 | 39 |
40 void CallbackFunctionTest::testReceiverObjectCallback(ScriptState* scriptState,
V8TestReceiverObjectCallback* callback, ExceptionState& exceptionState) | 40 void CallbackFunctionTest::testReceiverObjectCallback(ScriptState* scriptState,
TestReceiverObjectCallback* callback, ExceptionState& exceptionState) |
41 { | 41 { |
42 callback->call(scriptState, this, exceptionState); | 42 callback->call(scriptState, this, exceptionState); |
43 return; | 43 return; |
44 } | 44 } |
45 | 45 |
46 Vector<String> CallbackFunctionTest::testSequenceCallback(ScriptState* scriptSta
te, V8TestSequenceCallback* callback, const Vector<int>& numbers, ExceptionState
& exceptionState) | 46 Vector<String> CallbackFunctionTest::testSequenceCallback(ScriptState* scriptSta
te, TestSequenceCallback* callback, const Vector<int>& numbers, ExceptionState&
exceptionState) |
47 { | 47 { |
48 Vector<String> returnValue; | 48 Vector<String> returnValue; |
49 if (callback->call(scriptState, nullptr, exceptionState, numbers, returnValu
e)) { | 49 if (callback->call(scriptState, nullptr, exceptionState, numbers, returnValu
e)) { |
50 return returnValue; | 50 return returnValue; |
51 } | 51 } |
52 return Vector<String>(); | 52 return Vector<String>(); |
53 } | 53 } |
54 | 54 |
55 } // namespace blink | 55 } // namespace blink |
OLD | NEW |