| 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.h" | 5 #include "ppapi/tests/test_var.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/dev/ppb_testing_dev.h" | 11 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 13 #include "ppapi/c/pp_var.h" | 12 #include "ppapi/c/pp_var.h" |
| 14 #include "ppapi/c/ppb_var.h" | 13 #include "ppapi/c/ppb_var.h" |
| 15 #include "ppapi/cpp/instance.h" | 14 #include "ppapi/cpp/instance.h" |
| 16 #include "ppapi/cpp/module.h" | 15 #include "ppapi/cpp/module.h" |
| 17 #include "ppapi/cpp/var.h" | 16 #include "ppapi/cpp/var.h" |
| 18 #include "ppapi/tests/testing_instance.h" | 17 #include "ppapi/tests/testing_instance.h" |
| 19 | 18 |
| 20 namespace { | 19 namespace { |
| 21 | 20 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 RUN_TEST(ValidUtf8, filter); | 38 RUN_TEST(ValidUtf8, filter); |
| 40 RUN_TEST(Utf8WithEmbeddedNulls, filter); | 39 RUN_TEST(Utf8WithEmbeddedNulls, filter); |
| 41 RUN_TEST(VarToUtf8ForWrongType, filter); | 40 RUN_TEST(VarToUtf8ForWrongType, filter); |
| 42 } | 41 } |
| 43 | 42 |
| 44 std::string TestVar::TestBasicString() { | 43 std::string TestVar::TestBasicString() { |
| 45 uint32_t before_object = testing_interface_->GetLiveObjectsForInstance( | 44 uint32_t before_object = testing_interface_->GetLiveObjectsForInstance( |
| 46 instance_->pp_instance()); | 45 instance_->pp_instance()); |
| 47 { | 46 { |
| 48 const char kStr[] = "Hello"; | 47 const char kStr[] = "Hello"; |
| 49 const uint32_t kStrLen(arraysize(kStr) - 1); | 48 const uint32_t kStrLen(sizeof(kStr) - 1); |
| 50 PP_Var str = var_interface_->VarFromUtf8(pp::Module::Get()->pp_module(), | 49 PP_Var str = var_interface_->VarFromUtf8(pp::Module::Get()->pp_module(), |
| 51 kStr, kStrLen); | 50 kStr, kStrLen); |
| 52 ASSERT_EQ(PP_VARTYPE_STRING, str.type); | 51 ASSERT_EQ(PP_VARTYPE_STRING, str.type); |
| 53 | 52 |
| 54 // Reading back the string should work. | 53 // Reading back the string should work. |
| 55 uint32_t len = 0; | 54 uint32_t len = 0; |
| 56 const char* result = var_interface_->VarToUtf8(str, &len); | 55 const char* result = var_interface_->VarToUtf8(str, &len); |
| 57 ASSERT_EQ(kStrLen, len); | 56 ASSERT_EQ(kStrLen, len); |
| 58 ASSERT_EQ(0, strncmp(kStr, result, kStrLen)); | 57 ASSERT_EQ(0, strncmp(kStr, result, kStrLen)); |
| 59 | 58 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 if (length != 0) { | 244 if (length != 0) { |
| 246 return "Expected 0 on string conversion from Double var."; | 245 return "Expected 0 on string conversion from Double var."; |
| 247 } | 246 } |
| 248 if (result != NULL) { | 247 if (result != NULL) { |
| 249 return "Expected NULL on string conversion from Double var."; | 248 return "Expected NULL on string conversion from Double var."; |
| 250 } | 249 } |
| 251 | 250 |
| 252 PASS(); | 251 PASS(); |
| 253 } | 252 } |
| 254 | 253 |
| OLD | NEW |