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

Side by Side Diff: content/browser/renderer_host/media/audio_renderer_host_unittest.cc

Issue 10837118: Dead code elimination: scythe.chrome_functions:segment.path %media% edition, round 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 // A list of mock methods. 52 // A list of mock methods.
53 MOCK_METHOD2(OnStreamCreated, 53 MOCK_METHOD2(OnStreamCreated,
54 void(int stream_id, int length)); 54 void(int stream_id, int length));
55 MOCK_METHOD1(OnStreamPlaying, void(int stream_id)); 55 MOCK_METHOD1(OnStreamPlaying, void(int stream_id));
56 MOCK_METHOD1(OnStreamPaused, void(int stream_id)); 56 MOCK_METHOD1(OnStreamPaused, void(int stream_id));
57 MOCK_METHOD1(OnStreamError, void(int stream_id)); 57 MOCK_METHOD1(OnStreamError, void(int stream_id));
58 MOCK_METHOD2(OnStreamVolume, void(int stream_id, double volume)); 58 MOCK_METHOD2(OnStreamVolume, void(int stream_id, double volume));
59 59
60 base::SharedMemory* shared_memory() { return shared_memory_.get(); }
61 uint32 shared_memory_length() { return shared_memory_length_; }
62
63 base::SyncSocket* sync_socket() { return sync_socket_.get(); }
64
65 private: 60 private:
66 virtual ~MockAudioRendererHost() { 61 virtual ~MockAudioRendererHost() {
67 // Make sure all audio streams have been deleted. 62 // Make sure all audio streams have been deleted.
68 EXPECT_TRUE(audio_entries_.empty()); 63 EXPECT_TRUE(audio_entries_.empty());
69 } 64 }
70 65
71 // This method is used to dispatch IPC messages to the renderer. We intercept 66 // 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 67 // these messages here and dispatch to our mock methods to verify the
73 // conversation between this object and the renderer. 68 // conversation between this object and the renderer.
74 virtual bool Send(IPC::Message* message) { 69 virtual bool Send(IPC::Message* message) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 break; 123 break;
129 case media::AudioOutputIPCDelegate::kError: 124 case media::AudioOutputIPCDelegate::kError:
130 OnStreamError(stream_id); 125 OnStreamError(stream_id);
131 break; 126 break;
132 default: 127 default:
133 FAIL() << "Unknown stream state"; 128 FAIL() << "Unknown stream state";
134 break; 129 break;
135 } 130 }
136 } 131 }
137 132
138 void OnStreamVolume(const IPC::Message& msg, int stream_id, double volume) {
139 OnStreamVolume(stream_id, volume);
140 }
141
142 scoped_ptr<base::SharedMemory> shared_memory_; 133 scoped_ptr<base::SharedMemory> shared_memory_;
143 scoped_ptr<base::SyncSocket> sync_socket_; 134 scoped_ptr<base::SyncSocket> sync_socket_;
144 uint32 shared_memory_length_; 135 uint32 shared_memory_length_;
145 136
146 DISALLOW_COPY_AND_ASSIGN(MockAudioRendererHost); 137 DISALLOW_COPY_AND_ASSIGN(MockAudioRendererHost);
147 }; 138 };
148 139
149 ACTION_P(QuitMessageLoop, message_loop) { 140 ACTION_P(QuitMessageLoop, message_loop) {
150 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 141 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure());
151 } 142 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 void SyncWithAudioThread() { 289 void SyncWithAudioThread() {
299 // Don't use scoped_refptr to addref the media::AudioManager when posting 290 // Don't use scoped_refptr to addref the media::AudioManager when posting
300 // to the thread that itself owns. 291 // to the thread that itself owns.
301 message_loop_->PostTask( 292 message_loop_->PostTask(
302 FROM_HERE, base::Bind(&PostQuitOnAudioThread, 293 FROM_HERE, base::Bind(&PostQuitOnAudioThread,
303 base::Unretained(audio_manager_.get()), 294 base::Unretained(audio_manager_.get()),
304 message_loop_.get())); 295 message_loop_.get()));
305 message_loop_->Run(); 296 message_loop_->Run();
306 } 297 }
307 298
308 MessageLoop* message_loop() { return message_loop_.get(); }
309 MockAudioRendererHost* host() { return host_; }
310 void EnableRealDevice() { mock_stream_ = false; } 299 void EnableRealDevice() { mock_stream_ = false; }
311 300
312 private: 301 private:
313 bool mock_stream_; 302 bool mock_stream_;
314 scoped_ptr<MockMediaObserver> observer_; 303 scoped_ptr<MockMediaObserver> observer_;
315 scoped_refptr<MockAudioRendererHost> host_; 304 scoped_refptr<MockAudioRendererHost> host_;
316 scoped_ptr<MessageLoop> message_loop_; 305 scoped_ptr<MessageLoop> message_loop_;
317 scoped_ptr<BrowserThreadImpl> io_thread_; 306 scoped_ptr<BrowserThreadImpl> io_thread_;
318 scoped_ptr<BrowserThreadImpl> ui_thread_; 307 scoped_ptr<BrowserThreadImpl> ui_thread_;
319 scoped_ptr<media::AudioManager> audio_manager_; 308 scoped_ptr<media::AudioManager> audio_manager_;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 EnableRealDevice(); 392 EnableRealDevice();
404 393
405 Create(); 394 Create();
406 Play(); 395 Play();
407 SimulateError(); 396 SimulateError();
408 Close(); 397 Close();
409 } 398 }
410 399
411 400
412 // TODO(hclam): Add tests for data conversation in low latency mode. 401 // TODO(hclam): Add tests for data conversation in low latency mode.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698