OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ppapi/tests/test_class.h" |
| 6 |
| 7 #include <limits> |
| 8 |
| 9 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 10 #include "ppapi/c/pp_var.h" |
| 11 #include "ppapi/c/ppb_class.h" |
| 12 #include "ppapi/c/ppb_var.h" |
| 13 #include "ppapi/cpp/instance.h" |
| 14 #include "ppapi/cpp/module.h" |
| 15 #include "ppapi/cpp/var.h" |
| 16 #include "ppapi/tests/testing_instance.h" |
| 17 |
| 18 REGISTER_TEST_CASE(Class); |
| 19 |
| 20 bool TestClass::Init() { |
| 21 class_interface_ = reinterpret_cast<const PPB_Class*>( |
| 22 pp::Module::Get()->GetBrowserInterface(PPB_CLASS_INTERFACE)); |
| 23 testing_interface_ = reinterpret_cast<const PPB_Testing_Dev*>( |
| 24 pp::Module::Get()->GetBrowserInterface(PPB_TESTING_DEV_INTERFACE)); |
| 25 if (!testing_interface_) { |
| 26 // Give a more helpful error message for the testing interface being gone |
| 27 // since that needs special enabling in Chrome. |
| 28 instance_->AppendError("This test needs the testing interface, which is " |
| 29 "not currently available. In Chrome, use --enable-pepper-testing when " |
| 30 "launching."); |
| 31 } |
| 32 return class_interface_ && testing_interface_; |
| 33 } |
| 34 |
| 35 void TestClass::RunTest() { |
| 36 RUN_TEST(ConstructEmptyObject); |
| 37 } |
| 38 |
| 39 std::string TestClass::TestConstructEmptyObject() { |
| 40 PP_ClassProperty properties[] = { { NULL } }; |
| 41 PP_Resource object_class = class_interface_->Create( |
| 42 pp::Module::Get()->pp_module(), NULL, NULL, properties); |
| 43 ASSERT_TRUE(object_class != 0); |
| 44 |
| 45 pp::Var instance(pp::Var::PassRef(), |
| 46 class_interface_->Instantiate(object_class, NULL, NULL)); |
| 47 ASSERT_TRUE(instance.is_object()); |
| 48 return std::string(); |
| 49 } |
| 50 |
OLD | NEW |