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 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 ASSERT_EQ(kStrLen, len); | 57 ASSERT_EQ(kStrLen, len); |
58 ASSERT_EQ(0, strncmp(kStr, result, kStrLen)); | 58 ASSERT_EQ(0, strncmp(kStr, result, kStrLen)); |
59 | 59 |
60 // Destroy the string, readback should now fail. | 60 // Destroy the string, readback should now fail. |
61 var_interface_->Release(str); | 61 var_interface_->Release(str); |
62 result = var_interface_->VarToUtf8(str, &len); | 62 result = var_interface_->VarToUtf8(str, &len); |
63 ASSERT_EQ(0, len); | 63 ASSERT_EQ(0, len); |
64 ASSERT_EQ(NULL, result); | 64 ASSERT_EQ(NULL, result); |
65 } | 65 } |
66 | 66 |
| 67 // Make sure we can assign a C++ object to itself and it stays alive. |
| 68 { |
| 69 pp::Var a("test"); |
| 70 a = a; |
| 71 ASSERT_TRUE(a.AsString() == "test"); |
| 72 } |
| 73 |
67 // Make sure nothing leaked. | 74 // Make sure nothing leaked. |
68 ASSERT_TRUE(testing_interface_->GetLiveObjectsForInstance( | 75 ASSERT_TRUE(testing_interface_->GetLiveObjectsForInstance( |
69 instance_->pp_instance()) == before_object); | 76 instance_->pp_instance()) == before_object); |
70 | 77 |
71 PASS(); | 78 PASS(); |
72 } | 79 } |
73 | 80 |
74 std::string TestVar::TestInvalidAndEmpty() { | 81 std::string TestVar::TestInvalidAndEmpty() { |
75 PP_Var invalid_string; | 82 PP_Var invalid_string; |
76 invalid_string.type = PP_VARTYPE_STRING; | 83 invalid_string.type = PP_VARTYPE_STRING; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 if (length != 0) { | 245 if (length != 0) { |
239 return "Expected 0 on string conversion from Double var."; | 246 return "Expected 0 on string conversion from Double var."; |
240 } | 247 } |
241 if (result != NULL) { | 248 if (result != NULL) { |
242 return "Expected NULL on string conversion from Double var."; | 249 return "Expected NULL on string conversion from Double var."; |
243 } | 250 } |
244 | 251 |
245 PASS(); | 252 PASS(); |
246 } | 253 } |
247 | 254 |
OLD | NEW |