| 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 "content/test/ppapi_unittest.h" | 5 #include "content/test/ppapi_unittest.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/renderer/pepper/gfx_conversion.h" | 10 #include "content/renderer/pepper/gfx_conversion.h" |
| 11 #include "content/renderer/pepper/host_globals.h" | 11 #include "content/renderer/pepper/host_globals.h" |
| 12 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 12 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 13 #include "content/renderer/pepper/plugin_module.h" | 13 #include "content/renderer/pepper/plugin_module.h" |
| 14 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 14 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
| 15 #include "ppapi/c/pp_var.h" | 16 #include "ppapi/c/pp_var.h" |
| 16 #include "ppapi/c/ppp_instance.h" | 17 #include "ppapi/c/ppp_instance.h" |
| 17 #include "ppapi/shared_impl/ppapi_globals.h" | 18 #include "ppapi/shared_impl/ppapi_globals.h" |
| 18 #include "ppapi/shared_impl/ppapi_permissions.h" | 19 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 74 |
| 74 PpapiUnittest::~PpapiUnittest() { | 75 PpapiUnittest::~PpapiUnittest() { |
| 75 DCHECK(current_unittest == this); | 76 DCHECK(current_unittest == this); |
| 76 current_unittest = NULL; | 77 current_unittest = NULL; |
| 77 } | 78 } |
| 78 | 79 |
| 79 void PpapiUnittest::SetUp() { | 80 void PpapiUnittest::SetUp() { |
| 80 message_loop_.reset(new base::MessageLoop()); | 81 message_loop_.reset(new base::MessageLoop()); |
| 81 | 82 |
| 82 // Initialize the mock module. | 83 // Initialize the mock module. |
| 84 ppapi::PpapiPermissions perms; |
| 83 module_ = new PluginModule("Mock plugin", "1.0", base::FilePath(), | 85 module_ = new PluginModule("Mock plugin", "1.0", base::FilePath(), |
| 84 ppapi::PpapiPermissions()); | 86 perms); |
| 85 ppapi::PpapiGlobals::Get()->ResetMainThreadMessageLoopForTesting(); | 87 ppapi::PpapiGlobals::Get()->ResetMainThreadMessageLoopForTesting(); |
| 86 PepperPluginInfo::EntryPoints entry_points; | 88 PepperPluginInfo::EntryPoints entry_points; |
| 87 entry_points.get_interface = &MockGetInterface; | 89 entry_points.get_interface = &MockGetInterface; |
| 88 entry_points.initialize_module = &MockInitializeModule; | 90 entry_points.initialize_module = &MockInitializeModule; |
| 89 ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points)); | 91 ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points)); |
| 90 | 92 |
| 93 // Initialize renderer ppapi host. |
| 94 CHECK(RendererPpapiHostImpl::CreateOnModuleForInProcess(module(), perms)); |
| 95 CHECK(module_->renderer_ppapi_host()); |
| 96 |
| 91 // Initialize the mock instance. | 97 // Initialize the mock instance. |
| 92 instance_ = PepperPluginInstanceImpl::Create(NULL, module(), NULL, GURL()); | 98 instance_ = PepperPluginInstanceImpl::Create(NULL, module(), NULL, GURL()); |
| 93 } | 99 } |
| 94 | 100 |
| 95 void PpapiUnittest::TearDown() { | 101 void PpapiUnittest::TearDown() { |
| 96 instance_ = NULL; | 102 instance_ = NULL; |
| 97 module_ = NULL; | 103 module_ = NULL; |
| 98 message_loop_.reset(); | 104 message_loop_.reset(); |
| 99 PluginModule::ResetHostGlobalsForTest(); | 105 PluginModule::ResetHostGlobalsForTest(); |
| 100 } | 106 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 111 DCHECK(module_->HasOneRef()); | 117 DCHECK(module_->HasOneRef()); |
| 112 module_ = NULL; | 118 module_ = NULL; |
| 113 } | 119 } |
| 114 | 120 |
| 115 void PpapiUnittest::SetViewSize(int width, int height) const { | 121 void PpapiUnittest::SetViewSize(int width, int height) const { |
| 116 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)); |
| 117 instance_->view_data_.clip_rect = instance_->view_data_.rect; | 123 instance_->view_data_.clip_rect = instance_->view_data_.rect; |
| 118 } | 124 } |
| 119 | 125 |
| 120 } // namespace content | 126 } // namespace content |
| OLD | NEW |