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 String CallbackFunctionTest::testCallback(ScriptState* scriptState, | 19 String CallbackFunctionTest::testCallback(ScriptState* scriptState, |
20 V8TestCallback* callback, | 20 TestCallback* callback, |
21 const String& message1, | 21 const String& message1, |
22 const String& message2, | 22 const String& message2, |
23 ExceptionState& exceptionState) { | 23 ExceptionState& exceptionState) { |
24 ScriptWrappable* scriptWrappable; | 24 ScriptWrappable* scriptWrappable; |
25 String returnValue; | 25 String returnValue; |
26 | 26 |
27 if (callback->call(scriptState, scriptWrappable = nullptr, exceptionState, | 27 if (callback->call(scriptState, scriptWrappable = nullptr, exceptionState, |
28 message1, message2, returnValue)) { | 28 message1, message2, returnValue)) { |
29 return String("SUCCESS: ") + returnValue; | 29 return String("SUCCESS: ") + returnValue; |
30 } | 30 } |
31 return String("Error!"); | 31 return String("Error!"); |
32 } | 32 } |
33 | 33 |
34 void CallbackFunctionTest::testInterfaceCallback( | 34 void CallbackFunctionTest::testInterfaceCallback( |
35 ScriptState* scriptState, | 35 ScriptState* scriptState, |
36 V8TestInterfaceCallback* callback, | 36 TestInterfaceCallback* callback, |
37 HTMLDivElement* divElement, | 37 HTMLDivElement* divElement, |
38 ExceptionState& exceptionState) { | 38 ExceptionState& exceptionState) { |
39 ScriptWrappable* scriptWrappable; | 39 ScriptWrappable* scriptWrappable; |
40 | 40 |
41 callback->call(scriptState, scriptWrappable = nullptr, exceptionState, | 41 callback->call(scriptState, scriptWrappable = nullptr, exceptionState, |
42 divElement); | 42 divElement); |
43 return; | 43 return; |
44 } | 44 } |
45 | 45 |
46 void CallbackFunctionTest::testReceiverObjectCallback( | 46 void CallbackFunctionTest::testReceiverObjectCallback( |
47 ScriptState* scriptState, | 47 ScriptState* scriptState, |
48 V8TestReceiverObjectCallback* callback, | 48 TestReceiverObjectCallback* callback, |
49 ExceptionState& exceptionState) { | 49 ExceptionState& exceptionState) { |
50 callback->call(scriptState, this, exceptionState); | 50 callback->call(scriptState, this, exceptionState); |
51 return; | 51 return; |
52 } | 52 } |
53 | 53 |
54 Vector<String> CallbackFunctionTest::testSequenceCallback( | 54 Vector<String> CallbackFunctionTest::testSequenceCallback( |
55 ScriptState* scriptState, | 55 ScriptState* scriptState, |
56 V8TestSequenceCallback* callback, | 56 TestSequenceCallback* callback, |
57 const Vector<int>& numbers, | 57 const Vector<int>& numbers, |
58 ExceptionState& exceptionState) { | 58 ExceptionState& exceptionState) { |
59 Vector<String> returnValue; | 59 Vector<String> returnValue; |
60 if (callback->call(scriptState, nullptr, exceptionState, numbers, | 60 if (callback->call(scriptState, nullptr, exceptionState, numbers, |
61 returnValue)) { | 61 returnValue)) { |
62 return returnValue; | 62 return returnValue; |
63 } | 63 } |
64 return Vector<String>(); | 64 return Vector<String>(); |
65 } | 65 } |
66 | 66 |
67 } // namespace blink | 67 } // namespace blink |
OLD | NEW |