Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: content/renderer/cpp_variant_unittest.cc

Issue 25378002: Move the rest of source files from webkit/renderer to content/renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/renderer/cpp_variant.h"
6
5 #include <vector> 7 #include <vector>
6 8
7 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
8 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/WebKit/public/web/WebBindings.h" 13 #include "third_party/WebKit/public/web/WebBindings.h"
12 #include "webkit/renderer/cpp_variant.h"
13 14
14 using WebKit::WebBindings; 15 using WebKit::WebBindings;
15 using webkit_glue::CppVariant; 16
17 namespace content {
16 18
17 // Creates a std::string from an NPVariant of string type. If the NPVariant 19 // Creates a std::string from an NPVariant of string type. If the NPVariant
18 // is not a string, empties the std::string. 20 // is not a string, empties the std::string.
19 void MakeStdString(const NPVariant& np, std::string* std_string) { 21 void MakeStdString(const NPVariant& np, std::string* std_string) {
20 if (np.type == NPVariantType_String) { 22 if (np.type == NPVariantType_String) {
21 const char* chars = 23 const char* chars =
22 reinterpret_cast<const char*>(np.value.stringValue.UTF8Characters); 24 reinterpret_cast<const char*>(np.value.stringValue.UTF8Characters);
23 (*std_string).assign(chars, np.value.stringValue.UTF8Length); 25 (*std_string).assign(chars, np.value.stringValue.UTF8Length);
24 } else { 26 } else {
25 (*std_string).clear(); 27 (*std_string).clear();
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 EXPECT_TRUE(cpp_vector[1].isBool()); 507 EXPECT_TRUE(cpp_vector[1].isBool());
506 EXPECT_EQ(true, cpp_vector[1].ToBoolean()); 508 EXPECT_EQ(true, cpp_vector[1].ToBoolean());
507 509
508 EXPECT_TRUE(cpp_vector[2].isNull()); 510 EXPECT_TRUE(cpp_vector[2].isNull());
509 511
510 EXPECT_TRUE(cpp_vector[3].isString()); 512 EXPECT_TRUE(cpp_vector[3].isString());
511 CheckString("string", cpp_vector[3]); 513 CheckString("string", cpp_vector[3]);
512 514
513 WebBindings::releaseObject(obj); 515 WebBindings::releaseObject(obj);
514 } 516 }
517
518 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698