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 * Shows the grid view and checks the label texts of entries.
10 * @param {string} rootPath Root path to be used as a default current directory
11 * during initialization. Can be null, for no default path.
12 * @param {Array.<TestEntryInfo>} expectedSet Set of entries that are expected
13 * to appear in the grid view.
14 * @return {Promise} Promise to be fulfilled or rejected depending on the test
17 function showGridView(rootPath, expectedSet) {
18 var expectedLabels = expectedSet.map(function(entryInfo) {
19 return entryInfo.nameText;
21 var setupPromise = setupAndWaitUntilReady(null, rootPath);
22 return setupPromise.then(function(windowId) {
23 // Click the grid view button.
24 var clickedPromise = remoteCall.waitForElement(windowId, '#view-button').
26 return remoteCall.callRemoteTestUtil(
27 'fakeEvent', windowId, ['#view-button', 'click']);
30 // Compare the grid labels of the entries.
31 return clickedPromise.then(function() {
32 return repeatUntil(function() {
33 var labelsPromise = remoteCall.callRemoteTestUtil(
36 ['grid:not([hidden]) .thumbnail-item .entry-name']);
37 return labelsPromise.then(function(labels) {
38 var actualLabels = labels.map(function(label) {
41 if (chrome.test.checkDeepEq(expectedLabels, actualLabels))
44 'Failed to compare the grid lables, expected: %j, actual %j.',
54 * Tests to show grid view on a local directory.
56 testcase.showGridViewDownloads = function() {
57 testPromise(showGridView(
58 RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET));
62 * Tests to show grid view on a drive directory.
64 testcase.showGridViewDrive = function() {
65 testPromise(showGridView(
66 RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET));