Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / desktop_capture / test.js
blob48956ed7bc5a951bd4d32a21c44540bdcceef05c
1 // Copyright 2013 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.
5 chrome.test.runTests([
6   function emptySourceList() {
7     chrome.desktopCapture.chooseDesktopMedia(
8         [],
9         chrome.test.callback(function(id) {
10           chrome.test.assertEq("undefined", typeof id);
11         }, "At least one source type must be specified."));
12   },
14   // The prompt is canceled.
15   function pickerUiCanceled() {
16     chrome.desktopCapture.chooseDesktopMedia(
17         ["screen", "window"],
18         chrome.test.callbackPass(function(id) {
19           chrome.test.assertEq("string", typeof id);
20           chrome.test.assertTrue(id == "");
21         }));
22   },
24   // A source is chosen.
25   function chooseMedia() {
26     chrome.desktopCapture.chooseDesktopMedia(
27         ["screen", "window"],
28         chrome.test.callbackPass(function(id) {
29           chrome.test.assertEq("string", typeof id);
30           chrome.test.assertTrue(id != "");
31         }));
32   },
34   // For the following two tests FakeDestkopPickerFactory will verify that
35   // the right set of sources is selected when creating picker model.
36   function screensOnly() {
37     chrome.desktopCapture.chooseDesktopMedia(
38         ["screen"], chrome.test.callbackPass(function(id) {}));
39   },
41   function windowsOnly() {
42     chrome.desktopCapture.chooseDesktopMedia(
43         ["window"], chrome.test.callbackPass(function(id) {}));
44   },
46   // Show window picker and then get the selected stream using
47   // getUserMedia().
48   function chooseMediaAndGetStream() {
49     function onPickerResult(id) {
50       chrome.test.assertEq("string", typeof id);
51       chrome.test.assertTrue(id != "");
52       navigator.webkitGetUserMedia({
53         audio: false,
54         video: { mandatory: { chromeMediaSource: "desktop",
55                               chromeMediaSourceId: id } }
56       }, chrome.test.succeed, chrome.test.fail);
57     }
59     chrome.desktopCapture.chooseDesktopMedia(
60         ["screen", "window"], onPickerResult);
61   },
63   // Same as above but attempts to specify invalid source id.
64   function chooseMediaAndTryGetStreamWithInvalidId() {
65     function onPickerResult(id) {
66       navigator.webkitGetUserMedia({
67         audio: false,
68         video: { mandatory: { chromeMediaSource: "desktop",
69                               chromeMediaSourceId: id + "x" } }
70       }, chrome.test.fail, chrome.test.succeed);
71     }
73     chrome.desktopCapture.chooseDesktopMedia(
74         ["screen", "window"], onPickerResult);
75   },
77   function cancelDialog() {
78     var requestId = chrome.desktopCapture.chooseDesktopMedia(
79         ["screen", "window"],
80         chrome.test.fail);
81     chrome.test.assertEq("number", typeof requestId);
82     chrome.desktopCapture.cancelChooseDesktopMedia(requestId);
83     chrome.test.succeed();
84   }
85 ]);