Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / file_manager_browsertest / open_special_types.js
1 // Copyright (c) 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 the gallery shows up for the selected image and that the image
9  * gets displayed.
10  *
11  * @param {string} path Directory path to be tested.
12  */
13 function galleryOpen(path) {
14   var appId;
15   StepsRunner.run([
16     function() {
17       setupAndWaitUntilReady(null, path, this.next);
18     },
19     // Resize the window to desired dimensions to avoid flakyness.
20     function(inAppId) {
21       appId = inAppId;
22       callRemoteTestUtil('resizeWindow',
23                          appId,
24                          [480, 480],
25                          this.next);
26     },
27     // Select the image.
28     function(result) {
29       chrome.test.assertTrue(result);
30       callRemoteTestUtil('openFile',
31                          appId,
32                          ['My Desktop Background.png'],
33                          this.next);
34     },
35     // Wait for the image in the gallery's screen image.
36     function(result) {
37       chrome.test.assertTrue(result);
38       waitForElement(appId,
39                      '.gallery .content canvas.image',
40                      'iframe.overlay-pane').then(this.next);
41     },
42     // Verify the gallery's screen image.
43     function(element) {
44       chrome.test.assertEq('480', element.attributes.width);
45       chrome.test.assertEq('360', element.attributes.height);
46       // Get the full-resolution image.
47       waitForElement(appId,
48                          '.gallery .content canvas.fullres',
49                          'iframe.overlay-pane').then(this.next);
50     },
51     // Verify the gallery's full resolution image.
52     function(element) {
53       chrome.test.assertEq('800', element.attributes.width);
54       chrome.test.assertEq('600', element.attributes.height);
55       checkIfNoErrorsOccured(this.next);
56     }
57   ]);
58 }
59
60 /**
61  * Tests if we can open and unmount a zip file.
62  * @param {string} path Directory path to be tested.
63  */
64 function zipOpen(path) {
65   var appId;
66   StepsRunner.run([
67     // Add a ZIP file.
68     function() {
69       addEntries(['local', 'drive'], [ENTRIES.zipArchive], this.next);
70     },
71     // Open a window.
72     function(result) {
73       chrome.test.assertTrue(result);
74       openNewWindow(null, path, this.next);
75     },
76     // Wait for going back.
77     function(inAppId) {
78       appId = inAppId;
79       waitForElement(appId, '#detail-table').then(this.next);
80     },
81     function() {
82       waitForFiles(appId, [ENTRIES.zipArchive.getExpectedRow()]).
83           then(this.next);
84     },
85     // Open a file.
86     function(result) {
87       callRemoteTestUtil('openFile',
88                          appId,
89                          [ENTRIES.zipArchive.nameText],
90                          this.next);
91     },
92     // Wait for ZIP contents.
93     function(result) {
94       chrome.test.assertTrue(result);
95       waitForFiles(appId,
96                    [[
97                      'SUCCESSFULLY_PERFORMED_FAKE_MOUNT.txt',
98                      '21 bytes',
99                      'Plain text',
100                      ''
101                    ]],
102                    {ignoreLastModifiedTime: true}).then(this.next);
103     },
104     // Unmount the zip.
105     function(result) {
106       waitForElement(appId, '.root-eject', this.next).then(this.next);
107     },
108     // Unmount the zip.
109     function(element) {
110       callRemoteTestUtil('fakeMouseClick',
111                          appId,
112                          ['.root-eject'],
113                          this.next);
114     },
115     // Wait for going back.
116     function(result) {
117       chrome.test.assertTrue(result);
118       waitForFiles(appId, [ENTRIES.zipArchive.getExpectedRow()]).
119           then(this.next);
120     },
121     function() {
122       checkIfNoErrorsOccured(this.next);
123     }
124   ]);
125 }
126
127 testcase.galleryOpenDownloads = function() {
128   galleryOpen(RootPath.DOWNLOADS);
129 };
130
131 testcase.galleryOpenDrive = function() {
132   galleryOpen(RootPath.DRIVE);
133 };
134
135 testcase.zipOpenDownloads = function() {
136   zipOpen(RootPath.DOWNLOADS);
137 };
138
139 testcase.zipOpenDrive = function() {
140   zipOpen(RootPath.DRIVE);
141 };