summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-31 23:31:47 +0000
committerarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-31 23:31:47 +0000
commitb44a68148fb3f7a919010a4e5765b7b746453cbf (patch)
tree78af937ef248a6de3faf648760f3176748f34e2e
parent82347fd5a40e3ffa1204f587aefd930a6b32fd8a (diff)
downloadchromium_src-b44a68148fb3f7a919010a4e5765b7b746453cbf.zip
chromium_src-b44a68148fb3f7a919010a4e5765b7b746453cbf.tar.gz
chromium_src-b44a68148fb3f7a919010a4e5765b7b746453cbf.tar.bz2
Revert 43234 - Add a Pepper audio basic functionality unit test, take 2.
Also changed TestSink to be derived from IPC::Channel and made MockRenderThread service AddFilter/RemoveFilter, so that it can be used by MessageFilters. Also removed some logging because it triggers Valgrind errors. Review URL: http://codereview.chromium.org/1466001 TBR=neb@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43284 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/ipc_test_sink.cc8
-rw-r--r--chrome/common/ipc_test_sink.h9
-rw-r--r--chrome/renderer/mock_render_thread.cc12
-rw-r--r--chrome/renderer/mock_render_thread.h8
-rw-r--r--chrome/renderer/pepper_devices.cc4
-rw-r--r--chrome/renderer/pepper_devices_unittest.cc27
-rw-r--r--ipc/ipc_channel.h9
7 files changed, 13 insertions, 64 deletions
diff --git a/chrome/common/ipc_test_sink.cc b/chrome/common/ipc_test_sink.cc
index 04fd065..6a0e45b 100644
--- a/chrome/common/ipc_test_sink.cc
+++ b/chrome/common/ipc_test_sink.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,12 +12,6 @@ TestSink::TestSink() {
TestSink::~TestSink() {
}
-bool TestSink::Send(IPC::Message* message) {
- OnMessageReceived(*message);
- delete message;
- return true;
-}
-
void TestSink::OnMessageReceived(const Message& msg) {
messages_.push_back(Message(msg));
}
diff --git a/chrome/common/ipc_test_sink.h b/chrome/common/ipc_test_sink.h
index 96e91c0..973fc71 100644
--- a/chrome/common/ipc_test_sink.h
+++ b/chrome/common/ipc_test_sink.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,7 +9,6 @@
#include <vector>
#include "base/basictypes.h"
-#include "ipc/ipc_channel.h"
#include "ipc/ipc_message.h"
namespace IPC {
@@ -41,15 +40,11 @@ namespace IPC {
//
// To hook up the sink, all you need to do is call OnMessageReceived when a
// message is received.
-class TestSink : public IPC::Channel {
+class TestSink {
public:
TestSink();
~TestSink();
- // Interface in IPC::Channel. This copies the message to the sink and then
- // deletes it.
- virtual bool Send(IPC::Message* message);
-
// Used by the source of the messages to send the message to the sink. This
// will make a copy of the message and store it in the list.
void OnMessageReceived(const Message& msg);
diff --git a/chrome/renderer/mock_render_thread.cc b/chrome/renderer/mock_render_thread.cc
index cda4fef..1fa513f 100644
--- a/chrome/renderer/mock_render_thread.cc
+++ b/chrome/renderer/mock_render_thread.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -34,16 +34,6 @@ void MockRenderThread::RemoveRoute(int32 routing_id) {
widget_ = NULL;
}
-// Called by, for example, RenderView::Init(), when adding a new message filter.
-void MockRenderThread::AddFilter(IPC::ChannelProxy::MessageFilter* filter) {
- filter->OnFilterAdded(&sink());
-}
-
-// Called when the filter is removed.
-void MockRenderThread::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) {
- filter->OnFilterRemoved();
-}
-
// Called by the Widget. Used to send messages to the browser.
// We short-circuit the mechanim and handle the messages right here on this
// class.
diff --git a/chrome/renderer/mock_render_thread.h b/chrome/renderer/mock_render_thread.h
index 03fe08f..4f3b1d9 100644
--- a/chrome/renderer/mock_render_thread.h
+++ b/chrome/renderer/mock_render_thread.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -40,9 +40,9 @@ class MockRenderThread : public RenderThreadBase {
// class.
virtual bool Send(IPC::Message* msg);
- // Filtering support.
- virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter);
- virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter);
+ // Our mock thread doesn't do filtering.
+ virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) { }
+ virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) { }
// Our mock thread doesn't deal with hidden and restored tabs.
virtual void WidgetHidden() { }
diff --git a/chrome/renderer/pepper_devices.cc b/chrome/renderer/pepper_devices.cc
index 494884c..67301fa 100644
--- a/chrome/renderer/pepper_devices.cc
+++ b/chrome/renderer/pepper_devices.cc
@@ -168,6 +168,10 @@ NPError AudioDeviceContext::Initialize(AudioMessageFilter* filter,
// TODO(neb): figure out if this number is grounded in reality
params.buffer_capacity = params.packet_size * 3;
+ LOG(INFO) << "Initializing Pepper Audio Context (" <<
+ config->sampleFrameCount << "Hz, " << params.bits_per_sample <<
+ " bits, " << config->outputChannelMap << "channels";
+
stream_id_ = filter_->AddDelegate(this);
filter->Send(new ViewHostMsg_CreateAudioStream(0, stream_id_, params, true));
return NPERR_NO_ERROR;
diff --git a/chrome/renderer/pepper_devices_unittest.cc b/chrome/renderer/pepper_devices_unittest.cc
index b55ba88..de4941e 100644
--- a/chrome/renderer/pepper_devices_unittest.cc
+++ b/chrome/renderer/pepper_devices_unittest.cc
@@ -117,9 +117,6 @@ class PepperDeviceTest : public RenderViewTest {
NPError err,
NPUserData* user_data);
- // Audio callback, currently empty.
- static void AudioCallback(NPDeviceContextAudio* context);
-
// A log of flush commands we can use to check the async callbacks.
struct FlushData {
NPP instance;
@@ -221,10 +218,6 @@ void PepperDeviceTest::FlushCalled(NPP instance,
that->flush_calls_.push_back(flush_data);
}
-void PepperDeviceTest::AudioCallback(NPDeviceContextAudio* context) {
-}
-
-
// -----------------------------------------------------------------------------
// TODO(brettw) this crashes on Mac. Figure out why and enable.
@@ -257,23 +250,3 @@ TEST_F(PepperDeviceTest, Flush) {
EXPECT_EQ(1u, flush_calls_.size());
}
#endif
-
-TEST_F(PepperDeviceTest, AudioInit) {
- NPDeviceContextAudioConfig config;
- config.sampleRate = NPAudioSampleRate44100Hz;
- config.sampleType = NPAudioSampleTypeInt16;
- config.outputChannelMap = NPAudioChannelStereo;
- config.callback = &AudioCallback;
- config.userData = this;
- NPDeviceContextAudio context;
- EXPECT_EQ(NPERR_NO_ERROR,
- pepper_plugin()->DeviceAudioInitializeContext(&config, &context));
- EXPECT_TRUE(render_thread_.sink().GetFirstMessageMatching(
- ViewHostMsg_CreateAudioStream::ID));
- EXPECT_EQ(0, memcmp(&config, &context.config, sizeof(config)));
- EXPECT_EQ(NPERR_NO_ERROR,
- pepper_plugin()->DeviceAudioDestroyContext(&context));
- EXPECT_TRUE(render_thread_.sink().GetFirstMessageMatching(
- ViewHostMsg_CloseAudioStream::ID));
-}
-
diff --git a/ipc/ipc_channel.h b/ipc/ipc_channel.h
index d1dbd03..a7a9a34 100644
--- a/ipc/ipc_channel.h
+++ b/ipc/ipc_channel.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -96,13 +96,6 @@ class Channel : public Message::Sender {
int GetClientFileDescriptor() const;
#endif // defined(OS_POSIX)
- protected:
- // Used in Chrome by the TestSink to provide a dummy channel implementation
- // for testing. TestSink overrides the "interesting" functions in Channel so
- // no actual implementation is needed. This will cause un-overridden calls to
- // segfault. Do not use outside of test code!
- Channel() : channel_impl_(0) { }
-
private:
// PIMPL to which all channel calls are delegated.
class ChannelImpl;