OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 |
| 6 function getStateUninitialized() { |
| 7 chrome.mediaPerceptionPrivate.getState( |
| 8 chrome.test.callbackPass(function(state) { |
| 9 chrome.test.assertEq(state.status, 'UNINITIALIZED'); |
| 10 })); |
| 11 } |
| 12 |
| 13 function setStateRunning() { |
| 14 chrome.mediaPerceptionPrivate.setState({ |
| 15 status: 'RUNNING', |
| 16 deviceContext: 'device_context' |
| 17 }, chrome.test.callbackPass(function(state) { |
| 18 chrome.test.assertEq(state.status, 'RUNNING'); |
| 19 })); |
| 20 } |
| 21 |
| 22 function getStateRunning() { |
| 23 chrome.mediaPerceptionPrivate.getState( |
| 24 chrome.test.callbackPass(function(state) { |
| 25 chrome.test.assertEq(state.status, 'RUNNING'); |
| 26 })); |
| 27 } |
| 28 |
| 29 function setStateUnsettable() { |
| 30 const error = 'Status can only be set to RUNNING and SUSPENDED.'; |
| 31 chrome.mediaPerceptionPrivate.setState({ |
| 32 status: 'UNINITIALIZED' |
| 33 }, chrome.test.callbackFail(error)); |
| 34 chrome.mediaPerceptionPrivate.setState({ |
| 35 status: 'STARTED' |
| 36 }, chrome.test.callbackFail(error)); |
| 37 chrome.mediaPerceptionPrivate.setState({ |
| 38 status: 'TIMEOUT' |
| 39 }, chrome.test.callbackFail(error)); |
| 40 chrome.mediaPerceptionPrivate.setState({ |
| 41 status: 'ERROR' |
| 42 }, chrome.test.callbackFail(error)); |
| 43 } |
| 44 |
| 45 function setStateSuspendedButWithDeviceContextFail() { |
| 46 const error = 'Only provide deviceContext with SetState RUNNING.'; |
| 47 chrome.mediaPerceptionPrivate.setState({ |
| 48 status: 'SUSPENDED', |
| 49 deviceContext: 'device_context' |
| 50 }, chrome.test.callbackFail(error)); |
| 51 } |
| 52 |
| 53 chrome.test.runTests([ |
| 54 getStateUninitialized, |
| 55 setStateRunning, |
| 56 getStateRunning, |
| 57 setStateUnsettable, |
| 58 setStateSuspendedButWithDeviceContextFail]); |
| 59 |
OLD | NEW |