OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/V8Binding.h" | 5 #include "bindings/core/v8/V8Binding.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ToV8.h" | 8 #include "bindings/core/v8/ToV8.h" |
9 #include "bindings/core/v8/V8BindingForTesting.h" | 9 #include "bindings/core/v8/V8BindingForTesting.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 EXPECT_TRUE(v8CallBoolean( | 99 EXPECT_TRUE(v8CallBoolean( |
100 v8Array->Set(scope.context(), ToV8(&scope, 2), ToV8(&scope, 0.125)))); | 100 v8Array->Set(scope.context(), ToV8(&scope, 2), ToV8(&scope, 0.125)))); |
101 | 101 |
102 NonThrowableExceptionState exceptionState; | 102 NonThrowableExceptionState exceptionState; |
103 Vector<v8::Local<v8::Value>> v8HandleVector = | 103 Vector<v8::Local<v8::Value>> v8HandleVector = |
104 toImplArray<Vector<v8::Local<v8::Value>>>(v8Array, 0, scope.isolate(), | 104 toImplArray<Vector<v8::Local<v8::Value>>>(v8Array, 0, scope.isolate(), |
105 exceptionState); | 105 exceptionState); |
106 EXPECT_EQ(3U, v8HandleVector.size()); | 106 EXPECT_EQ(3U, v8HandleVector.size()); |
107 EXPECT_EQ("Vini, vidi, vici.", | 107 EXPECT_EQ("Vini, vidi, vici.", |
108 toUSVString(scope.isolate(), v8HandleVector[0], exceptionState)); | 108 toUSVString(scope.isolate(), v8HandleVector[0], exceptionState)); |
109 EXPECT_EQ(65535U, toUInt32(scope.isolate(), v8HandleVector[1], | 109 EXPECT_EQ(65535U, |
110 NormalConversion, exceptionState)); | 110 toUInt32(scope.isolate(), v8HandleVector[1], NormalConversion, |
| 111 exceptionState)); |
111 | 112 |
112 Vector<ScriptValue> scriptValueVector = toImplArray<Vector<ScriptValue>>( | 113 Vector<ScriptValue> scriptValueVector = toImplArray<Vector<ScriptValue>>( |
113 v8Array, 0, scope.isolate(), exceptionState); | 114 v8Array, 0, scope.isolate(), exceptionState); |
114 EXPECT_EQ(3U, scriptValueVector.size()); | 115 EXPECT_EQ(3U, scriptValueVector.size()); |
115 String reportOnZela; | 116 String reportOnZela; |
116 EXPECT_TRUE(scriptValueVector[0].toString(reportOnZela)); | 117 EXPECT_TRUE(scriptValueVector[0].toString(reportOnZela)); |
117 EXPECT_EQ("Vini, vidi, vici.", reportOnZela); | 118 EXPECT_EQ("Vini, vidi, vici.", reportOnZela); |
118 EXPECT_EQ(65535U, toUInt32(scope.isolate(), scriptValueVector[1].v8Value(), | 119 EXPECT_EQ(65535U, |
119 NormalConversion, exceptionState)); | 120 toUInt32(scope.isolate(), scriptValueVector[1].v8Value(), |
| 121 NormalConversion, exceptionState)); |
120 } | 122 } |
121 { | 123 { |
122 v8::Local<v8::Array> v8StringArray1 = v8::Array::New(scope.isolate(), 2); | 124 v8::Local<v8::Array> v8StringArray1 = v8::Array::New(scope.isolate(), 2); |
123 EXPECT_TRUE(v8CallBoolean(v8StringArray1->Set( | 125 EXPECT_TRUE(v8CallBoolean(v8StringArray1->Set( |
124 scope.context(), ToV8(&scope, 0), ToV8(&scope, "foo")))); | 126 scope.context(), ToV8(&scope, 0), ToV8(&scope, "foo")))); |
125 EXPECT_TRUE(v8CallBoolean(v8StringArray1->Set( | 127 EXPECT_TRUE(v8CallBoolean(v8StringArray1->Set( |
126 scope.context(), ToV8(&scope, 1), ToV8(&scope, "bar")))); | 128 scope.context(), ToV8(&scope, 1), ToV8(&scope, "bar")))); |
127 v8::Local<v8::Array> v8StringArray2 = v8::Array::New(scope.isolate(), 3); | 129 v8::Local<v8::Array> v8StringArray2 = v8::Array::New(scope.isolate(), 3); |
128 EXPECT_TRUE(v8CallBoolean(v8StringArray2->Set( | 130 EXPECT_TRUE(v8CallBoolean(v8StringArray2->Set( |
129 scope.context(), ToV8(&scope, 0), ToV8(&scope, "x")))); | 131 scope.context(), ToV8(&scope, 0), ToV8(&scope, "x")))); |
(...skipping 19 matching lines...) Expand all Loading... |
149 EXPECT_EQ(3U, stringVectorVector[1].size()); | 151 EXPECT_EQ(3U, stringVectorVector[1].size()); |
150 EXPECT_EQ("x", stringVectorVector[1][0]); | 152 EXPECT_EQ("x", stringVectorVector[1][0]); |
151 EXPECT_EQ("y", stringVectorVector[1][1]); | 153 EXPECT_EQ("y", stringVectorVector[1][1]); |
152 EXPECT_EQ("z", stringVectorVector[1][2]); | 154 EXPECT_EQ("z", stringVectorVector[1][2]); |
153 } | 155 } |
154 } | 156 } |
155 | 157 |
156 } // namespace | 158 } // namespace |
157 | 159 |
158 } // namespace blink | 160 } // namespace blink |
OLD | NEW |