Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / file_manager_browsertest / file_manager / open_zip_files.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  * Tests if we can open and unmount a zip file.
9  * @param {string} path Directory path to be tested.
10  */
11 function zipOpen(path) {
12   var appId;
13   StepsRunner.run([
14     // Add a ZIP file.
15     function() {
16       addEntries(['local', 'drive'], [ENTRIES.zipArchive], this.next);
17     },
18     // Open a window.
19     function(result) {
20       chrome.test.assertTrue(result);
21       openNewWindow(null, path, this.next);
22     },
23     // Wait for going back.
24     function(inAppId) {
25       appId = inAppId;
26       remoteCall.waitForElement(appId, '#detail-table').then(this.next);
27     },
28     function() {
29       remoteCall.waitForFiles(appId, [ENTRIES.zipArchive.getExpectedRow()]).
30           then(this.next);
31     },
32     // Open a file.
33     function(result) {
34       remoteCall.callRemoteTestUtil('openFile',
35                                     appId,
36                                     [ENTRIES.zipArchive.nameText],
37                                     this.next);
38     },
39     // Wait for ZIP contents.
40     function(result) {
41       chrome.test.assertTrue(result);
42       remoteCall.waitForFiles(appId,
43                               [[
44                                 'SUCCESSFULLY_PERFORMED_FAKE_MOUNT.txt',
45                                 '21 bytes',
46                                  'Plain text',
47                                 ''
48                               ]],
49                               {ignoreLastModifiedTime: true}).then(this.next);
50     },
51     // Unmount the zip.
52     function(result) {
53       remoteCall.waitForElement(appId, '.root-eject', this.next).
54           then(this.next);
55     },
56     // Unmount the zip.
57     function(element) {
58       remoteCall.callRemoteTestUtil('fakeMouseClick',
59                                     appId,
60                                     ['.root-eject'],
61                                     this.next);
62     },
63     // Wait for going back.
64     function(result) {
65       chrome.test.assertTrue(result);
66       remoteCall.waitForFiles(appId, [ENTRIES.zipArchive.getExpectedRow()]).
67           then(this.next);
68     },
69     function() {
70       checkIfNoErrorsOccured(this.next);
71     }
72   ]);
73 }
74
75 testcase.zipOpenDownloads = function() {
76   zipOpen(RootPath.DOWNLOADS);
77 };
78
79 testcase.zipOpenDrive = function() {
80   zipOpen(RootPath.DRIVE);
81 };