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

Side by Side Diff: content/test/webrtc_audio_device_test.cc

Issue 10449094: Fix client-side phishing detection test flakiness and ChromeOS failure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore the previous sandbox-enabled state Created 8 years, 6 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
« no previous file with comments | « content/test/webrtc_audio_device_test.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/test/webrtc_audio_device_test.h" 5 #include "content/test/webrtc_audio_device_test.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 #include "base/test/test_timeouts.h" 13 #include "base/test/test_timeouts.h"
14 #include "base/win/scoped_com_initializer.h" 14 #include "base/win/scoped_com_initializer.h"
15 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" 15 #include "content/browser/renderer_host/media/audio_input_renderer_host.h"
16 #include "content/browser/renderer_host/media/audio_renderer_host.h" 16 #include "content/browser/renderer_host/media/audio_renderer_host.h"
17 #include "content/browser/renderer_host/media/media_stream_manager.h" 17 #include "content/browser/renderer_host/media/media_stream_manager.h"
18 #include "content/browser/renderer_host/media/mock_media_observer.h" 18 #include "content/browser/renderer_host/media/mock_media_observer.h"
19 #include "content/common/view_messages.h" 19 #include "content/common/view_messages.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/common/content_paths.h" 21 #include "content/public/common/content_paths.h"
22 #include "content/public/test/mock_resource_context.h" 22 #include "content/public/test/mock_resource_context.h"
23 #include "content/public/test/test_browser_thread.h"
23 #include "content/renderer/media/audio_hardware.h" 24 #include "content/renderer/media/audio_hardware.h"
24 #include "content/renderer/media/webrtc_audio_device_impl.h" 25 #include "content/renderer/media/webrtc_audio_device_impl.h"
25 #include "content/renderer/render_process.h" 26 #include "content/renderer/render_process.h"
26 #include "content/renderer/render_thread_impl.h" 27 #include "content/renderer/render_thread_impl.h"
27 #include "content/public/test/test_browser_thread.h" 28 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
28 #include "net/url_request/url_request_test_util.h" 29 #include "net/url_request/url_request_test_util.h"
29 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
31 #include "third_party/webrtc/voice_engine/main/interface/voe_audio_processing.h" 32 #include "third_party/webrtc/voice_engine/main/interface/voe_audio_processing.h"
32 #include "third_party/webrtc/voice_engine/main/interface/voe_base.h" 33 #include "third_party/webrtc/voice_engine/main/interface/voe_base.h"
33 #include "third_party/webrtc/voice_engine/main/interface/voe_file.h" 34 #include "third_party/webrtc/voice_engine/main/interface/voe_file.h"
34 #include "third_party/webrtc/voice_engine/main/interface/voe_network.h" 35 #include "third_party/webrtc/voice_engine/main/interface/voe_network.h"
35 36
36 using base::win::ScopedCOMInitializer; 37 using base::win::ScopedCOMInitializer;
37 using testing::_; 38 using testing::_;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 131
131 // Construct the resource context on the UI thread. 132 // Construct the resource context on the UI thread.
132 resource_context_.reset(new MockResourceContext); 133 resource_context_.reset(new MockResourceContext);
133 134
134 static const char kThreadName[] = "RenderThread"; 135 static const char kThreadName[] = "RenderThread";
135 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE, 136 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE,
136 base::Bind(&WebRTCAudioDeviceTest::InitializeIOThread, 137 base::Bind(&WebRTCAudioDeviceTest::InitializeIOThread,
137 base::Unretained(this), kThreadName)); 138 base::Unretained(this), kThreadName));
138 WaitForIOThreadCompletion(); 139 WaitForIOThreadCompletion();
139 140
141 sandbox_was_enabled_ =
142 RendererWebKitPlatformSupportImpl::SetSandboxEnabledForTesting(false);
140 render_thread_ = new RenderThreadImpl(kThreadName); 143 render_thread_ = new RenderThreadImpl(kThreadName);
141 } 144 }
142 145
143 void WebRTCAudioDeviceTest::TearDown() { 146 void WebRTCAudioDeviceTest::TearDown() {
144 SetAudioUtilCallback(NULL); 147 SetAudioUtilCallback(NULL);
145 148
146 // Run any pending cleanup tasks that may have been posted to the main thread. 149 // Run any pending cleanup tasks that may have been posted to the main thread.
147 ChildProcess::current()->main_thread()->message_loop()->RunAllPending(); 150 ChildProcess::current()->main_thread()->message_loop()->RunAllPending();
148 151
149 // Kick of the cleanup process by closing the channel. This queues up 152 // Kick of the cleanup process by closing the channel. This queues up
150 // OnStreamClosed calls to be executed on the audio thread. 153 // OnStreamClosed calls to be executed on the audio thread.
151 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE, 154 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE,
152 base::Bind(&WebRTCAudioDeviceTest::DestroyChannel, 155 base::Bind(&WebRTCAudioDeviceTest::DestroyChannel,
153 base::Unretained(this))); 156 base::Unretained(this)));
154 WaitForIOThreadCompletion(); 157 WaitForIOThreadCompletion();
155 158
156 // When audio [input] render hosts are notified that the channel has 159 // When audio [input] render hosts are notified that the channel has
157 // been closed, they post tasks to the audio thread to close the 160 // been closed, they post tasks to the audio thread to close the
158 // AudioOutputController and once that's completed, a task is posted back to 161 // AudioOutputController and once that's completed, a task is posted back to
159 // the IO thread to actually delete the AudioEntry for the audio stream. Only 162 // the IO thread to actually delete the AudioEntry for the audio stream. Only
160 // then is the reference to the audio manager released, so we wait for the 163 // then is the reference to the audio manager released, so we wait for the
161 // whole thing to be torn down before we finally uninitialize the io thread. 164 // whole thing to be torn down before we finally uninitialize the io thread.
162 WaitForAudioManagerCompletion(); 165 WaitForAudioManagerCompletion();
163 166
164 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE, 167 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE,
165 base::Bind(&WebRTCAudioDeviceTest::UninitializeIOThread, 168 base::Bind(&WebRTCAudioDeviceTest::UninitializeIOThread,
166 base::Unretained((this)))); 169 base::Unretained((this))));
167 WaitForIOThreadCompletion(); 170 WaitForIOThreadCompletion();
168 mock_process_.reset(); 171 mock_process_.reset();
172 RendererWebKitPlatformSupportImpl::SetSandboxEnabledForTesting(
173 sandbox_was_enabled_);
169 } 174 }
170 175
171 bool WebRTCAudioDeviceTest::Send(IPC::Message* message) { 176 bool WebRTCAudioDeviceTest::Send(IPC::Message* message) {
172 return channel_->Send(message); 177 return channel_->Send(message);
173 } 178 }
174 179
175 void WebRTCAudioDeviceTest::SetAudioUtilCallback(AudioUtilInterface* callback) { 180 void WebRTCAudioDeviceTest::SetAudioUtilCallback(AudioUtilInterface* callback) {
176 // Invalidate any potentially cached values since the new callback should 181 // Invalidate any potentially cached values since the new callback should
177 // be used for those queries. 182 // be used for those queries.
178 audio_hardware::ResetCache(); 183 audio_hardware::ResetCache();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 WebRTCTransportImpl::~WebRTCTransportImpl() {} 354 WebRTCTransportImpl::~WebRTCTransportImpl() {}
350 355
351 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { 356 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) {
352 return network_->ReceivedRTPPacket(channel, data, len); 357 return network_->ReceivedRTPPacket(channel, data, len);
353 } 358 }
354 359
355 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, 360 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data,
356 int len) { 361 int len) {
357 return network_->ReceivedRTCPPacket(channel, data, len); 362 return network_->ReceivedRTCPPacket(channel, data, len);
358 } 363 }
OLDNEW
« no previous file with comments | « content/test/webrtc_audio_device_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698