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 25 matching lines...) Expand all Loading... |
36 static bool IsRunningHeadless() { | 36 static bool IsRunningHeadless() { |
37 scoped_ptr<base::Environment> env(base::Environment::Create()); | 37 scoped_ptr<base::Environment> env(base::Environment::Create()); |
38 if (env->HasVar("CHROME_HEADLESS")) | 38 if (env->HasVar("CHROME_HEADLESS")) |
39 return true; | 39 return true; |
40 return false; | 40 return false; |
41 } | 41 } |
42 | 42 |
43 class MockAudioRendererHost : public AudioRendererHost { | 43 class MockAudioRendererHost : public AudioRendererHost { |
44 public: | 44 public: |
45 explicit MockAudioRendererHost( | 45 explicit MockAudioRendererHost( |
46 content::ResourceContext* resource_context) | 46 content::ResourceContext* resource_context, |
47 : AudioRendererHost(resource_context), | 47 AudioManager* audio_manager) |
| 48 : AudioRendererHost(resource_context, audio_manager), |
48 shared_memory_length_(0) { | 49 shared_memory_length_(0) { |
49 } | 50 } |
50 | 51 |
51 virtual ~MockAudioRendererHost() { | 52 virtual ~MockAudioRendererHost() { |
52 } | 53 } |
53 | 54 |
54 // A list of mock methods. | 55 // A list of mock methods. |
55 MOCK_METHOD2(OnStreamCreated, | 56 MOCK_METHOD2(OnStreamCreated, |
56 void(int stream_id, int length)); | 57 void(int stream_id, int length)); |
57 MOCK_METHOD1(OnStreamPlaying, void(int stream_id)); | 58 MOCK_METHOD1(OnStreamPlaying, void(int stream_id)); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); | 155 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); |
155 | 156 |
156 // Claim to be on both the UI and IO threads to pass all the DCHECKS. | 157 // Claim to be on both the UI and IO threads to pass all the DCHECKS. |
157 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, | 158 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, |
158 message_loop_.get())); | 159 message_loop_.get())); |
159 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, | 160 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, |
160 message_loop_.get())); | 161 message_loop_.get())); |
161 audio_manager_.reset(AudioManager::Create()); | 162 audio_manager_.reset(AudioManager::Create()); |
162 observer_.reset(new MockMediaObserver()); | 163 observer_.reset(new MockMediaObserver()); |
163 resource_context_.set_media_observer(observer_.get()); | 164 resource_context_.set_media_observer(observer_.get()); |
164 resource_context_.set_audio_manager(audio_manager_.get()); | 165 host_ = new MockAudioRendererHost(&resource_context_, audio_manager_.get()); |
165 host_ = new MockAudioRendererHost(&resource_context_); | |
166 | 166 |
167 // Simulate IPC channel connected. | 167 // Simulate IPC channel connected. |
168 host_->OnChannelConnected(base::GetCurrentProcId()); | 168 host_->OnChannelConnected(base::GetCurrentProcId()); |
169 } | 169 } |
170 | 170 |
171 virtual void TearDown() { | 171 virtual void TearDown() { |
172 // Simulate closing the IPC channel. | 172 // Simulate closing the IPC channel. |
173 host_->OnChannelClosing(); | 173 host_->OnChannelClosing(); |
174 | 174 |
175 // Release the reference to the mock object. The object will be destructed | 175 // Release the reference to the mock object. The object will be destructed |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 EnableRealDevice(); | 400 EnableRealDevice(); |
401 | 401 |
402 Create(); | 402 Create(); |
403 Play(); | 403 Play(); |
404 SimulateError(); | 404 SimulateError(); |
405 Close(); | 405 Close(); |
406 } | 406 } |
407 | 407 |
408 | 408 |
409 // TODO(hclam): Add tests for data conversation in low latency mode. | 409 // TODO(hclam): Add tests for data conversation in low latency mode. |
OLD | NEW |