OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "third_party/WebKit/public/web/WebBindings.h" | 11 #include "third_party/WebKit/public/web/WebBindings.h" |
12 #include "webkit/renderer/cpp_variant.h" | 12 #include "webkit/renderer/cpp_variant.h" |
13 | 13 |
14 using WebKit::WebBindings; | 14 using blink::WebBindings; |
15 using webkit_glue::CppVariant; | 15 using webkit_glue::CppVariant; |
16 | 16 |
17 // Creates a std::string from an NPVariant of string type. If the NPVariant | 17 // Creates a std::string from an NPVariant of string type. If the NPVariant |
18 // is not a string, empties the std::string. | 18 // is not a string, empties the std::string. |
19 void MakeStdString(const NPVariant& np, std::string* std_string) { | 19 void MakeStdString(const NPVariant& np, std::string* std_string) { |
20 if (np.type == NPVariantType_String) { | 20 if (np.type == NPVariantType_String) { |
21 const char* chars = | 21 const char* chars = |
22 reinterpret_cast<const char*>(np.value.stringValue.UTF8Characters); | 22 reinterpret_cast<const char*>(np.value.stringValue.UTF8Characters); |
23 (*std_string).assign(chars, np.value.stringValue.UTF8Length); | 23 (*std_string).assign(chars, np.value.stringValue.UTF8Length); |
24 } else { | 24 } else { |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 EXPECT_TRUE(cpp_vector[1].isBool()); | 505 EXPECT_TRUE(cpp_vector[1].isBool()); |
506 EXPECT_EQ(true, cpp_vector[1].ToBoolean()); | 506 EXPECT_EQ(true, cpp_vector[1].ToBoolean()); |
507 | 507 |
508 EXPECT_TRUE(cpp_vector[2].isNull()); | 508 EXPECT_TRUE(cpp_vector[2].isNull()); |
509 | 509 |
510 EXPECT_TRUE(cpp_vector[3].isString()); | 510 EXPECT_TRUE(cpp_vector[3].isString()); |
511 CheckString("string", cpp_vector[3]); | 511 CheckString("string", cpp_vector[3]); |
512 | 512 |
513 WebBindings::releaseObject(obj); | 513 WebBindings::releaseObject(obj); |
514 } | 514 } |
OLD | NEW |