| 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" | 8 #include "bindings/core/v8/TestCallback.h" |
| 9 #include "bindings/core/v8/TestInterfaceCallback.h" | 9 #include "bindings/core/v8/TestInterfaceCallback.h" |
| 10 #include "bindings/core/v8/TestReceiverObjectCallback.h" | 10 #include "bindings/core/v8/TestReceiverObjectCallback.h" |
| 11 #include "bindings/core/v8/TestSequenceCallback.h" | 11 #include "bindings/core/v8/TestSequenceCallback.h" |
| 12 #include "bindings/core/v8/V8Binding.h" | 12 #include "bindings/core/v8/V8Binding.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 TestCallback* 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, message1, message2, |
| 28 message1, message2, returnValue)) { | 28 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 TestInterfaceCallback* 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, divElement); |
| 42 divElement); | |
| 43 return; | 42 return; |
| 44 } | 43 } |
| 45 | 44 |
| 46 void CallbackFunctionTest::testReceiverObjectCallback( | 45 void CallbackFunctionTest::testReceiverObjectCallback( |
| 47 ScriptState* scriptState, | 46 ScriptState* scriptState, |
| 48 TestReceiverObjectCallback* callback, | 47 TestReceiverObjectCallback* callback, |
| 49 ExceptionState& exceptionState) { | 48 ExceptionState& exceptionState) { |
| 50 callback->call(scriptState, this, exceptionState); | 49 callback->call(scriptState, this); |
| 51 return; | 50 return; |
| 52 } | 51 } |
| 53 | 52 |
| 54 Vector<String> CallbackFunctionTest::testSequenceCallback( | 53 Vector<String> CallbackFunctionTest::testSequenceCallback( |
| 55 ScriptState* scriptState, | 54 ScriptState* scriptState, |
| 56 TestSequenceCallback* callback, | 55 TestSequenceCallback* callback, |
| 57 const Vector<int>& numbers, | 56 const Vector<int>& numbers, |
| 58 ExceptionState& exceptionState) { | 57 ExceptionState& exceptionState) { |
| 59 Vector<String> returnValue; | 58 Vector<String> returnValue; |
| 60 if (callback->call(scriptState, nullptr, exceptionState, numbers, | 59 if (callback->call(scriptState, nullptr, numbers, returnValue)) { |
| 61 returnValue)) { | |
| 62 return returnValue; | 60 return returnValue; |
| 63 } | 61 } |
| 64 return Vector<String>(); | 62 return Vector<String>(); |
| 65 } | 63 } |
| 66 | 64 |
| 67 } // namespace blink | 65 } // namespace blink |
| OLD | NEW |