1 // Copyright 2014 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.
8 * Extension ID of gallery app.
12 var GALLERY_APP_ID = 'nlkncpkkdoccmpiclbokaimcnedabhhm';
14 var gallery = new RemoteCallGallery(GALLERY_APP_ID);
17 * Launches the gallery with the given entries.
19 * @param {string} testVolumeName Test volume name passed to the addEntries
20 * function. Either 'drive' or 'local'.
21 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
22 * @param {Array<TestEntryInfo>} entries Entries to be parepared and passed to
24 * @param {Array<TestEntryInfo>=} opt_selected Entries to be selected. Should
25 * be a sub-set of the entries argument.
26 * @return {Promise} Promise to be fulfilled with the data of the main element
29 function launch(testVolumeName, volumeType, entries, opt_selected) {
30 var entriesPromise = addEntries([testVolumeName], entries).then(function() {
31 var selectedEntries = opt_selected || entries;
32 var selectedEntryNames =
33 selectedEntries.map(function(entry) { return entry.nameText; });
34 return gallery.callRemoteTestUtil(
35 'getFilesUnderVolume', null, [volumeType, selectedEntryNames]);
40 return entriesPromise.then(function(result) {
42 return gallery.callRemoteTestUtil('openGallery', null, [urls]);
43 }).then(function(windowId) {
44 chrome.test.assertTrue(!!windowId);
46 return gallery.waitForElement(appId, 'div.gallery');
47 }).then(function(args) {
57 * Namespace for test cases.
61 // Ensure the test cases are loaded.
62 window.addEventListener('load', function() {
64 // Check for the guest mode.
66 chrome.test.sendMessage(
67 JSON.stringify({name: 'isInGuestMode'}), steps.shift());
69 // Obtain the test case name.
71 if (JSON.parse(result) != chrome.extension.inIncognitoContext)
73 chrome.test.sendMessage(
74 JSON.stringify({name: 'getRootPaths'}), steps.shift());
76 // Obtain the root entry paths.
78 var roots = JSON.parse(result);
79 RootPath.DOWNLOADS = roots.downloads;
80 RootPath.DRIVE = roots.drive;
81 chrome.test.sendMessage(
82 JSON.stringify({name: 'getTestName'}), steps.shift());
85 function(testCaseName) {
86 var targetTest = testcase[testCaseName];
88 chrome.test.fail(testCaseName + ' is not found.');
91 // Specify the name of test to the test system.
92 targetTest.generatedName = testCaseName;
93 chrome.test.runTests([function() {
94 return testPromiseAndApps(targetTest(), [gallery]);