OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/app_list/speech_recognizer.h" | 5 #include "chrome/browser/ui/app_list/speech_recognizer.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 fake_speech_recognition_manager_.reset( | 52 fake_speech_recognition_manager_.reset( |
53 new content::FakeSpeechRecognitionManager()); | 53 new content::FakeSpeechRecognitionManager()); |
54 fake_speech_recognition_manager_->set_should_send_fake_response(true); | 54 fake_speech_recognition_manager_->set_should_send_fake_response(true); |
55 content::SpeechRecognitionManager::SetManagerForTesting( | 55 content::SpeechRecognitionManager::SetManagerForTesting( |
56 fake_speech_recognition_manager_.get()); | 56 fake_speech_recognition_manager_.get()); |
57 mock_speech_delegate_.reset(new MockSpeechRecognizerDelegate()); | 57 mock_speech_delegate_.reset(new MockSpeechRecognizerDelegate()); |
58 test_contents_.reset(content::WebContentsTester::CreateTestWebContents( | 58 test_contents_.reset(content::WebContentsTester::CreateTestWebContents( |
59 browser()->profile(), NULL)); | 59 browser()->profile(), NULL)); |
60 } | 60 } |
61 | 61 |
62 void SetUpCommandLine(base::CommandLine* command_line) override { | |
63 command_line->AppendSwitch(switches::kEnableExperimentalHotwording); | |
64 } | |
65 | |
66 void TearDownOnMainThread() override { | 62 void TearDownOnMainThread() override { |
67 // This puts stuff on the IO loop which needs to be executed. | 63 // This puts stuff on the IO loop which needs to be executed. |
68 test_contents_.reset(); | 64 test_contents_.reset(); |
69 | 65 |
70 // Poor-person's way of ensuring IO loop is idle. | 66 // Poor-person's way of ensuring IO loop is idle. |
71 auto io_loop = content::BrowserThread::UnsafeGetMessageLoopForThread( | 67 auto io_loop = content::BrowserThread::UnsafeGetMessageLoopForThread( |
72 content::BrowserThread::IO); | 68 content::BrowserThread::IO); |
73 ASSERT_TRUE(io_loop); | 69 ASSERT_TRUE(io_loop); |
74 while (!io_loop->IsIdleForTesting()) { | 70 while (!io_loop->IsIdleForTesting()) { |
75 // Sleep for a little bit, allowing the IO thread to obtain any locks | 71 // Sleep for a little bit, allowing the IO thread to obtain any locks |
(...skipping 26 matching lines...) Expand all Loading... |
102 EXPECT_CALL(*mock_speech_delegate_, | 98 EXPECT_CALL(*mock_speech_delegate_, |
103 OnSpeechRecognitionStateChanged(SPEECH_RECOGNITION_READY)) | 99 OnSpeechRecognitionStateChanged(SPEECH_RECOGNITION_READY)) |
104 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 100 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
105 recognizer.Start(); | 101 recognizer.Start(); |
106 run_loop.Run(); | 102 run_loop.Run(); |
107 } | 103 } |
108 | 104 |
109 } // namespace app_list | 105 } // namespace app_list |
110 | 106 |
111 | 107 |
OLD | NEW |