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

Unified Diff: extensions/test/data/media_perception_private/state/runtest.js

Issue 2858353002: MediaPerceptionPrivate API impl and testing. (Closed)
Patch Set: Addressed comments and all tests passing. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: extensions/test/data/media_perception_private/state/runtest.js
diff --git a/extensions/test/data/media_perception_private/state/runtest.js b/extensions/test/data/media_perception_private/state/runtest.js
new file mode 100644
index 0000000000000000000000000000000000000000..0c65c52511525abb4a9ffee313a6b11802fd212c
--- /dev/null
+++ b/extensions/test/data/media_perception_private/state/runtest.js
@@ -0,0 +1,53 @@
+// 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.
+
+
tbarzic 2017/05/17 21:04:42 remove extra new line
Luke Sorenson 2017/05/17 23:07:49 Done.
+function getStateUninitialized() {
+ chrome.mediaPerceptionPrivate.getState(
+ chrome.test.callbackPass(function(state) {
+ chrome.test.assertEq(state.status, 'UNINITIALIZED');
+ }));
+}
+
+function setStateRunning() {
+ chrome.mediaPerceptionPrivate.setState({
+ status: 'RUNNING',
+ deviceContext: 'device_context'
+ }, chrome.test.callbackPass(function(state) {
+ chrome.test.assertEq(state.status, 'RUNNING');
+ }));
+}
+
+function getStateRunning() {
+ chrome.mediaPerceptionPrivate.getState(
+ chrome.test.callbackPass(function(state) {
+ chrome.test.assertEq(state.status, 'RUNNING');
+ }));
+}
+
+function setStateUnsettable() {
+ const error = 'Status can only be set to RUNNING and SUSPENDED.';
+ chrome.mediaPerceptionPrivate.setState({
+ status: 'UNINITIALIZED'
+ }, chrome.test.callbackFail(error));
+ chrome.mediaPerceptionPrivate.setState({
+ status: 'STARTED'
+ }, chrome.test.callbackFail(error));
+}
+
+function setStateSuspendedButWithDeviceContextFail() {
+ const error = 'Only provide deviceContext with SetState RUNNING.';
+ chrome.mediaPerceptionPrivate.setState({
+ status: 'SUSPENDED',
+ deviceContext: 'device_context'
+ }, chrome.test.callbackFail(error));
+}
+
+chrome.test.runTests([
+ getStateUninitialized,
+ setStateRunning,
+ getStateRunning,
+ setStateUnsettable,
+ setStateSuspendedButWithDeviceContextFail]);
+

Powered by Google App Engine
This is Rietveld 408576698