| OLD | NEW |
| 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> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "content/browser/browser_main_loop.h" |
| 18 #include "content/browser/speech/speech_recognition_engine.h" | 19 #include "content/browser/speech/speech_recognition_engine.h" |
| 19 #include "content/browser/speech/speech_recognition_manager_impl.h" | 20 #include "content/browser/speech/speech_recognition_manager_impl.h" |
| 20 #include "content/browser/speech/speech_recognizer_impl.h" | 21 #include "content/browser/speech/speech_recognizer_impl.h" |
| 21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
| 23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 24 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
| 25 #include "content/public/test/content_browser_test.h" | 26 #include "content/public/test/content_browser_test.h" |
| 26 #include "content/public/test/content_browser_test_utils.h" | 27 #include "content/public/test/content_browser_test_utils.h" |
| 27 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // ContentBrowserTest methods. | 113 // ContentBrowserTest methods. |
| 113 void SetUpInProcessBrowserTestFixture() override { | 114 void SetUpInProcessBrowserTestFixture() override { |
| 114 test_audio_input_controller_factory_.set_delegate(this); | 115 test_audio_input_controller_factory_.set_delegate(this); |
| 115 media::AudioInputController::set_factory_for_testing( | 116 media::AudioInputController::set_factory_for_testing( |
| 116 &test_audio_input_controller_factory_); | 117 &test_audio_input_controller_factory_); |
| 117 mock_streaming_server_.reset(new MockGoogleStreamingServer(this)); | 118 mock_streaming_server_.reset(new MockGoogleStreamingServer(this)); |
| 118 streaming_server_state_ = kIdle; | 119 streaming_server_state_ = kIdle; |
| 119 } | 120 } |
| 120 | 121 |
| 121 void SetUpOnMainThread() override { | 122 void SetUpOnMainThread() override { |
| 123 BrowserMainLoop::GetInstance()->InitializeMediaComponentsIfNeeded(); |
| 122 ASSERT_TRUE(SpeechRecognitionManagerImpl::GetInstance()); | 124 ASSERT_TRUE(SpeechRecognitionManagerImpl::GetInstance()); |
| 123 SpeechRecognizerImpl::SetAudioManagerForTesting( | 125 SpeechRecognizerImpl::SetAudioManagerForTesting( |
| 124 new media::MockAudioManager(BrowserThread::GetMessageLoopProxyForThread( | 126 new media::MockAudioManager(BrowserThread::GetMessageLoopProxyForThread( |
| 125 BrowserThread::IO))); | 127 BrowserThread::IO))); |
| 126 } | 128 } |
| 127 | 129 |
| 128 void TearDownOnMainThread() override { | 130 void TearDownOnMainThread() override { |
| 129 SpeechRecognizerImpl::SetAudioManagerForTesting(NULL); | 131 SpeechRecognizerImpl::SetAudioManagerForTesting(NULL); |
| 130 } | 132 } |
| 131 | 133 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 208 |
| 207 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, OneShotRecognition) { | 209 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, OneShotRecognition) { |
| 208 NavigateToURLBlockUntilNavigationsComplete( | 210 NavigateToURLBlockUntilNavigationsComplete( |
| 209 shell(), GetTestUrlFromFragment("oneshot"), 2); | 211 shell(), GetTestUrlFromFragment("oneshot"), 2); |
| 210 | 212 |
| 211 EXPECT_EQ(kClientDisconnected, streaming_server_state()); | 213 EXPECT_EQ(kClientDisconnected, streaming_server_state()); |
| 212 EXPECT_EQ("goodresult1", GetPageFragment()); | 214 EXPECT_EQ("goodresult1", GetPageFragment()); |
| 213 } | 215 } |
| 214 | 216 |
| 215 } // namespace content | 217 } // namespace content |
| OLD | NEW |