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 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 ASSERT_EQ(PP_VARTYPE_STRING, str.type); | 99 ASSERT_EQ(PP_VARTYPE_STRING, str.type); |
100 | 100 |
101 // Reading back the string should work. | 101 // Reading back the string should work. |
102 uint32_t len = 0; | 102 uint32_t len = 0; |
103 const char* result = var_interface_->VarToUtf8(str, &len); | 103 const char* result = var_interface_->VarToUtf8(str, &len); |
104 ASSERT_EQ(kStrLen, len); | 104 ASSERT_EQ(kStrLen, len); |
105 ASSERT_EQ(0, strncmp(kStr, result, kStrLen)); | 105 ASSERT_EQ(0, strncmp(kStr, result, kStrLen)); |
106 | 106 |
107 // Destroy the string, readback should now fail. | 107 // Destroy the string, readback should now fail. |
108 var_interface_->Release(str); | 108 var_interface_->Release(str); |
109 /* | |
110 Note: this will crash in the current out-of-process implementation since | |
111 we don't do actual tracking of strings (we just convert the ID to a | |
112 pointer). | |
113 TODO(brettw) This should be fixed and this checking code re-enabled. | |
114 result = var_interface_->VarToUtf8(str, &len); | 109 result = var_interface_->VarToUtf8(str, &len); |
115 ASSERT_EQ(0, len); | 110 ASSERT_EQ(0, len); |
116 ASSERT_EQ(NULL, result); | 111 ASSERT_EQ(NULL, result); |
117 */ | |
118 } | 112 } |
119 | 113 |
120 // Make sure nothing leaked. | 114 // Make sure nothing leaked. |
121 ASSERT_TRUE(testing_interface_->GetLiveObjectsForInstance( | 115 ASSERT_TRUE(testing_interface_->GetLiveObjectsForInstance( |
122 instance_->pp_instance()) == before_object); | 116 instance_->pp_instance()) == before_object); |
123 | 117 |
124 PASS(); | 118 PASS(); |
125 } | 119 } |
126 | 120 |
127 std::string TestVarDeprecated::TestInvalidAndEmpty() { | 121 std::string TestVarDeprecated::TestInvalidAndEmpty() { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 // If the reference counting works, the object should be valid. We can test | 389 // If the reference counting works, the object should be valid. We can test |
396 // this by executing it (it was a function we defined above) and it should | 390 // this by executing it (it was a function we defined above) and it should |
397 // return "works" concatenated with the argument. | 391 // return "works" concatenated with the argument. |
398 pp::VarPrivate function(var_from_page_); | 392 pp::VarPrivate function(var_from_page_); |
399 pp::Var result = var_from_page_.Call(pp::Var(), "nice"); | 393 pp::Var result = var_from_page_.Call(pp::Var(), "nice"); |
400 ASSERT_TRUE(result.is_string()); | 394 ASSERT_TRUE(result.is_string()); |
401 ASSERT_TRUE(result.AsString() == "worksnice"); | 395 ASSERT_TRUE(result.AsString() == "worksnice"); |
402 | 396 |
403 PASS(); | 397 PASS(); |
404 } | 398 } |
OLD | NEW |