| 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 testSpeechInputRecognitionError() { | 9 function testSpeechInputRecognitionError() { |
| 10 // Results should never be provided in this test case. | 10 // Results should never be provided in this test case. |
| 11 chrome.experimental.speechInput.onResult.addListener(function(event) { | 11 chrome.experimental.speechInput.onResult.addListener(function(event) { |
| 12 chrome.test.fail(); | 12 chrome.test.fail(); |
| 13 }); | 13 }); |
| 14 | 14 |
| 15 // Ensure the recognition error happens. | 15 // Ensure the recognition error happens. |
| 16 chrome.experimental.speechInput.onError.addListener(function(error) { | 16 chrome.experimental.speechInput.onError.addListener(function(error) { |
| 17 chrome.test.assertEq(error.code, "networkError"); | 17 chrome.test.assertEq(error.code, "networkError"); |
| 18 | 18 |
| 19 // No recording should be happening after an error. | 19 // No recording should be happening after an error. |
| 20 chrome.experimental.speechInput.isRecording(function(recording) { | 20 chrome.experimental.speechInput.isRecording(function(recording) { |
| 21 chrome.test.assertNoLastError(); | 21 chrome.test.assertNoLastError(); |
| 22 chrome.test.assertFalse(recording); | 22 chrome.test.assertFalse(recording); |
| 23 | 23 |
| 24 // Stopping should fail since we're in the idle state again. | 24 // Stopping should fail since we're in the idle state again. |
| 25 chrome.experimental.speechInput.stop(function() { | 25 chrome.experimental.speechInput.stop(function() { |
| 26 chrome.test.assertEq(chrome.extension.lastError.message, | 26 chrome.test.assertEq(chrome.runtime.lastError.message, |
| 27 "invalidOperation"); | 27 "invalidOperation"); |
| 28 chrome.test.succeed(); | 28 chrome.test.succeed(); |
| 29 }); | 29 }); |
| 30 }); | 30 }); |
| 31 }); | 31 }); |
| 32 | 32 |
| 33 // Start recording. | 33 // Start recording. |
| 34 chrome.experimental.speechInput.start({}, function() { | 34 chrome.experimental.speechInput.start({}, function() { |
| 35 chrome.test.assertNoLastError(); | 35 chrome.test.assertNoLastError(); |
| 36 }); | 36 }); |
| 37 } | 37 } |
| 38 ]); | 38 ]); |
| OLD | NEW |