Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / file_manager_browsertest / file_manager / traverse.js
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.
4
5 'use strict';
6
7 /**
8  * Test utility for traverse tests.
9  * @param {string} path Root path to be traversed.
10  */
11 function traverseDirectories(path) {
12   var appId;
13   StepsRunner.run([
14     // Set up File Manager. Do not add initial files.
15     function() {
16       openNewWindow(null, path, this.next);
17     },
18     // Check the initial view.
19     function(inAppId) {
20       appId = inAppId;
21       remoteCall.waitForElement(appId, '#detail-table').then(this.next);
22     },
23     function() {
24       addEntries(['local', 'drive'], NESTED_ENTRY_SET, this.next);
25     },
26     function(result) {
27       chrome.test.assertTrue(result);
28       remoteCall.waitForFiles(appId, [ENTRIES.directoryA.getExpectedRow()]).
29           then(this.next);
30     },
31     // Open the directory
32     function() {
33       remoteCall.callRemoteTestUtil('openFile', appId, ['A'], this.next);
34     },
35     // Check the contents of current directory.
36     function(result) {
37       chrome.test.assertTrue(result);
38       remoteCall.waitForFiles(appId, [ENTRIES.directoryB.getExpectedRow()]).
39           then(this.next);
40     },
41     // Open the directory
42     function() {
43       remoteCall.callRemoteTestUtil('openFile', appId, ['B'], this.next);
44     },
45     // Check the contents of current directory.
46     function(result) {
47       chrome.test.assertTrue(result);
48       remoteCall.waitForFiles(appId, [ENTRIES.directoryC.getExpectedRow()]).
49           then(this.next);
50     },
51     // Check the error.
52     function() {
53       checkIfNoErrorsOccured(this.next);
54     }
55   ]);
56 }
57
58 /**
59  * Tests to traverse local directories.
60  */
61 testcase.traverseDownloads = function() {
62   traverseDirectories(RootPath.DOWNLOADS);
63 };
64
65 /**
66  * Tests to traverse drive directories.
67  */
68 testcase.traverseDrive = function() {
69   traverseDirectories(RootPath.DRIVE);
70 };