Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/media_perception_private/state/runtest.js |
| diff --git a/chrome/test/data/extensions/api_test/media_perception_private/state/runtest.js b/chrome/test/data/extensions/api_test/media_perception_private/state/runtest.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a268f7e52eba58004d27fd9606f9f100160c138f |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/media_perception_private/state/runtest.js |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +let kStatusEnum = 'RUNNING' |
|
tbarzic
2017/05/11 00:38:27
can you just create new state object in tests?
Luke Sorenson
2017/05/11 23:57:58
Done.
|
| +var state = { status: kStatusEnum } |
| + |
| +function setState() { |
| + state.deviceContext = 'Just a string.'; |
|
tbarzic
2017/05/11 00:38:27
can you set this to something little more meaningf
Luke Sorenson
2017/05/11 23:57:58
Done.
|
| + chrome.mediaPerceptionPrivate.setState( |
| + state, chrome.test.callbackPass(function(state) { |
| + chrome.test.assertEq(state.status, kStatusEnum); |
| + })); |
| +} |
| + |
| +function getState() { |
| + chrome.mediaPerceptionPrivate.getState( |
| + chrome.test.callbackPass(function(state) { |
| + chrome.test.assertEq(state.status, kStatusEnum); |
| + })); |
| +} |
| + |
| +function setStateUnsettable() { |
| + state.status = 'UNINITIALIZED'; |
|
tbarzic
2017/05/11 00:38:27
what about other states?
Luke Sorenson
2017/05/11 23:57:58
Done.
|
| + const error = 'Status can only be set to RUNNING and SUSPENDED.'; |
| + chrome.mediaPerceptionPrivate.setState( |
| + state, chrome.test.callbackFail(error)); |
| +} |
| + |
| +function setStateSuspendedButWithDeviceContextFail() { |
| + state.status = 'SUSPENDED'; |
| + state.deviceContext = 'Just a string.'; |
| + const error = 'Only provide deviceContext with SetState RUNNING.'; |
|
tbarzic
2017/05/11 00:38:27
can you test there's an error if the current state
Luke Sorenson
2017/05/11 23:57:58
That isn't an error case. Setting the desired stat
|
| + chrome.mediaPerceptionPrivate.setState( |
| + state, chrome.test.callbackFail(error)); |
| +} |
| + |
| +chrome.test.runTests([ |
| + setState, |
| + getState, |
| + setStateUnsettable, |
| + setStateSuspendedButWithDeviceContextFail]); |
| + |