| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/ppapi_unittest.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "content/renderer/pepper/gfx_conversion.h" |
| 9 #include "content/renderer/pepper/host_globals.h" |
| 10 #include "content/renderer/pepper/mock_plugin_delegate.h" |
| 11 #include "content/renderer/pepper/plugin_module.h" |
| 12 #include "content/renderer/pepper/ppapi_interface_factory.h" |
| 13 #include "content/renderer/pepper/ppapi_plugin_instance_impl.h" |
| 8 #include "ppapi/c/pp_var.h" | 14 #include "ppapi/c/pp_var.h" |
| 9 #include "ppapi/c/ppp_instance.h" | 15 #include "ppapi/c/ppp_instance.h" |
| 10 #include "ppapi/shared_impl/ppapi_globals.h" | 16 #include "ppapi/shared_impl/ppapi_globals.h" |
| 11 #include "ppapi/shared_impl/ppapi_permissions.h" | 17 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 12 #include "webkit/plugins/ppapi/gfx_conversion.h" | |
| 13 #include "webkit/plugins/ppapi/host_globals.h" | |
| 14 #include "webkit/plugins/ppapi/mock_plugin_delegate.h" | |
| 15 #include "webkit/plugins/ppapi/plugin_module.h" | |
| 16 #include "webkit/plugins/ppapi/ppapi_interface_factory.h" | |
| 17 #include "webkit/plugins/ppapi/ppapi_plugin_instance_impl.h" | |
| 18 | 18 |
| 19 namespace webkit { | 19 namespace webkit { |
| 20 namespace ppapi { | 20 namespace ppapi { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 PpapiUnittest* current_unittest = NULL; | 24 PpapiUnittest* current_unittest = NULL; |
| 25 | 25 |
| 26 const void* MockGetInterface(const char* interface_name) { | 26 const void* MockGetInterface(const char* interface_name) { |
| 27 return current_unittest->GetMockInterface(interface_name); | 27 return current_unittest->GetMockInterface(interface_name); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 PpapiUnittest::~PpapiUnittest() { | 74 PpapiUnittest::~PpapiUnittest() { |
| 75 DCHECK(current_unittest == this); | 75 DCHECK(current_unittest == this); |
| 76 current_unittest = NULL; | 76 current_unittest = NULL; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void PpapiUnittest::SetUp() { | 79 void PpapiUnittest::SetUp() { |
| 80 message_loop_.reset(new base::MessageLoop()); | 80 message_loop_.reset(new base::MessageLoop()); |
| 81 delegate_.reset(NewPluginDelegate()); | 81 delegate_.reset(NewPluginDelegate()); |
| 82 | 82 |
| 83 // Initialize the mock module. | 83 // Initialize the mock module. |
| 84 module_ = new PluginModule("Mock plugin", base::FilePath(), this, | 84 module_ = new PluginModule("Mock plugin", base::FilePath(), |
| 85 ::ppapi::PpapiPermissions()); | 85 ::ppapi::PpapiPermissions()); |
| 86 ::ppapi::PpapiGlobals::Get()->ResetMainThreadMessageLoopForTesting(); | 86 ::ppapi::PpapiGlobals::Get()->ResetMainThreadMessageLoopForTesting(); |
| 87 PluginModule::EntryPoints entry_points; | 87 content::PepperPluginInfo::EntryPoints entry_points; |
| 88 entry_points.get_interface = &MockGetInterface; | 88 entry_points.get_interface = &MockGetInterface; |
| 89 entry_points.initialize_module = &MockInitializeModule; | 89 entry_points.initialize_module = &MockInitializeModule; |
| 90 ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points)); | 90 ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points)); |
| 91 | 91 |
| 92 // Initialize the mock instance. | 92 // Initialize the mock instance. |
| 93 instance_ = PluginInstanceImpl::Create( | 93 instance_ = PluginInstanceImpl::Create( |
| 94 delegate_.get(), NULL, module(), NULL, GURL()); | 94 delegate_.get(), NULL, module(), NULL, GURL()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void PpapiUnittest::TearDown() { | 97 void PpapiUnittest::TearDown() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 116 instance_ = NULL; | 116 instance_ = NULL; |
| 117 DCHECK(module_->HasOneRef()); | 117 DCHECK(module_->HasOneRef()); |
| 118 module_ = NULL; | 118 module_ = NULL; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void PpapiUnittest::SetViewSize(int width, int height) const { | 121 void PpapiUnittest::SetViewSize(int width, int height) const { |
| 122 instance_->view_data_.rect = PP_FromGfxRect(gfx::Rect(0, 0, width, height)); | 122 instance_->view_data_.rect = PP_FromGfxRect(gfx::Rect(0, 0, width, height)); |
| 123 instance_->view_data_.clip_rect = instance_->view_data_.rect; | 123 instance_->view_data_.clip_rect = instance_->view_data_.rect; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void PpapiUnittest::PluginModuleDead(PluginModule* /* dead_module */) { | |
| 127 // Nothing needed (this is necessary to make the module compile). | |
| 128 } | |
| 129 | |
| 130 // Tests whether custom PPAPI interface factories are called when PPAPI | 126 // Tests whether custom PPAPI interface factories are called when PPAPI |
| 131 // interfaces are requested. | 127 // interfaces are requested. |
| 132 class PpapiCustomInterfaceFactoryTest : public PpapiUnittest { | 128 class PpapiCustomInterfaceFactoryTest : public PpapiUnittest { |
| 133 public: | 129 public: |
| 134 PpapiCustomInterfaceFactoryTest() {} | 130 PpapiCustomInterfaceFactoryTest() {} |
| 135 virtual ~PpapiCustomInterfaceFactoryTest() {} | 131 virtual ~PpapiCustomInterfaceFactoryTest() {} |
| 136 | 132 |
| 137 bool result() { | 133 bool result() { |
| 138 return result_; | 134 return result_; |
| 139 } | 135 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 164 reset_result(); | 160 reset_result(); |
| 165 PpapiInterfaceFactoryManager::GetInstance()->UnregisterFactory( | 161 PpapiInterfaceFactoryManager::GetInstance()->UnregisterFactory( |
| 166 PpapiCustomInterfaceFactoryTest::InterfaceFactory); | 162 PpapiCustomInterfaceFactoryTest::InterfaceFactory); |
| 167 | 163 |
| 168 (*PluginModule::GetLocalGetInterfaceFunc())("DummyInterface"); | 164 (*PluginModule::GetLocalGetInterfaceFunc())("DummyInterface"); |
| 169 EXPECT_FALSE(result()); | 165 EXPECT_FALSE(result()); |
| 170 } | 166 } |
| 171 | 167 |
| 172 } // namespace ppapi | 168 } // namespace ppapi |
| 173 } // namespace webkit | 169 } // namespace webkit |
| OLD | NEW |