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 "config.h" | 5 #include "config.h" |
6 #include "bindings/core/v8/ToV8.h" | 6 #include "bindings/core/v8/ToV8.h" |
7 | 7 |
8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
9 #include "core/testing/GarbageCollectedScriptWrappable.h" | 9 #include "core/testing/GarbageCollectedScriptWrappable.h" |
10 #include "core/testing/RefCountedScriptWrappable.h" | 10 #include "core/testing/RefCountedScriptWrappable.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 doubleVector.append(4.2); | 220 doubleVector.append(4.2); |
221 TEST_TOV8("2.3,4.2", doubleVector); | 221 TEST_TOV8("2.3,4.2", doubleVector); |
222 | 222 |
223 Vector<bool> boolVector; | 223 Vector<bool> boolVector; |
224 boolVector.append(true); | 224 boolVector.append(true); |
225 boolVector.append(true); | 225 boolVector.append(true); |
226 boolVector.append(false); | 226 boolVector.append(false); |
227 TEST_TOV8("true,true,false", boolVector); | 227 TEST_TOV8("true,true,false", boolVector); |
228 } | 228 } |
229 | 229 |
230 TEST_F(ToV8Test, dictionaryVector) | |
231 { | |
232 Vector<std::pair<String, v8::Handle<v8::Value>>> dictionary; | |
Yuki
2015/03/05 03:31:03
Optional: You can test with Vector<pair<String, in
| |
233 dictionary.append(std::make_pair("one", v8::Number::New(m_scope.isolate(), 1 ))); | |
234 dictionary.append(std::make_pair("two", v8::Number::New(m_scope.isolate(), 2 ))); | |
235 TEST_TOV8("[object Object]", dictionary); | |
236 v8::Handle<v8::Object> result = toV8(dictionary, m_scope.scriptState()->cont ext()->Global(), m_scope.isolate())->ToObject(); | |
237 EXPECT_EQ(1, result->Get(v8String(m_scope.isolate(), "one"))->NumberValue()) ; | |
238 EXPECT_EQ(2, result->Get(v8String(m_scope.isolate(), "two"))->NumberValue()) ; | |
239 } | |
240 | |
230 TEST_F(ToV8Test, heapVector) | 241 TEST_F(ToV8Test, heapVector) |
231 { | 242 { |
232 HeapVector<Member<GarbageCollectedScriptWrappable>> v; | 243 HeapVector<Member<GarbageCollectedScriptWrappable>> v; |
233 v.append(new GarbageCollectedScriptWrappable("hoge")); | 244 v.append(new GarbageCollectedScriptWrappable("hoge")); |
234 v.append(new GarbageCollectedScriptWrappable("fuga")); | 245 v.append(new GarbageCollectedScriptWrappable("fuga")); |
235 v.append(nullptr); | 246 v.append(nullptr); |
236 | 247 |
237 TEST_TOV8("hoge,fuga,", v); | 248 TEST_TOV8("hoge,fuga,", v); |
238 } | 249 } |
239 | 250 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 HeapVector<bool> boolVector; | 296 HeapVector<bool> boolVector; |
286 boolVector.append(true); | 297 boolVector.append(true); |
287 boolVector.append(true); | 298 boolVector.append(true); |
288 boolVector.append(false); | 299 boolVector.append(false); |
289 TEST_TOV8("true,true,false", boolVector); | 300 TEST_TOV8("true,true,false", boolVector); |
290 } | 301 } |
291 | 302 |
292 } // namespace | 303 } // namespace |
293 | 304 |
294 } // namespace blink | 305 } // namespace blink |
OLD | NEW |