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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 ASSERT_TRUE(io_loop); | 66 ASSERT_TRUE(io_loop); |
67 while (!io_loop->IsIdleForTesting()) { | 67 while (!io_loop->IsIdleForTesting()) { |
68 // Sleep for a little bit, allowing the IO thread to obtain any locks | 68 // Sleep for a little bit, allowing the IO thread to obtain any locks |
69 // taken by IsIdleForTesting(). Without this sleep, this loop may livelock | 69 // taken by IsIdleForTesting(). Without this sleep, this loop may livelock |
70 // the message loop causing the test to fail. | 70 // the message loop causing the test to fail. |
71 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); | 71 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 protected: | 75 protected: |
76 scoped_ptr<content::FakeSpeechRecognitionManager> | 76 std::unique_ptr<content::FakeSpeechRecognitionManager> |
77 fake_speech_recognition_manager_; | 77 fake_speech_recognition_manager_; |
78 scoped_ptr<MockSpeechRecognizerDelegate> mock_speech_delegate_; | 78 std::unique_ptr<MockSpeechRecognizerDelegate> mock_speech_delegate_; |
79 | 79 |
80 private: | 80 private: |
81 DISALLOW_COPY_AND_ASSIGN(AppListSpeechRecognizerBrowserTest); | 81 DISALLOW_COPY_AND_ASSIGN(AppListSpeechRecognizerBrowserTest); |
82 }; | 82 }; |
83 | 83 |
84 IN_PROC_BROWSER_TEST_F(AppListSpeechRecognizerBrowserTest, RecognizeSpeech) { | 84 IN_PROC_BROWSER_TEST_F(AppListSpeechRecognizerBrowserTest, RecognizeSpeech) { |
85 SpeechRecognizer recognizer(mock_speech_delegate_->GetWeakPtr(), | 85 SpeechRecognizer recognizer(mock_speech_delegate_->GetWeakPtr(), |
86 browser()->profile()->GetRequestContext(), | 86 browser()->profile()->GetRequestContext(), |
87 "en"); | 87 "en"); |
88 | 88 |
89 base::RunLoop run_loop; | 89 base::RunLoop run_loop; |
90 EXPECT_CALL(*mock_speech_delegate_, | 90 EXPECT_CALL(*mock_speech_delegate_, |
91 OnSpeechResult(base::ASCIIToUTF16("Pictures of the moon"), true)); | 91 OnSpeechResult(base::ASCIIToUTF16("Pictures of the moon"), true)); |
92 EXPECT_CALL(*mock_speech_delegate_, | 92 EXPECT_CALL(*mock_speech_delegate_, |
93 OnSpeechRecognitionStateChanged(SPEECH_RECOGNITION_READY)) | 93 OnSpeechRecognitionStateChanged(SPEECH_RECOGNITION_READY)) |
94 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 94 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
95 recognizer.Start(nullptr); | 95 recognizer.Start(nullptr); |
96 run_loop.Run(); | 96 run_loop.Run(); |
97 } | 97 } |
98 | 98 |
99 } // namespace app_list | 99 } // namespace app_list |
100 | 100 |
101 | 101 |
OLD | NEW |