Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: chrome/test/data/extensions/api_test/speech_input/recognition/test.js

Issue 14230005: Remove all code for chrome.experimental.speechInput extension API (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 testSpeechInputRecognition() {
10 var did_sound_start = false;
11 var did_sound_end = false;
12
13 // Check that sound starts once and before ending.
14 chrome.experimental.speechInput.onSoundStart.addListener(function() {
15 chrome.test.assertFalse(did_sound_start);
16 chrome.test.assertFalse(did_sound_end);
17 did_sound_start = true;
18 });
19
20 // Check that sounds ends once and after starting.
21 chrome.experimental.speechInput.onSoundEnd.addListener(function() {
22 chrome.test.assertTrue(did_sound_start);
23 chrome.test.assertFalse(did_sound_end);
24 did_end_sound = true;
25 });
26
27 // Check that both sound events happened and that the given results
28 // match the expected ones.
29 chrome.experimental.speechInput.onResult.addListener(function(event) {
30 chrome.test.assertTrue(did_sound_start);
31 chrome.test.assertTrue(did_end_sound);
32 chrome.test.assertEq(event.hypotheses.length, 1);
33 chrome.test.assertEq(event.hypotheses[0].utterance, "this is a test");
34 chrome.test.assertEq(event.hypotheses[0].confidence, 0.99);
35
36 // Ensure no recording is happening after delivering results.
37 chrome.experimental.speechInput.isRecording(function(recording) {
38 chrome.test.assertNoLastError();
39 chrome.test.assertFalse(recording);
40
41 // Stopping should fail since we're in the idle state again.
42 chrome.experimental.speechInput.stop(function() {
43 chrome.test.assertEq(chrome.runtime.lastError.message,
44 "invalidOperation");
45 chrome.test.succeed();
46 });
47 });
48 });
49
50 // Ensure that no errors happened during the recognition.
51 chrome.experimental.speechInput.onError.addListener(function(event) {
52 chrome.test.fail();
53 });
54
55 // Recording is not active, start it.
56 chrome.experimental.speechInput.isRecording(function(recording) {
57 chrome.test.assertNoLastError();
58 chrome.test.assertFalse(recording);
59 chrome.experimental.speechInput.start({}, function() {
60 chrome.test.assertNoLastError();
61 });
62 });
63 }
64 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698