| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Extension Speech Input api test. | |
| 6 // browser_tests --gtest_filter="ExtensionSpeechInputApiTest.*" | |
| 7 | |
| 8 chrome.test.runTests([ | |
| 9 function testSpeechInputStartStop() { | |
| 10 var count = 0; | |
| 11 | |
| 12 // Recording is not active, start it. | |
| 13 chrome.experimental.speechInput.isRecording(function(recording) { | |
| 14 chrome.test.assertNoLastError(); | |
| 15 chrome.test.assertFalse(recording); | |
| 16 chrome.experimental.speechInput.start({}, started); | |
| 17 }); | |
| 18 | |
| 19 // There should be no error and recording should be active. Stop it. | |
| 20 function started() { | |
| 21 chrome.test.assertNoLastError(); | |
| 22 chrome.experimental.speechInput.isRecording(function(recording) { | |
| 23 chrome.test.assertNoLastError(); | |
| 24 chrome.test.assertTrue(recording); | |
| 25 chrome.experimental.speechInput.stop(stopped); | |
| 26 }); | |
| 27 } | |
| 28 | |
| 29 // There should be no error and recording shouldn't be active again. | |
| 30 // Restart recording if not repeated at least 3 times. | |
| 31 function stopped() { | |
| 32 chrome.test.assertNoLastError(); | |
| 33 chrome.experimental.speechInput.isRecording(function(recording) { | |
| 34 chrome.test.assertNoLastError(); | |
| 35 chrome.test.assertFalse(recording); | |
| 36 if (++count < 3) | |
| 37 chrome.experimental.speechInput.start({}, started); | |
| 38 else | |
| 39 chrome.test.succeed(); | |
| 40 }); | |
| 41 } | |
| 42 }, | |
| 43 | |
| 44 function testSpeechInputInvalidOperation() { | |
| 45 // Calling start once recording should generate an invalid operation error. | |
| 46 chrome.experimental.speechInput.stop(function() { | |
| 47 chrome.test.assertEq(chrome.runtime.lastError.message, | |
| 48 "invalidOperation"); | |
| 49 chrome.experimental.speechInput.start({}, started); | |
| 50 }); | |
| 51 | |
| 52 // Calling stop before recording should generate an invalid operation error. | |
| 53 function started() { | |
| 54 chrome.test.assertNoLastError(); | |
| 55 chrome.experimental.speechInput.start({}, function() { | |
| 56 chrome.test.assertEq(chrome.runtime.lastError.message, | |
| 57 "invalidOperation"); | |
| 58 chrome.test.succeed(); | |
| 59 }); | |
| 60 } | |
| 61 } | |
| 62 ]); | |
| OLD | NEW |