| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/process_util.h" | 6 #include "base/process_util.h" |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "chrome/browser/chrome_thread.h" | 8 #include "chrome/browser/chrome_thread.h" |
| 9 #include "chrome/browser/renderer_host/audio_renderer_host.h" | 9 #include "chrome/browser/renderer_host/audio_renderer_host.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 void(int routing_id, int stream_id, | 42 void(int routing_id, int stream_id, |
| 43 size_t bytes_in_buffer, int64 message_timestamp)); | 43 size_t bytes_in_buffer, int64 message_timestamp)); |
| 44 | 44 |
| 45 MOCK_METHOD3(OnStreamCreated, | 45 MOCK_METHOD3(OnStreamCreated, |
| 46 void(int routing_id, int stream_id, int length)); | 46 void(int routing_id, int stream_id, int length)); |
| 47 | 47 |
| 48 MOCK_METHOD3(OnStreamStateChanged, | 48 MOCK_METHOD3(OnStreamStateChanged, |
| 49 void(int routing_id, int stream_id, | 49 void(int routing_id, int stream_id, |
| 50 ViewMsg_AudioStreamState state)); | 50 ViewMsg_AudioStreamState state)); |
| 51 | 51 |
| 52 MOCK_METHOD4(OnStreamVolume, | 52 MOCK_METHOD3(OnStreamVolume, |
| 53 void(int routing_id, int stream_id, double left, double right)); | 53 void(int routing_id, int stream_id, double volume)); |
| 54 | 54 |
| 55 base::SharedMemory* shared_memory() { return shared_memory_.get(); } | 55 base::SharedMemory* shared_memory() { return shared_memory_.get(); } |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 // This method is used to dispatch IPC messages to the renderer. We intercept | 58 // This method is used to dispatch IPC messages to the renderer. We intercept |
| 59 // these messages here and dispatch to our mock methods to verify the | 59 // these messages here and dispatch to our mock methods to verify the |
| 60 // conversation between this object and the renderer. | 60 // conversation between this object and the renderer. |
| 61 virtual void Send(IPC::Message* message) { | 61 virtual void Send(IPC::Message* message) { |
| 62 CHECK(message); | 62 CHECK(message); |
| 63 | 63 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 94 | 94 |
| 95 // And then delegate the call to the mock method. | 95 // And then delegate the call to the mock method. |
| 96 OnStreamCreated(msg.routing_id(), stream_id, length); | 96 OnStreamCreated(msg.routing_id(), stream_id, length); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void OnStreamStateChanged(const IPC::Message& msg, int stream_id, | 99 void OnStreamStateChanged(const IPC::Message& msg, int stream_id, |
| 100 ViewMsg_AudioStreamState state) { | 100 ViewMsg_AudioStreamState state) { |
| 101 OnStreamStateChanged(msg.routing_id(), stream_id, state); | 101 OnStreamStateChanged(msg.routing_id(), stream_id, state); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void OnStreamVolume(const IPC::Message& msg, int stream_id, | 104 void OnStreamVolume(const IPC::Message& msg, int stream_id, double volume) { |
| 105 double left, double right) { | 105 OnStreamVolume(msg.routing_id(), stream_id, volume); |
| 106 OnStreamVolume(msg.routing_id(), stream_id, left, right); | |
| 107 } | 106 } |
| 108 | 107 |
| 109 scoped_ptr<base::SharedMemory> shared_memory_; | 108 scoped_ptr<base::SharedMemory> shared_memory_; |
| 110 | 109 |
| 111 DISALLOW_COPY_AND_ASSIGN(MockAudioRendererHost); | 110 DISALLOW_COPY_AND_ASSIGN(MockAudioRendererHost); |
| 112 }; | 111 }; |
| 113 | 112 |
| 114 class AudioRendererHostTest : public testing::Test { | 113 class AudioRendererHostTest : public testing::Test { |
| 115 public: | 114 public: |
| 116 AudioRendererHostTest() | 115 AudioRendererHostTest() |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 source->NotifyPacketReady(kPacketSize); | 218 source->NotifyPacketReady(kPacketSize); |
| 220 source->NotifyPacketReady(kPacketSize); | 219 source->NotifyPacketReady(kPacketSize); |
| 221 source->NotifyPacketReady(kStep); | 220 source->NotifyPacketReady(kStep); |
| 222 source->NotifyPacketReady(kStep); | 221 source->NotifyPacketReady(kStep); |
| 223 source->NotifyPacketReady(kStep); | 222 source->NotifyPacketReady(kStep); |
| 224 source->NotifyPacketReady(kStep); | 223 source->NotifyPacketReady(kStep); |
| 225 source->Play(); | 224 source->Play(); |
| 226 EXPECT_EQ(ViewMsg_AudioStreamState::kPlaying, state.state); | 225 EXPECT_EQ(ViewMsg_AudioStreamState::kPlaying, state.state); |
| 227 source->Close(); | 226 source->Close(); |
| 228 } | 227 } |
| OLD | NEW |