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

Unified Diff: chrome/test/data/extensions/api_test/desktop_capture/test.js

Issue 1758463002: Add browser test cases for tab and audio share, which are new functionality of desktop share. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve comment Created 4 years, 10 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: chrome/test/data/extensions/api_test/desktop_capture/test.js
diff --git a/chrome/test/data/extensions/api_test/desktop_capture/test.js b/chrome/test/data/extensions/api_test/desktop_capture/test.js
index 48956ed7bc5a951bd4d32a21c44540bdcceef05c..cacaab27c84a1a3829898e1ee742e778e8d1761c 100644
--- a/chrome/test/data/extensions/api_test/desktop_capture/test.js
+++ b/chrome/test/data/extensions/api_test/desktop_capture/test.js
@@ -2,6 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+function onPickerResult(request_audio, audio_track_num, id) {
+ chrome.test.assertEq("string", typeof id);
+ chrome.test.assertTrue(id != "");
+ var video_constraint = { mandatory: { chromeMediaSource: "desktop",
+ chromeMediaSourceId: id } };
+ var audio_constraint = request_audio ? video_constraint : false;
+ navigator.webkitGetUserMedia({
+ audio: audio_constraint,
+ video: video_constraint
+ },
+ function(stream) {
+ if (audio_track_num != null)
+ chrome.test.assertEq(audio_track_num, stream.getAudioTracks().length);
+ chrome.test.succeed();
+ }, chrome.test.fail);
+}
+
+// We can support audio for screen share on Windows. For ChromeOS, it depends
+// on whether USE_CRAS is on or not, thus we disable the check here. We cannot
+// support audio on other platforms.
+var expected_audio_tracks_for_screen_share = 0;
+if (navigator.appVersion.indexOf("Windows") != -1)
+ expected_audio_tracks_for_screen_share = 1;
+else if (navigator.appVersion.indexOf("CrOS") != -1)
+ expected_audio_tracks_for_screen_share = null;
+
chrome.test.runTests([
function emptySourceList() {
chrome.desktopCapture.chooseDesktopMedia(
@@ -31,7 +57,7 @@ chrome.test.runTests([
}));
},
- // For the following two tests FakeDestkopPickerFactory will verify that
+ // For the following four tests FakeDestkopPickerFactory will verify that
// the right set of sources is selected when creating picker model.
function screensOnly() {
chrome.desktopCapture.chooseDesktopMedia(
@@ -43,21 +69,23 @@ chrome.test.runTests([
["window"], chrome.test.callbackPass(function(id) {}));
},
+ function tabOnly() {
+ chrome.desktopCapture.chooseDesktopMedia(
+ ["tab"],
+ chrome.test.succeed);
+ },
+
+ function audioShare() {
+ chrome.desktopCapture.chooseDesktopMedia(
+ ["screen", "window", "tab", "audio"],
+ chrome.test.succeed);
+ },
+
// Show window picker and then get the selected stream using
// getUserMedia().
function chooseMediaAndGetStream() {
- function onPickerResult(id) {
- chrome.test.assertEq("string", typeof id);
- chrome.test.assertTrue(id != "");
- navigator.webkitGetUserMedia({
- audio: false,
- video: { mandatory: { chromeMediaSource: "desktop",
- chromeMediaSourceId: id } }
- }, chrome.test.succeed, chrome.test.fail);
- }
-
chrome.desktopCapture.chooseDesktopMedia(
- ["screen", "window"], onPickerResult);
+ ["screen", "window"], onPickerResult.bind(undefined, false, 0));
},
// Same as above but attempts to specify invalid source id.
@@ -81,5 +109,48 @@ chrome.test.runTests([
chrome.test.assertEq("number", typeof requestId);
chrome.desktopCapture.cancelChooseDesktopMedia(requestId);
chrome.test.succeed();
+ },
+
+ // For the following six, they all request audio track. Based on user's
+ // permission and the source type, it may or may not actually get the audio
+ // track.
+ // In detail:
+ // 1. We cannot support audio for Window share;
+ // 2. We can support audio for Tab share;
+ // 3. We can support audio for Screen share on Windows;
+ // 4. We can support audio for Screen Share on ChromeOS if USE_CRAS is on;
+ // 5. To actually get audio track, user permission is always necessary;
+ // 6. To actually get audio track, getUserMedia() should set audio
+ // constraint.
+ function tabShareWithAudioPermissionGetStream() {
+ chrome.desktopCapture.chooseDesktopMedia(
+ ["tab", "audio"], onPickerResult.bind(undefined, true, 1));
+ },
+
+ function windowShareWithAudioPermissionGetStream() {
+ chrome.desktopCapture.chooseDesktopMedia(
+ ["window", "audio"], onPickerResult.bind(undefined, true, 0));
+ },
+
+ function screenShareWithAudioPermissionGetStream() {
+ chrome.desktopCapture.chooseDesktopMedia(
+ ["screen", "audio"],
+ onPickerResult.bind(undefined, true,
+ expected_audio_tracks_for_screen_share));
+ },
+
+ function tabShareWithoutAudioPermissionGetStream() {
+ chrome.desktopCapture.chooseDesktopMedia(
+ ["tab", "audio"], onPickerResult.bind(undefined, true, 0));
+ },
+
+ function windowShareWithoutAudioPermissionGetStream() {
+ chrome.desktopCapture.chooseDesktopMedia(
+ ["window", "audio"], onPickerResult.bind(undefined, true, 0));
+ },
+
+ function screenShareWithoutAudioPermissionGetStream() {
+ chrome.desktopCapture.chooseDesktopMedia(
+ ["screen", "audio"], onPickerResult.bind(undefined, true, 0));
}
]);
« no previous file with comments | « chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc ('k') | content/public/browser/desktop_media_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698