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

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

Issue 1344003: Revert 42656 - Add a Pepper audio basic functionality unit test.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 9 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 | « chrome/renderer/mock_render_thread.cc ('k') | ipc/ipc_channel.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) 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 "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 NPP npp() const { return pepper_plugin_->instance()->npp(); } 111 NPP npp() const { return pepper_plugin_->instance()->npp(); }
112 112
113 protected: 113 protected:
114 // Logs that the given flush command was called in flush_calls. 114 // Logs that the given flush command was called in flush_calls.
115 static void FlushCalled(NPP instance, 115 static void FlushCalled(NPP instance,
116 NPDeviceContext* context, 116 NPDeviceContext* context,
117 NPError err, 117 NPError err,
118 NPUserData* user_data); 118 NPUserData* user_data);
119 119
120 // Audio callback, currently empty.
121 static void AudioCallback(NPDeviceContextAudio* context);
122
123 // A log of flush commands we can use to check the async callbacks. 120 // A log of flush commands we can use to check the async callbacks.
124 struct FlushData { 121 struct FlushData {
125 NPP instance; 122 NPP instance;
126 NPDeviceContext* context; 123 NPDeviceContext* context;
127 NPError err; 124 NPError err;
128 NPUserData* user_data; 125 NPUserData* user_data;
129 }; 126 };
130 std::vector<FlushData> flush_calls_; 127 std::vector<FlushData> flush_calls_;
131 128
132 private: 129 private:
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 PepperDeviceTest* that = active_tests[instance]; 211 PepperDeviceTest* that = active_tests[instance];
215 212
216 FlushData flush_data; 213 FlushData flush_data;
217 flush_data.instance = instance; 214 flush_data.instance = instance;
218 flush_data.context = context; 215 flush_data.context = context;
219 flush_data.err = err; 216 flush_data.err = err;
220 flush_data.user_data = user_data; 217 flush_data.user_data = user_data;
221 that->flush_calls_.push_back(flush_data); 218 that->flush_calls_.push_back(flush_data);
222 } 219 }
223 220
224 void PepperDeviceTest::AudioCallback(NPDeviceContextAudio* context) {
225 }
226
227
228 // ----------------------------------------------------------------------------- 221 // -----------------------------------------------------------------------------
229 222
230 // TODO(brettw) this crashes on Mac. Figure out why and enable. 223 // TODO(brettw) this crashes on Mac. Figure out why and enable.
231 #if !defined(OS_MACOSX) 224 #if !defined(OS_MACOSX)
232 225
233 TEST_F(PepperDeviceTest, Flush) { 226 TEST_F(PepperDeviceTest, Flush) {
234 // Create a 2D device. 227 // Create a 2D device.
235 NPDeviceContext2DConfig config; 228 NPDeviceContext2DConfig config;
236 NPDeviceContext2D context; 229 NPDeviceContext2D context;
237 EXPECT_EQ(NPERR_NO_ERROR, 230 EXPECT_EQ(NPERR_NO_ERROR,
(...skipping 12 matching lines...) Expand all
250 MessageLoop::current()->RunAllPending(); 243 MessageLoop::current()->RunAllPending();
251 EXPECT_TRUE(flush_calls_.empty()); 244 EXPECT_TRUE(flush_calls_.empty());
252 EXPECT_TRUE(render_thread_.sink().GetFirstMessageMatching( 245 EXPECT_TRUE(render_thread_.sink().GetFirstMessageMatching(
253 ViewHostMsg_UpdateRect::ID)); 246 ViewHostMsg_UpdateRect::ID));
254 247
255 // Send a paint ACK, this should trigger the callback. 248 // Send a paint ACK, this should trigger the callback.
256 view_->OnMessageReceived(ViewMsg_UpdateRect_ACK(view_->routing_id())); 249 view_->OnMessageReceived(ViewMsg_UpdateRect_ACK(view_->routing_id()));
257 EXPECT_EQ(1u, flush_calls_.size()); 250 EXPECT_EQ(1u, flush_calls_.size());
258 } 251 }
259 #endif 252 #endif
260
261 TEST_F(PepperDeviceTest, AudioInit) {
262 NPDeviceContextAudioConfig config;
263 config.sampleRate = NPAudioSampleRate44100Hz;
264 config.sampleType = NPAudioSampleTypeInt16;
265 config.outputChannelMap = NPAudioChannelStereo;
266 config.callback = &AudioCallback;
267 config.userData = this;
268 NPDeviceContextAudio context;
269 EXPECT_EQ(NPERR_NO_ERROR,
270 pepper_plugin()->DeviceAudioInitializeContext(&config, &context));
271 EXPECT_TRUE(render_thread_.sink().GetFirstMessageMatching(
272 ViewHostMsg_CreateAudioStream::ID));
273 EXPECT_EQ(0, memcmp(&config, &context.config, sizeof(config)));
274 EXPECT_EQ(NPERR_NO_ERROR,
275 pepper_plugin()->DeviceAudioDestroyContext(&context));
276 EXPECT_TRUE(render_thread_.sink().GetFirstMessageMatching(
277 ViewHostMsg_CloseAudioStream::ID));
278 }
279
OLDNEW
« no previous file with comments | « chrome/renderer/mock_render_thread.cc ('k') | ipc/ipc_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698