| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 "webkit/plugins/ppapi/ppapi_unittest.h" | 5 #include "webkit/plugins/ppapi/ppapi_unittest.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_var.h" | 7 #include "ppapi/c/pp_var.h" |
| 8 #include "ppapi/c/ppp_instance.h" | 8 #include "ppapi/c/ppp_instance.h" |
| 9 #include "webkit/plugins/ppapi/mock_plugin_delegate.h" | 9 #include "webkit/plugins/ppapi/mock_plugin_delegate.h" |
| 10 #include "webkit/plugins/ppapi/plugin_module.h" | 10 #include "webkit/plugins/ppapi/plugin_module.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, | 53 PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, |
| 54 PP_Resource pp_url_loader) { | 54 PP_Resource pp_url_loader) { |
| 55 return PP_FALSE; | 55 return PP_FALSE; |
| 56 } | 56 } |
| 57 | 57 |
| 58 PP_Var Instance_GetInstanceObject(PP_Instance pp_instance) { | 58 PP_Var Instance_GetInstanceObject(PP_Instance pp_instance) { |
| 59 return PP_MakeUndefined(); | 59 return PP_MakeUndefined(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void Instance_HandleMessage(PP_Instance pp_instance, PP_Var message) { |
| 63 return; |
| 64 } |
| 65 |
| 62 static PPP_Instance mock_instance_interface = { | 66 static PPP_Instance mock_instance_interface = { |
| 63 &Instance_DidCreate, | 67 &Instance_DidCreate, |
| 64 &Instance_DidDestroy, | 68 &Instance_DidDestroy, |
| 65 &Instance_DidChangeView, | 69 &Instance_DidChangeView, |
| 66 &Instance_DidChangeFocus, | 70 &Instance_DidChangeFocus, |
| 67 &Instance_HandleInputEvent, | 71 &Instance_HandleInputEvent, |
| 68 &Instance_HandleDocumentLoad, | 72 &Instance_HandleDocumentLoad, |
| 69 &Instance_GetInstanceObject | 73 &Instance_GetInstanceObject, |
| 74 &Instance_HandleMessage |
| 70 }; | 75 }; |
| 71 | 76 |
| 72 } // namespace | 77 } // namespace |
| 73 | 78 |
| 74 // PpapiUnittest -------------------------------------------------------------- | 79 // PpapiUnittest -------------------------------------------------------------- |
| 75 | 80 |
| 76 PpapiUnittest::PpapiUnittest() { | 81 PpapiUnittest::PpapiUnittest() { |
| 77 DCHECK(!current_unittest); | 82 DCHECK(!current_unittest); |
| 78 current_unittest = this; | 83 current_unittest = this; |
| 79 } | 84 } |
| 80 | 85 |
| 81 PpapiUnittest::~PpapiUnittest() { | 86 PpapiUnittest::~PpapiUnittest() { |
| 82 DCHECK(current_unittest == this); | 87 DCHECK(current_unittest == this); |
| 83 current_unittest = NULL; | 88 current_unittest = NULL; |
| 84 } | 89 } |
| 85 | 90 |
| 86 void PpapiUnittest::SetUp() { | 91 void PpapiUnittest::SetUp() { |
| 87 delegate_.reset(new MockPluginDelegate); | 92 delegate_.reset(new MockPluginDelegate); |
| 88 | 93 |
| 89 // Initialize the mock module. | 94 // Initialize the mock module. |
| 90 module_ = new PluginModule("Mock plugin", this); | 95 module_ = new PluginModule("Mock plugin", this); |
| 91 PluginModule::EntryPoints entry_points; | 96 PluginModule::EntryPoints entry_points; |
| 92 entry_points.get_interface = &MockGetInterface; | 97 entry_points.get_interface = &MockGetInterface; |
| 93 entry_points.initialize_module = &MockInitializeModule; | 98 entry_points.initialize_module = &MockInitializeModule; |
| 94 ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points)); | 99 ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points)); |
| 95 | 100 |
| 96 // Initialize the mock instance. | 101 // Initialize the mock instance. |
| 97 instance_ = new PluginInstance(delegate_.get(), module(), | 102 instance_ = new PluginInstance(delegate_.get(), module(), |
| 98 static_cast<const PPP_Instance*>( | 103 static_cast<const PPP_Instance*>( |
| 99 GetMockInterface(PPP_INSTANCE_INTERFACE))); | 104 GetMockInterface(PPP_INSTANCE_INTERFACE)), |
| 105 PluginInstance::PLUGIN_OWNS_INTERFACE); |
| 100 } | 106 } |
| 101 | 107 |
| 102 void PpapiUnittest::TearDown() { | 108 void PpapiUnittest::TearDown() { |
| 103 instance_ = NULL; | 109 instance_ = NULL; |
| 104 module_ = NULL; | 110 module_ = NULL; |
| 105 } | 111 } |
| 106 | 112 |
| 107 const void* PpapiUnittest::GetMockInterface(const char* interface_name) const { | 113 const void* PpapiUnittest::GetMockInterface(const char* interface_name) const { |
| 108 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) | 114 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) |
| 109 return &mock_instance_interface; | 115 return &mock_instance_interface; |
| 110 return NULL; | 116 return NULL; |
| 111 } | 117 } |
| 112 | 118 |
| 113 void PpapiUnittest::ShutdownModule() { | 119 void PpapiUnittest::ShutdownModule() { |
| 114 DCHECK(instance_->HasOneRef()); | 120 DCHECK(instance_->HasOneRef()); |
| 115 instance_ = NULL; | 121 instance_ = NULL; |
| 116 DCHECK(module_->HasOneRef()); | 122 DCHECK(module_->HasOneRef()); |
| 117 module_ = NULL; | 123 module_ = NULL; |
| 118 } | 124 } |
| 119 | 125 |
| 120 void PpapiUnittest::PluginModuleDead(PluginModule* /* dead_module */) { | 126 void PpapiUnittest::PluginModuleDead(PluginModule* /* dead_module */) { |
| 121 // Nothing needed (this is necessary to make the module compile). | 127 // Nothing needed (this is necessary to make the module compile). |
| 122 } | 128 } |
| 123 | 129 |
| 124 } // namespace ppapi | 130 } // namespace ppapi |
| 125 } // namespace webkit | 131 } // namespace webkit |
| OLD | NEW |