Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/environment.h" | 6 #include "base/environment.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/sync_socket.h" | 10 #include "base/sync_socket.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 | 42 |
| 43 class MockAudioRendererHost : public AudioRendererHost { | 43 class MockAudioRendererHost : public AudioRendererHost { |
| 44 public: | 44 public: |
| 45 explicit MockAudioRendererHost( | 45 explicit MockAudioRendererHost( |
| 46 media::AudioManager* audio_manager, | 46 media::AudioManager* audio_manager, |
| 47 content::MediaObserver* media_observer) | 47 content::MediaObserver* media_observer) |
| 48 : AudioRendererHost(audio_manager, media_observer), | 48 : AudioRendererHost(audio_manager, media_observer), |
| 49 shared_memory_length_(0) { | 49 shared_memory_length_(0) { |
| 50 } | 50 } |
| 51 | 51 |
| 52 virtual ~MockAudioRendererHost() { | |
| 53 // Make sure all audio streams have been deleted. | |
| 54 EXPECT_EQ(0u, audio_entries_.size()); | |
| 55 } | |
| 56 | |
| 57 // A list of mock methods. | 52 // A list of mock methods. |
| 58 MOCK_METHOD2(OnStreamCreated, | 53 MOCK_METHOD2(OnStreamCreated, |
| 59 void(int stream_id, int length)); | 54 void(int stream_id, int length)); |
| 60 MOCK_METHOD1(OnStreamPlaying, void(int stream_id)); | 55 MOCK_METHOD1(OnStreamPlaying, void(int stream_id)); |
| 61 MOCK_METHOD1(OnStreamPaused, void(int stream_id)); | 56 MOCK_METHOD1(OnStreamPaused, void(int stream_id)); |
| 62 MOCK_METHOD1(OnStreamError, void(int stream_id)); | 57 MOCK_METHOD1(OnStreamError, void(int stream_id)); |
| 63 MOCK_METHOD2(OnStreamVolume, void(int stream_id, double volume)); | 58 MOCK_METHOD2(OnStreamVolume, void(int stream_id, double volume)); |
| 64 | 59 |
| 65 base::SharedMemory* shared_memory() { return shared_memory_.get(); } | 60 base::SharedMemory* shared_memory() { return shared_memory_.get(); } |
| 66 uint32 shared_memory_length() { return shared_memory_length_; } | 61 uint32 shared_memory_length() { return shared_memory_length_; } |
| 67 | 62 |
| 68 base::SyncSocket* sync_socket() { return sync_socket_.get(); } | 63 base::SyncSocket* sync_socket() { return sync_socket_.get(); } |
| 69 | 64 |
| 70 private: | 65 private: |
| 66 virtual ~MockAudioRendererHost() { | |
| 67 // Make sure all audio streams have been deleted. | |
| 68 EXPECT_EQ(0u, audio_entries_.size()); | |
|
sky
2012/04/27 15:45:23
nit: empty
| |
| 69 } | |
| 70 | |
| 71 // This method is used to dispatch IPC messages to the renderer. We intercept | 71 // This method is used to dispatch IPC messages to the renderer. We intercept |
| 72 // these messages here and dispatch to our mock methods to verify the | 72 // these messages here and dispatch to our mock methods to verify the |
| 73 // conversation between this object and the renderer. | 73 // conversation between this object and the renderer. |
| 74 virtual bool Send(IPC::Message* message) { | 74 virtual bool Send(IPC::Message* message) { |
| 75 CHECK(message); | 75 CHECK(message); |
| 76 | 76 |
| 77 // In this method we dispatch the messages to the according handlers as if | 77 // In this method we dispatch the messages to the according handlers as if |
| 78 // we are the renderer. | 78 // we are the renderer. |
| 79 bool handled = true; | 79 bool handled = true; |
| 80 IPC_BEGIN_MESSAGE_MAP(MockAudioRendererHost, *message) | 80 IPC_BEGIN_MESSAGE_MAP(MockAudioRendererHost, *message) |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 EnableRealDevice(); | 404 EnableRealDevice(); |
| 405 | 405 |
| 406 Create(); | 406 Create(); |
| 407 Play(); | 407 Play(); |
| 408 SimulateError(); | 408 SimulateError(); |
| 409 Close(); | 409 Close(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 | 412 |
| 413 // TODO(hclam): Add tests for data conversation in low latency mode. | 413 // TODO(hclam): Add tests for data conversation in low latency mode. |
| OLD | NEW |