Upstream version 8.37.180.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / file_manager_browsertest / file_manager / restore_prefs.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 restoring the sorting order.
9  */
10 testcase.restoreSortColumn = function() {
11   var appId;
12   var EXPECTED_FILES = TestEntryInfo.getExpectedRows([
13     ENTRIES.world,
14     ENTRIES.photos,
15     ENTRIES.desktop,
16     ENTRIES.hello,
17     ENTRIES.beautiful
18   ]);
19   StepsRunner.run([
20     // Set up File Manager.
21     function() {
22       setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
23     },
24     // Sort by name.
25     function(inAppId) {
26       appId = inAppId;
27       callRemoteTestUtil('fakeMouseClick',
28                          appId,
29                          ['.table-header-cell:nth-of-type(1)'],
30                          this.next);
31     },
32     // Check the sorted style of the header.
33     function() {
34       waitForElement(appId, '.table-header-sort-image-asc').then(this.next);
35     },
36     // Sort by name.
37     function() {
38       callRemoteTestUtil('fakeMouseClick',
39                          appId,
40                          ['.table-header-cell:nth-of-type(1)'],
41                          this.next);
42     },
43     // Check the sorted style of the header.
44     function() {
45       waitForElement(appId, '.table-header-sort-image-desc').
46           then(this.next);
47     },
48     // Check the sorted files.
49     function() {
50       waitForFiles(appId, EXPECTED_FILES, {orderCheck: true}).then(this.next);
51     },
52     // Open another window, where the sorted column should be restored.
53     function() {
54       setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
55     },
56     // Check the sorted style of the header.
57     function(inAppId) {
58       appId = inAppId;
59       waitForElement(appId, '.table-header-sort-image-desc').
60           then(this.next);
61     },
62     // Check the sorted files.
63     function() {
64       waitForFiles(appId, EXPECTED_FILES, {orderCheck: true}).then(this.next);
65     },
66     // Check the error.
67     function() {
68       checkIfNoErrorsOccured(this.next);
69     }
70   ]);
71 };
72
73 /**
74  * Tests restoring the current view (the file list or the thumbnail grid).
75  */
76 testcase.restoreCurrentView = function() {
77   var appId;
78   StepsRunner.run([
79     // Set up File Manager.
80     function() {
81       setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
82     },
83     // Check the initial view.
84     function(inAppId) {
85       appId = inAppId;
86       waitForElement(appId, '.thumbnail-grid[hidden]').then(this.next);
87     },
88     // Opens the gear menu.
89     function() {
90       callRemoteTestUtil('fakeMouseClick',
91                          appId,
92                          ['#gear-button'],
93                          this.next);
94     },
95     // Change the current view.
96     function() {
97       callRemoteTestUtil('fakeMouseClick',
98                          appId,
99                          ['#thumbnail-view'],
100                          this.next);
101     },
102     // Check the new current view.
103     function(result) {
104       chrome.test.assertTrue(result);
105       waitForElement(appId, '.detail-table[hidden]').then(this.next);
106     },
107     // Open another window, where the current view is restored.
108     function() {
109       openNewWindow(null, RootPath.DOWNLOADS, this.next);
110     },
111     // Check the current view.
112     function(inAppId) {
113       appId = inAppId;
114       waitForElement(appId, '.detail-table[hidden]').then(this.next);
115     },
116     // Check the error.
117     function() {
118       checkIfNoErrorsOccured(this.next);
119     }
120   ]);
121 };