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.
6 function emptySourceList() {
7 chrome
.desktopCapture
.chooseDesktopMedia(
9 chrome
.test
.callback(function(id
) {
10 chrome
.test
.assertEq("undefined", typeof id
);
11 }, "At least one source type must be specified."));
14 // The prompt is canceled.
15 function pickerUiCanceled() {
16 chrome
.desktopCapture
.chooseDesktopMedia(
18 chrome
.test
.callbackPass(function(id
) {
19 chrome
.test
.assertEq("string", typeof id
);
20 chrome
.test
.assertTrue(id
== "");
24 // A source is chosen.
25 function chooseMedia() {
26 chrome
.desktopCapture
.chooseDesktopMedia(
28 chrome
.test
.callbackPass(function(id
) {
29 chrome
.test
.assertEq("string", typeof id
);
30 chrome
.test
.assertTrue(id
!= "");
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
) {}));
41 function windowsOnly() {
42 chrome
.desktopCapture
.chooseDesktopMedia(
43 ["window"], chrome
.test
.callbackPass(function(id
) {}));
46 // Show window picker and then get the selected stream using
48 function chooseMediaAndGetStream() {
49 function onPickerResult(id
) {
50 chrome
.test
.assertEq("string", typeof id
);
51 chrome
.test
.assertTrue(id
!= "");
52 navigator
.webkitGetUserMedia({
54 video
: { mandatory
: { chromeMediaSource
: "desktop",
55 chromeMediaSourceId
: id
} }
56 }, chrome
.test
.succeed
, chrome
.test
.fail
);
59 chrome
.desktopCapture
.chooseDesktopMedia(
60 ["screen", "window"], onPickerResult
);
63 // Same as above but attempts to specify invalid source id.
64 function chooseMediaAndTryGetStreamWithInvalidId() {
65 function onPickerResult(id
) {
66 navigator
.webkitGetUserMedia({
68 video
: { mandatory
: { chromeMediaSource
: "desktop",
69 chromeMediaSourceId
: id
+ "x" } }
70 }, chrome
.test
.fail
, chrome
.test
.succeed
);
73 chrome
.desktopCapture
.chooseDesktopMedia(
74 ["screen", "window"], onPickerResult
);
77 function cancelDialog() {
78 var requestId
= chrome
.desktopCapture
.chooseDesktopMedia(
81 chrome
.test
.assertEq("number", typeof requestId
);
82 chrome
.desktopCapture
.cancelChooseDesktopMedia(requestId
);
83 chrome
.test
.succeed();