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

Side by Side Diff: content/test/ppapi_unittest.cc

Issue 2463703006: Initialy renderer ppapi host in ppapi_unittests to fix nullptr access. (Closed)
Patch Set: Export CreateOnModuleForInProcess Created 4 years, 1 month 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
« no previous file with comments | « content/renderer/pepper/renderer_ppapi_host_impl.h ('k') | no next file » | 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 "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
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
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
OLDNEW
« no previous file with comments | « content/renderer/pepper/renderer_ppapi_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698