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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 const std::vector<pp::Var>& args, | 50 const std::vector<pp::Var>& args, |
51 pp::Var* exception) { | 51 pp::Var* exception) { |
52 if (!method_name.is_string()) | 52 if (!method_name.is_string()) |
53 return false; | 53 return false; |
54 std::string name = method_name.AsString(); | 54 std::string name = method_name.AsString(); |
55 | 55 |
56 if (name == kSetValueFunction) { | 56 if (name == kSetValueFunction) { |
57 if (args.size() != 1) | 57 if (args.size() != 1) |
58 *exception = pp::Var("Bad argument to SetValue(<value>)"); | 58 *exception = pp::Var("Bad argument to SetValue(<value>)"); |
59 else | 59 else |
60 test_var_deprecated_->set_var_from_page(args[0]); | 60 test_var_deprecated_->set_var_from_page(pp::VarPrivate(args[0])); |
61 } | 61 } |
62 | 62 |
63 return pp::Var(); | 63 return pp::Var(); |
64 } | 64 } |
65 | 65 |
66 } // namespace | 66 } // namespace |
67 | 67 |
68 REGISTER_TEST_CASE(VarDeprecated); | 68 REGISTER_TEST_CASE(VarDeprecated); |
69 | 69 |
70 bool TestVarDeprecated::Init() { | 70 bool TestVarDeprecated::Init() { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 return "Expected NULL on string conversion from Double var."; | 290 return "Expected NULL on string conversion from Double var."; |
291 } | 291 } |
292 | 292 |
293 PASS(); | 293 PASS(); |
294 } | 294 } |
295 | 295 |
296 std::string TestVarDeprecated::TestHasPropertyAndMethod() { | 296 std::string TestVarDeprecated::TestHasPropertyAndMethod() { |
297 uint32_t before_objects = testing_interface_->GetLiveObjectsForInstance( | 297 uint32_t before_objects = testing_interface_->GetLiveObjectsForInstance( |
298 instance_->pp_instance()); | 298 instance_->pp_instance()); |
299 { | 299 { |
300 pp::Var window = instance_->GetWindowObject(); | 300 pp::VarPrivate window = instance_->GetWindowObject(); |
301 ASSERT_TRUE(window.is_object()); | 301 ASSERT_TRUE(window.is_object()); |
302 | 302 |
303 // Regular property. | 303 // Regular property. |
304 pp::Var exception; | 304 pp::Var exception; |
305 ASSERT_TRUE(window.HasProperty("scrollX", &exception)); | 305 ASSERT_TRUE(window.HasProperty("scrollX", &exception)); |
306 ASSERT_TRUE(exception.is_undefined()); | 306 ASSERT_TRUE(exception.is_undefined()); |
307 ASSERT_FALSE(window.HasMethod("scrollX", &exception)); | 307 ASSERT_FALSE(window.HasMethod("scrollX", &exception)); |
308 ASSERT_TRUE(exception.is_undefined()); | 308 ASSERT_TRUE(exception.is_undefined()); |
309 | 309 |
310 // Regular method (also counts as HasProperty). | 310 // Regular method (also counts as HasProperty). |
(...skipping 12 matching lines...) Expand all Loading... |
323 ASSERT_FALSE(window.HasProperty(3.14159, &exception)); | 323 ASSERT_FALSE(window.HasProperty(3.14159, &exception)); |
324 ASSERT_FALSE(exception.is_undefined()); | 324 ASSERT_FALSE(exception.is_undefined()); |
325 exception = pp::Var(); | 325 exception = pp::Var(); |
326 | 326 |
327 exception = pp::Var(); | 327 exception = pp::Var(); |
328 ASSERT_FALSE(window.HasMethod(3.14159, &exception)); | 328 ASSERT_FALSE(window.HasMethod(3.14159, &exception)); |
329 ASSERT_FALSE(exception.is_undefined()); | 329 ASSERT_FALSE(exception.is_undefined()); |
330 | 330 |
331 // Try to use something not an object. | 331 // Try to use something not an object. |
332 exception = pp::Var(); | 332 exception = pp::Var(); |
333 pp::Var string_object("asdf"); | 333 pp::VarPrivate string_object("asdf"); |
334 ASSERT_FALSE(string_object.HasProperty("find", &exception)); | 334 ASSERT_FALSE(string_object.HasProperty("find", &exception)); |
335 ASSERT_FALSE(exception.is_undefined()); | 335 ASSERT_FALSE(exception.is_undefined()); |
336 exception = pp::Var(); | 336 exception = pp::Var(); |
337 ASSERT_FALSE(string_object.HasMethod("find", &exception)); | 337 ASSERT_FALSE(string_object.HasMethod("find", &exception)); |
338 ASSERT_FALSE(exception.is_undefined()); | 338 ASSERT_FALSE(exception.is_undefined()); |
339 | 339 |
340 // Try to use an invalid object (need to use the C API). | 340 // Try to use an invalid object (need to use the C API). |
341 PP_Var invalid_object; | 341 PP_Var invalid_object; |
342 invalid_object.type = PP_VARTYPE_OBJECT; | 342 invalid_object.type = PP_VARTYPE_OBJECT; |
343 invalid_object.value.as_id = static_cast<int64_t>(-1234567); | 343 invalid_object.value.as_id = static_cast<int64_t>(-1234567); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 // If the reference counting works, the object should be valid. We can test | 390 // If the reference counting works, the object should be valid. We can test |
391 // this by executing it (it was a function we defined above) and it should | 391 // this by executing it (it was a function we defined above) and it should |
392 // return "works" concatenated with the argument. | 392 // return "works" concatenated with the argument. |
393 pp::VarPrivate function(var_from_page_); | 393 pp::VarPrivate function(var_from_page_); |
394 pp::Var result = var_from_page_.Call(pp::Var(), "nice"); | 394 pp::Var result = var_from_page_.Call(pp::Var(), "nice"); |
395 ASSERT_TRUE(result.is_string()); | 395 ASSERT_TRUE(result.is_string()); |
396 ASSERT_TRUE(result.AsString() == "worksnice"); | 396 ASSERT_TRUE(result.AsString() == "worksnice"); |
397 | 397 |
398 PASS(); | 398 PASS(); |
399 } | 399 } |
| 400 |
OLD | NEW |