| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Extension Speech Input api test. | 5 // Extension Speech Input api test. |
| 6 // browser_tests --gtest_filter="ExtensionSpeechInputApiTest.*" | 6 // browser_tests --gtest_filter="ExtensionSpeechInputApiTest.*" |
| 7 | 7 |
| 8 chrome.test.runTests([ | 8 chrome.test.runTests([ |
| 9 function testSpeechInputRecognition() { | 9 function testSpeechInputRecognition() { |
| 10 var did_sound_start = false; | 10 var did_sound_start = false; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 chrome.test.assertEq(event.hypotheses[0].utterance, "this is a test"); | 33 chrome.test.assertEq(event.hypotheses[0].utterance, "this is a test"); |
| 34 chrome.test.assertEq(event.hypotheses[0].confidence, 0.99); | 34 chrome.test.assertEq(event.hypotheses[0].confidence, 0.99); |
| 35 | 35 |
| 36 // Ensure no recording is happening after delivering results. | 36 // Ensure no recording is happening after delivering results. |
| 37 chrome.experimental.speechInput.isRecording(function(recording) { | 37 chrome.experimental.speechInput.isRecording(function(recording) { |
| 38 chrome.test.assertNoLastError(); | 38 chrome.test.assertNoLastError(); |
| 39 chrome.test.assertFalse(recording); | 39 chrome.test.assertFalse(recording); |
| 40 | 40 |
| 41 // Stopping should fail since we're in the idle state again. | 41 // Stopping should fail since we're in the idle state again. |
| 42 chrome.experimental.speechInput.stop(function() { | 42 chrome.experimental.speechInput.stop(function() { |
| 43 chrome.test.assertEq(chrome.extension.lastError.message, | 43 chrome.test.assertEq(chrome.runtime.lastError.message, |
| 44 "invalidOperation"); | 44 "invalidOperation"); |
| 45 chrome.test.succeed(); | 45 chrome.test.succeed(); |
| 46 }); | 46 }); |
| 47 }); | 47 }); |
| 48 }); | 48 }); |
| 49 | 49 |
| 50 // Ensure that no errors happened during the recognition. | 50 // Ensure that no errors happened during the recognition. |
| 51 chrome.experimental.speechInput.onError.addListener(function(event) { | 51 chrome.experimental.speechInput.onError.addListener(function(event) { |
| 52 chrome.test.fail(); | 52 chrome.test.fail(); |
| 53 }); | 53 }); |
| 54 | 54 |
| 55 // Recording is not active, start it. | 55 // Recording is not active, start it. |
| 56 chrome.experimental.speechInput.isRecording(function(recording) { | 56 chrome.experimental.speechInput.isRecording(function(recording) { |
| 57 chrome.test.assertNoLastError(); | 57 chrome.test.assertNoLastError(); |
| 58 chrome.test.assertFalse(recording); | 58 chrome.test.assertFalse(recording); |
| 59 chrome.experimental.speechInput.start({}, function() { | 59 chrome.experimental.speechInput.start({}, function() { |
| 60 chrome.test.assertNoLastError(); | 60 chrome.test.assertNoLastError(); |
| 61 }); | 61 }); |
| 62 }); | 62 }); |
| 63 } | 63 } |
| 64 ]); | 64 ]); |
| OLD | NEW |