Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: webkit/plugins/ppapi/ppapi_unittest.cc

Issue 11146009: Mac Flash: Fix scaling bitmap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/ppapi_unittest.h ('k') | webkit/plugins/ppapi/ppb_graphics_2d_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "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 "ppapi/shared_impl/ppapi_permissions.h" 9 #include "ppapi/shared_impl/ppapi_permissions.h"
10 #include "webkit/plugins/ppapi/gfx_conversion.h"
10 #include "webkit/plugins/ppapi/mock_plugin_delegate.h" 11 #include "webkit/plugins/ppapi/mock_plugin_delegate.h"
11 #include "webkit/plugins/ppapi/plugin_module.h" 12 #include "webkit/plugins/ppapi/plugin_module.h"
12 #include "webkit/plugins/ppapi/ppapi_interface_factory.h" 13 #include "webkit/plugins/ppapi/ppapi_interface_factory.h"
13 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 14 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
15 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
14 16
15 namespace webkit { 17 namespace webkit {
16 namespace ppapi { 18 namespace ppapi {
17 19
18 namespace { 20 namespace {
19 21
20 PpapiUnittest* current_unittest = NULL; 22 PpapiUnittest* current_unittest = NULL;
21 23
22 const void* MockGetInterface(const char* interface_name) { 24 const void* MockGetInterface(const char* interface_name) {
23 return current_unittest->GetMockInterface(interface_name); 25 return current_unittest->GetMockInterface(interface_name);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Initialize the mock module. 80 // Initialize the mock module.
79 module_ = new PluginModule("Mock plugin", FilePath(), this, 81 module_ = new PluginModule("Mock plugin", FilePath(), this,
80 ::ppapi::PpapiPermissions()); 82 ::ppapi::PpapiPermissions());
81 PluginModule::EntryPoints entry_points; 83 PluginModule::EntryPoints entry_points;
82 entry_points.get_interface = &MockGetInterface; 84 entry_points.get_interface = &MockGetInterface;
83 entry_points.initialize_module = &MockInitializeModule; 85 entry_points.initialize_module = &MockInitializeModule;
84 ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points)); 86 ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points));
85 87
86 // Initialize the mock instance. 88 // Initialize the mock instance.
87 instance_ = PluginInstance::Create(delegate_.get(), module()); 89 instance_ = PluginInstance::Create(delegate_.get(), module());
88
89 } 90 }
90 91
91 void PpapiUnittest::TearDown() { 92 void PpapiUnittest::TearDown() {
92 instance_ = NULL; 93 instance_ = NULL;
93 module_ = NULL; 94 module_ = NULL;
94 } 95 }
95 96
96 MockPluginDelegate* PpapiUnittest::NewPluginDelegate() { 97 MockPluginDelegate* PpapiUnittest::NewPluginDelegate() {
97 return new MockPluginDelegate; 98 return new MockPluginDelegate;
98 } 99 }
99 100
100 const void* PpapiUnittest::GetMockInterface(const char* interface_name) const { 101 const void* PpapiUnittest::GetMockInterface(const char* interface_name) const {
101 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE_1_0) == 0) 102 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE_1_0) == 0)
102 return &mock_instance_interface; 103 return &mock_instance_interface;
103 return NULL; 104 return NULL;
104 } 105 }
105 106
106 void PpapiUnittest::ShutdownModule() { 107 void PpapiUnittest::ShutdownModule() {
107 DCHECK(instance_->HasOneRef()); 108 DCHECK(instance_->HasOneRef());
108 instance_ = NULL; 109 instance_ = NULL;
109 DCHECK(module_->HasOneRef()); 110 DCHECK(module_->HasOneRef());
110 module_ = NULL; 111 module_ = NULL;
111 } 112 }
112 113
114 void PpapiUnittest::SetViewSize(int width, int height, float scale) const {
115 instance_->view_data_.rect = PP_FromGfxRect(gfx::Rect(0, 0, width, height));
116 instance_->view_data_.clip_rect = instance_->view_data_.rect;
117 instance_->GetBoundGraphics2D()->SetScale(scale);
118 }
119
113 void PpapiUnittest::PluginModuleDead(PluginModule* /* dead_module */) { 120 void PpapiUnittest::PluginModuleDead(PluginModule* /* dead_module */) {
114 // Nothing needed (this is necessary to make the module compile). 121 // Nothing needed (this is necessary to make the module compile).
115 } 122 }
116 123
117 // Tests whether custom PPAPI interface factories are called when PPAPI 124 // Tests whether custom PPAPI interface factories are called when PPAPI
118 // interfaces are requested. 125 // interfaces are requested.
119 class PpapiCustomInterfaceFactoryTest 126 class PpapiCustomInterfaceFactoryTest
120 : public testing::Test, 127 : public testing::Test,
121 public webkit::ppapi::PluginDelegate::ModuleLifetime { 128 public webkit::ppapi::PluginDelegate::ModuleLifetime {
122 public: 129 public:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 reset_result(); 162 reset_result();
156 PpapiInterfaceFactoryManager::GetInstance()->UnregisterFactory( 163 PpapiInterfaceFactoryManager::GetInstance()->UnregisterFactory(
157 PpapiCustomInterfaceFactoryTest::InterfaceFactory); 164 PpapiCustomInterfaceFactoryTest::InterfaceFactory);
158 165
159 (*PluginModule::GetLocalGetInterfaceFunc())("DummyInterface"); 166 (*PluginModule::GetLocalGetInterfaceFunc())("DummyInterface");
160 EXPECT_FALSE(result()); 167 EXPECT_FALSE(result());
161 } 168 }
162 169
163 } // namespace ppapi 170 } // namespace ppapi
164 } // namespace webkit 171 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppapi_unittest.h ('k') | webkit/plugins/ppapi/ppb_graphics_2d_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698