| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/tests/test_var_deprecated.h" | 5 #include "ppapi/tests/test_var_deprecated.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | |
| 12 #include "ppapi/c/pp_var.h" | 11 #include "ppapi/c/pp_var.h" |
| 13 #include "ppapi/c/dev/ppb_testing_dev.h" | 12 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 14 #include "ppapi/c/dev/ppb_var_deprecated.h" | 13 #include "ppapi/c/dev/ppb_var_deprecated.h" |
| 15 #include "ppapi/cpp/dev/scriptable_object_deprecated.h" | 14 #include "ppapi/cpp/dev/scriptable_object_deprecated.h" |
| 16 #include "ppapi/cpp/instance.h" | 15 #include "ppapi/cpp/instance.h" |
| 17 #include "ppapi/cpp/module.h" | 16 #include "ppapi/cpp/module.h" |
| 18 #include "ppapi/cpp/private/var_private.h" | 17 #include "ppapi/cpp/private/var_private.h" |
| 19 #include "ppapi/cpp/var.h" | 18 #include "ppapi/cpp/var.h" |
| 20 #include "ppapi/tests/testing_instance.h" | 19 #include "ppapi/tests/testing_instance.h" |
| 21 | 20 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 86 |
| 88 pp::deprecated::ScriptableObject* TestVarDeprecated::CreateTestObject() { | 87 pp::deprecated::ScriptableObject* TestVarDeprecated::CreateTestObject() { |
| 89 return new VarScriptableObject(this); | 88 return new VarScriptableObject(this); |
| 90 } | 89 } |
| 91 | 90 |
| 92 std::string TestVarDeprecated::TestBasicString() { | 91 std::string TestVarDeprecated::TestBasicString() { |
| 93 uint32_t before_object = testing_interface_->GetLiveObjectsForInstance( | 92 uint32_t before_object = testing_interface_->GetLiveObjectsForInstance( |
| 94 instance_->pp_instance()); | 93 instance_->pp_instance()); |
| 95 { | 94 { |
| 96 const char kStr[] = "Hello"; | 95 const char kStr[] = "Hello"; |
| 97 const uint32_t kStrLen(arraysize(kStr) - 1); | 96 const uint32_t kStrLen(sizeof(kStr) - 1); |
| 98 PP_Var str = var_interface_->VarFromUtf8(pp::Module::Get()->pp_module(), | 97 PP_Var str = var_interface_->VarFromUtf8(pp::Module::Get()->pp_module(), |
| 99 kStr, kStrLen); | 98 kStr, kStrLen); |
| 100 ASSERT_EQ(PP_VARTYPE_STRING, str.type); | 99 ASSERT_EQ(PP_VARTYPE_STRING, str.type); |
| 101 | 100 |
| 102 // Reading back the string should work. | 101 // Reading back the string should work. |
| 103 uint32_t len = 0; | 102 uint32_t len = 0; |
| 104 const char* result = var_interface_->VarToUtf8(str, &len); | 103 const char* result = var_interface_->VarToUtf8(str, &len); |
| 105 ASSERT_EQ(kStrLen, len); | 104 ASSERT_EQ(kStrLen, len); |
| 106 ASSERT_EQ(0, strncmp(kStr, result, kStrLen)); | 105 ASSERT_EQ(0, strncmp(kStr, result, kStrLen)); |
| 107 | 106 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 // this by executing it (it was a function we defined above) and it should | 382 // this by executing it (it was a function we defined above) and it should |
| 384 // return "works" concatenated with the argument. | 383 // return "works" concatenated with the argument. |
| 385 pp::VarPrivate function(var_from_page_); | 384 pp::VarPrivate function(var_from_page_); |
| 386 pp::Var result = var_from_page_.Call(pp::Var(), "nice"); | 385 pp::Var result = var_from_page_.Call(pp::Var(), "nice"); |
| 387 ASSERT_TRUE(result.is_string()); | 386 ASSERT_TRUE(result.is_string()); |
| 388 ASSERT_TRUE(result.AsString() == "worksnice"); | 387 ASSERT_TRUE(result.AsString() == "worksnice"); |
| 389 | 388 |
| 390 PASS(); | 389 PASS(); |
| 391 } | 390 } |
| 392 | 391 |
| OLD | NEW |