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

Side by Side Diff: content/browser/speech/speech_recognition_browsertest.cc

Issue 2832023002: Replace SetUpInProcessBrowserTestFixture/TearDownInProcessBrowserTestFixture usage in content with … (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « content/browser/accessibility/cross_platform_accessibility_browsertest.cc ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <list> 9 #include <list>
10 #include <memory> 10 #include <memory>
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 std::string GetPageFragment() { 104 std::string GetPageFragment() {
105 return shell()->web_contents()->GetLastCommittedURL().ref(); 105 return shell()->web_contents()->GetLastCommittedURL().ref();
106 } 106 }
107 107
108 const StreamingServerState &streaming_server_state() { 108 const StreamingServerState &streaming_server_state() {
109 return streaming_server_state_; 109 return streaming_server_state_;
110 } 110 }
111 111
112 protected: 112 protected:
113 // ContentBrowserTest methods. 113 // ContentBrowserTest methods.
114 void SetUpInProcessBrowserTestFixture() override { 114 void SetUpOnMainThread() override {
115 test_audio_input_controller_factory_.set_delegate(this); 115 test_audio_input_controller_factory_.set_delegate(this);
116 media::AudioInputController::set_factory_for_testing( 116 media::AudioInputController::set_factory_for_testing(
117 &test_audio_input_controller_factory_); 117 &test_audio_input_controller_factory_);
118 mock_streaming_server_.reset(new MockGoogleStreamingServer(this)); 118 mock_streaming_server_.reset(new MockGoogleStreamingServer(this));
119 streaming_server_state_ = kIdle; 119 streaming_server_state_ = kIdle;
120 }
121 120
122 void SetUpOnMainThread() override {
123 ASSERT_TRUE(SpeechRecognitionManagerImpl::GetInstance()); 121 ASSERT_TRUE(SpeechRecognitionManagerImpl::GetInstance());
124 media::AudioManager::StartHangMonitorIfNeeded( 122 media::AudioManager::StartHangMonitorIfNeeded(
125 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); 123 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
126 audio_manager_.reset(new media::MockAudioManager( 124 audio_manager_.reset(new media::MockAudioManager(
127 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); 125 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)));
128 audio_manager_->SetInputStreamParameters( 126 audio_manager_->SetInputStreamParameters(
129 media::AudioParameters::UnavailableDeviceParams()); 127 media::AudioParameters::UnavailableDeviceParams());
130 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); 128 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get());
131 SpeechRecognizerImpl::SetAudioEnvironmentForTesting(audio_system_.get(), 129 SpeechRecognizerImpl::SetAudioEnvironmentForTesting(audio_system_.get(),
132 audio_manager_.get()); 130 audio_manager_.get());
133 } 131 }
134 132
135 void TearDownOnMainThread() override { 133 void TearDownOnMainThread() override {
136 SpeechRecognizerImpl::SetAudioEnvironmentForTesting(nullptr, nullptr); 134 SpeechRecognizerImpl::SetAudioEnvironmentForTesting(nullptr, nullptr);
137 135
138 // Deleting AudioManager on audio thread, 136 // Deleting AudioManager on audio thread,
139 audio_system_.reset(); 137 audio_system_.reset();
140 audio_manager_.reset(); 138 audio_manager_.reset();
141 }
142 139
143 void TearDownInProcessBrowserTestFixture() override {
144 test_audio_input_controller_factory_.set_delegate(nullptr); 140 test_audio_input_controller_factory_.set_delegate(nullptr);
145 mock_streaming_server_.reset(); 141 mock_streaming_server_.reset();
146 } 142 }
147 143
148 private: 144 private:
149 static void FeedSingleBufferToAudioController( 145 static void FeedSingleBufferToAudioController(
150 scoped_refptr<media::TestAudioInputController> controller, 146 scoped_refptr<media::TestAudioInputController> controller,
151 size_t buffer_size, 147 size_t buffer_size,
152 bool fill_with_noise) { 148 bool fill_with_noise) {
153 DCHECK(controller.get()); 149 DCHECK(controller.get());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 215
220 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, OneShotRecognition) { 216 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, OneShotRecognition) {
221 NavigateToURLBlockUntilNavigationsComplete( 217 NavigateToURLBlockUntilNavigationsComplete(
222 shell(), GetTestUrlFromFragment("oneshot"), 2); 218 shell(), GetTestUrlFromFragment("oneshot"), 2);
223 219
224 EXPECT_EQ(kClientDisconnected, streaming_server_state()); 220 EXPECT_EQ(kClientDisconnected, streaming_server_state());
225 EXPECT_EQ("goodresult1", GetPageFragment()); 221 EXPECT_EQ("goodresult1", GetPageFragment());
226 } 222 }
227 223
228 } // namespace content 224 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/accessibility/cross_platform_accessibility_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698