| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "bindings/core/v8/NativeValueTraitsImpl.h" | 5 #include "bindings/core/v8/NativeValueTraitsImpl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/IDLTypes.h" | 9 #include "bindings/core/v8/IDLTypes.h" |
| 10 #include "bindings/core/v8/TestSequenceCallback.h" | 10 #include "bindings/core/v8/TestSequenceCallback.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 } | 24 } |
| 25 | 25 |
| 26 TEST(NativeValueTraitsImplTest, IDLInterface) { | 26 TEST(NativeValueTraitsImplTest, IDLInterface) { |
| 27 V8TestingScope scope; | 27 V8TestingScope scope; |
| 28 { | 28 { |
| 29 DummyExceptionStateForTesting exception_state; | 29 DummyExceptionStateForTesting exception_state; |
| 30 Internals* internals = NativeValueTraits<Internals>::NativeValue( | 30 Internals* internals = NativeValueTraits<Internals>::NativeValue( |
| 31 scope.GetIsolate(), v8::Number::New(scope.GetIsolate(), 42), | 31 scope.GetIsolate(), v8::Number::New(scope.GetIsolate(), 42), |
| 32 exception_state); | 32 exception_state); |
| 33 EXPECT_TRUE(exception_state.HadException()); | 33 EXPECT_TRUE(exception_state.HadException()); |
| 34 EXPECT_EQ("Unable to convert value to Internals.", | 34 EXPECT_EQ("Failed to convert value to 'Internals'.", |
| 35 exception_state.Message()); | 35 exception_state.Message()); |
| 36 EXPECT_EQ(nullptr, internals); | 36 EXPECT_EQ(nullptr, internals); |
| 37 } | 37 } |
| 38 { | 38 { |
| 39 DummyExceptionStateForTesting exception_state; | 39 DummyExceptionStateForTesting exception_state; |
| 40 TestSequenceCallback* callback_function = | 40 TestSequenceCallback* callback_function = |
| 41 NativeValueTraits<TestSequenceCallback>::NativeValue( | 41 NativeValueTraits<TestSequenceCallback>::NativeValue( |
| 42 scope.GetIsolate(), v8::Undefined(scope.GetIsolate()), | 42 scope.GetIsolate(), v8::Undefined(scope.GetIsolate()), |
| 43 exception_state); | 43 exception_state); |
| 44 EXPECT_TRUE(exception_state.HadException()); | 44 EXPECT_TRUE(exception_state.HadException()); |
| 45 EXPECT_EQ("Unable to convert value to TestSequenceCallback.", | 45 EXPECT_EQ("Failed to convert value to 'TestSequenceCallback'.", |
| 46 exception_state.Message()); | 46 exception_state.Message()); |
| 47 EXPECT_EQ(nullptr, callback_function); | 47 EXPECT_EQ(nullptr, callback_function); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 void ThrowException(v8::Local<v8::Name>, | 51 void ThrowException(v8::Local<v8::Name>, |
| 52 const v8::PropertyCallbackInfo<v8::Value>& info) { | 52 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 53 info.GetIsolate()->ThrowException(V8String(info.GetIsolate(), "bogus!")); | 53 info.GetIsolate()->ThrowException(V8String(info.GetIsolate(), "bogus!")); |
| 54 } | 54 } |
| 55 | 55 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 EXPECT_EQ(1U, record.size()); | 269 EXPECT_EQ(1U, record.size()); |
| 270 EXPECT_EQ("foo", record[0].first); | 270 EXPECT_EQ("foo", record[0].first); |
| 271 EXPECT_EQ("Hello, World!", record[0].second[0]); | 271 EXPECT_EQ("Hello, World!", record[0].second[0]); |
| 272 EXPECT_EQ("Hi, Mom!", record[0].second[1]); | 272 EXPECT_EQ("Hi, Mom!", record[0].second[1]); |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 | 275 |
| 276 } // namespace | 276 } // namespace |
| 277 | 277 |
| 278 } // namespace blink | 278 } // namespace blink |
| OLD | NEW |