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

Side by Side Diff: chrome/renderer/pepper_devices_browsertest.cc

Issue 5961004: Revert 69755 - Move the NPAPI files from webkit/glue/plugins to webkit/plugin... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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 | « chrome/renderer/pepper_devices.cc ('k') | chrome/renderer/pepper_plugin_delegate_impl.cc » ('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) 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 <map> 5 #include <map>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/common/render_messages.h" 11 #include "chrome/common/render_messages.h"
12 #include "chrome/renderer/pepper_devices.h" 12 #include "chrome/renderer/pepper_devices.h"
13 #include "chrome/renderer/webplugin_delegate_pepper.h" 13 #include "chrome/renderer/webplugin_delegate_pepper.h"
14 #include "chrome/test/render_view_test.h" 14 #include "chrome/test/render_view_test.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/npapi/bindings/npapi.h" 16 #include "third_party/npapi/bindings/npapi.h"
17 #include "third_party/npapi/bindings/npruntime.h" 17 #include "third_party/npapi/bindings/npruntime.h"
18 #include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h" 18 #include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h"
19 #include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h" 19 #include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h"
20 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" 20 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
21 #include "webkit/plugins/npapi/plugin_instance.h" 21 #include "webkit/glue/plugins/plugin_instance.h"
22 #include "webkit/plugins/npapi/plugin_list.h" 22 #include "webkit/glue/plugins/plugin_list.h"
23 #include "webkit/plugins/npapi/webplugin_impl.h" 23 #include "webkit/glue/plugins/webplugin_impl.h"
24 24
25 class PepperDeviceTest; 25 class PepperDeviceTest;
26 26
27 namespace { 27 namespace {
28 28
29 const char kTestPluginMimeType[] = "chrome-test/pepper-device-test"; 29 const char kTestPluginMimeType[] = "chrome-test/pepper-device-test";
30 30
31 // This maps the NPP instances to the test object so our C callbacks can easily 31 // This maps the NPP instances to the test object so our C callbacks can easily
32 // get back to the object. There will normally be only one item in this map. 32 // get back to the object. There will normally be only one item in this map.
33 static std::map<NPP, PepperDeviceTest*> active_tests; 33 static std::map<NPP, PepperDeviceTest*> active_tests;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 NPError err; 128 NPError err;
129 NPUserData* user_data; 129 NPUserData* user_data;
130 }; 130 };
131 std::vector<FlushData> flush_calls_; 131 std::vector<FlushData> flush_calls_;
132 132
133 private: 133 private:
134 // testing::Test implementation. 134 // testing::Test implementation.
135 virtual void SetUp(); 135 virtual void SetUp();
136 virtual void TearDown(); 136 virtual void TearDown();
137 137
138 webkit::npapi::PluginVersionInfo version_info_; 138 NPAPI::PluginVersionInfo version_info_;
139 139
140 scoped_ptr<webkit::npapi::WebPluginImpl> plugin_; 140 scoped_ptr<webkit_glue::WebPluginImpl> plugin_;
141 WebPluginDelegatePepper* pepper_plugin_; // FIXME(brettw): check lifetime. 141 WebPluginDelegatePepper* pepper_plugin_; // FIXME(brettw): check lifetime.
142 }; 142 };
143 143
144 PepperDeviceTest::PepperDeviceTest() { 144 PepperDeviceTest::PepperDeviceTest() {
145 version_info_.path = FilePath(FILE_PATH_LITERAL("pepper-device-tester")); 145 version_info_.path = FilePath(FILE_PATH_LITERAL("pepper-device-tester"));
146 version_info_.product_name = ASCIIToWide("Pepper device test plugin"); 146 version_info_.product_name = ASCIIToWide("Pepper device test plugin");
147 version_info_.file_description = ASCIIToWide("Pepper device test plugin"); 147 version_info_.file_description = ASCIIToWide("Pepper device test plugin");
148 version_info_.file_version = ASCIIToWide("1"); 148 version_info_.file_version = ASCIIToWide("1");
149 version_info_.mime_types = ASCIIToWide(kTestPluginMimeType); 149 version_info_.mime_types = ASCIIToWide(kTestPluginMimeType);
150 webkit::npapi::PluginEntryPoints entry_points = { 150 NPAPI::PluginEntryPoints entry_points = {
151 #if !defined(OS_POSIX) || defined(OS_MACOSX) 151 #if !defined(OS_POSIX) || defined(OS_MACOSX)
152 NP_GetEntryPoints, 152 NP_GetEntryPoints,
153 #endif 153 #endif
154 NP_Initialize, 154 NP_Initialize,
155 NP_Shutdown 155 NP_Shutdown
156 }; 156 };
157 version_info_.entry_points = entry_points; 157 version_info_.entry_points = entry_points;
158 } 158 }
159 159
160 PepperDeviceTest::~PepperDeviceTest() { 160 PepperDeviceTest::~PepperDeviceTest() {
161 } 161 }
162 162
163 void PepperDeviceTest::SetUp() { 163 void PepperDeviceTest::SetUp() {
164 RenderViewTest::SetUp(); 164 RenderViewTest::SetUp();
165 165
166 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(version_info_); 166 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(version_info_);
167 167
168 // Create the WebKit plugin with no delegates (this seems to work 168 // Create the WebKit plugin with no delegates (this seems to work
169 // sufficiently for the test). 169 // sufficiently for the test).
170 WebKit::WebPluginParams params; 170 WebKit::WebPluginParams params;
171 plugin_.reset(new webkit::npapi::WebPluginImpl( 171 plugin_.reset(new webkit_glue::WebPluginImpl(
172 NULL, params, FilePath(), std::string(), 172 NULL, params, FilePath(), std::string(),
173 base::WeakPtr<webkit::npapi::WebPluginPageDelegate>())); 173 base::WeakPtr<webkit_glue::WebPluginPageDelegate>()));
174 174
175 // Create a pepper plugin for the RenderView. 175 // Create a pepper plugin for the RenderView.
176 pepper_plugin_ = WebPluginDelegatePepper::Create( 176 pepper_plugin_ = WebPluginDelegatePepper::Create(
177 plugin_path(), kTestPluginMimeType, view_->AsWeakPtr()); 177 plugin_path(), kTestPluginMimeType, view_->AsWeakPtr());
178 ASSERT_TRUE(pepper_plugin_); 178 ASSERT_TRUE(pepper_plugin_);
179 ASSERT_TRUE(pepper_plugin_->Initialize(GURL(), std::vector<std::string>(), 179 ASSERT_TRUE(pepper_plugin_->Initialize(GURL(), std::vector<std::string>(),
180 std::vector<std::string>(), 180 std::vector<std::string>(),
181 plugin_.get(), false)); 181 plugin_.get(), false));
182 182
183 // Normally the RenderView creates the pepper plugin and registers it with 183 // Normally the RenderView creates the pepper plugin and registers it with
(...skipping 10 matching lines...) Expand all
194 pepper_plugin_->UpdateGeometry(rect, rect); 194 pepper_plugin_->UpdateGeometry(rect, rect);
195 } 195 }
196 196
197 void PepperDeviceTest::TearDown() { 197 void PepperDeviceTest::TearDown() {
198 active_tests.erase(active_tests.find(npp())); 198 active_tests.erase(active_tests.find(npp()));
199 199
200 plugin_.reset(); 200 plugin_.reset();
201 if (pepper_plugin_) 201 if (pepper_plugin_)
202 pepper_plugin_->PluginDestroyed(); 202 pepper_plugin_->PluginDestroyed();
203 203
204 webkit::npapi::PluginList::Singleton()->UnregisterInternalPlugin( 204 NPAPI::PluginList::Singleton()->UnregisterInternalPlugin(version_info_.path);
205 version_info_.path);
206 205
207 RenderViewTest::TearDown(); 206 RenderViewTest::TearDown();
208 } 207 }
209 208
210 // static 209 // static
211 void PepperDeviceTest::FlushCalled(NPP instance, 210 void PepperDeviceTest::FlushCalled(NPP instance,
212 NPDeviceContext* context, 211 NPDeviceContext* context,
213 NPError err, 212 NPError err,
214 NPUserData* user_data) { 213 NPUserData* user_data) {
215 if (active_tests.find(instance) == active_tests.end()) 214 if (active_tests.find(instance) == active_tests.end())
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 EXPECT_EQ(NPERR_NO_ERROR, 271 EXPECT_EQ(NPERR_NO_ERROR,
273 pepper_plugin()->DeviceAudioInitializeContext(&config, &context)); 272 pepper_plugin()->DeviceAudioInitializeContext(&config, &context));
274 EXPECT_TRUE(render_thread_.sink().GetFirstMessageMatching( 273 EXPECT_TRUE(render_thread_.sink().GetFirstMessageMatching(
275 ViewHostMsg_CreateAudioStream::ID)); 274 ViewHostMsg_CreateAudioStream::ID));
276 EXPECT_EQ(NPERR_NO_ERROR, 275 EXPECT_EQ(NPERR_NO_ERROR,
277 pepper_plugin()->DeviceAudioDestroyContext(&context)); 276 pepper_plugin()->DeviceAudioDestroyContext(&context));
278 EXPECT_TRUE(render_thread_.sink().GetFirstMessageMatching( 277 EXPECT_TRUE(render_thread_.sink().GetFirstMessageMatching(
279 ViewHostMsg_CloseAudioStream::ID)); 278 ViewHostMsg_CloseAudioStream::ID));
280 } 279 }
281 280
OLDNEW
« no previous file with comments | « chrome/renderer/pepper_devices.cc ('k') | chrome/renderer/pepper_plugin_delegate_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698