| 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" | |
| 8 #include "bindings/core/v8/TestCallback.h" | 7 #include "bindings/core/v8/TestCallback.h" |
| 9 #include "bindings/core/v8/TestInterfaceCallback.h" | 8 #include "bindings/core/v8/TestInterfaceCallback.h" |
| 10 #include "bindings/core/v8/TestReceiverObjectCallback.h" | 9 #include "bindings/core/v8/TestReceiverObjectCallback.h" |
| 11 #include "bindings/core/v8/TestSequenceCallback.h" | 10 #include "bindings/core/v8/TestSequenceCallback.h" |
| 12 #include "bindings/core/v8/V8Binding.h" | 11 #include "bindings/core/v8/V8Binding.h" |
| 13 #include "core/html/HTMLDivElement.h" | 12 #include "core/html/HTMLDivElement.h" |
| 14 | 13 |
| 15 namespace blink { | 14 namespace blink { |
| 16 | 15 |
| 17 DEFINE_TRACE(CallbackFunctionTest) {} | 16 DEFINE_TRACE(CallbackFunctionTest) {} |
| 18 | 17 |
| 19 String CallbackFunctionTest::testCallback(ScriptState* scriptState, | 18 String CallbackFunctionTest::testCallback(TestCallback* callback, |
| 20 TestCallback* callback, | |
| 21 const String& message1, | 19 const String& message1, |
| 22 const String& message2, | 20 const String& message2, |
| 23 ExceptionState& exceptionState) { | 21 ExceptionState& exceptionState) { |
| 24 ScriptWrappable* scriptWrappable; | 22 ScriptWrappable* scriptWrappable; |
| 25 String returnValue; | 23 String returnValue; |
| 26 | 24 |
| 27 if (callback->call(scriptState, scriptWrappable = nullptr, message1, message2, | 25 if (callback->call(scriptWrappable = nullptr, message1, message2, |
| 28 returnValue)) { | 26 returnValue)) { |
| 29 return String("SUCCESS: ") + returnValue; | 27 return String("SUCCESS: ") + returnValue; |
| 30 } | 28 } |
| 31 return String("Error!"); | 29 return String("Error!"); |
| 32 } | 30 } |
| 33 | 31 |
| 34 void CallbackFunctionTest::testInterfaceCallback( | 32 void CallbackFunctionTest::testInterfaceCallback( |
| 35 ScriptState* scriptState, | |
| 36 TestInterfaceCallback* callback, | 33 TestInterfaceCallback* callback, |
| 37 HTMLDivElement* divElement, | 34 HTMLDivElement* divElement, |
| 38 ExceptionState& exceptionState) { | 35 ExceptionState& exceptionState) { |
| 39 ScriptWrappable* scriptWrappable; | 36 ScriptWrappable* scriptWrappable; |
| 40 | 37 |
| 41 callback->call(scriptState, scriptWrappable = nullptr, divElement); | 38 callback->call(scriptWrappable = nullptr, divElement); |
| 42 return; | 39 return; |
| 43 } | 40 } |
| 44 | 41 |
| 45 void CallbackFunctionTest::testReceiverObjectCallback( | 42 void CallbackFunctionTest::testReceiverObjectCallback( |
| 46 ScriptState* scriptState, | |
| 47 TestReceiverObjectCallback* callback, | 43 TestReceiverObjectCallback* callback, |
| 48 ExceptionState& exceptionState) { | 44 ExceptionState& exceptionState) { |
| 49 callback->call(scriptState, this); | 45 callback->call(this); |
| 50 return; | 46 return; |
| 51 } | 47 } |
| 52 | 48 |
| 53 Vector<String> CallbackFunctionTest::testSequenceCallback( | 49 Vector<String> CallbackFunctionTest::testSequenceCallback( |
| 54 ScriptState* scriptState, | |
| 55 TestSequenceCallback* callback, | 50 TestSequenceCallback* callback, |
| 56 const Vector<int>& numbers, | 51 const Vector<int>& numbers, |
| 57 ExceptionState& exceptionState) { | 52 ExceptionState& exceptionState) { |
| 58 Vector<String> returnValue; | 53 Vector<String> returnValue; |
| 59 if (callback->call(scriptState, nullptr, numbers, returnValue)) { | 54 if (callback->call(nullptr, numbers, returnValue)) { |
| 60 return returnValue; | 55 return returnValue; |
| 61 } | 56 } |
| 62 return Vector<String>(); | 57 return Vector<String>(); |
| 63 } | 58 } |
| 64 | 59 |
| 65 } // namespace blink | 60 } // namespace blink |
| OLD | NEW |