| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Extension ID of Files.app. | 8 * Extension ID of Files.app. |
| 9 * @type {string} | 9 * @type {string} |
| 10 * @const | 10 * @const |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } else { | 108 } else { |
| 109 return result; | 109 return result; |
| 110 } | 110 } |
| 111 }); | 111 }); |
| 112 }; | 112 }; |
| 113 return step(); | 113 return step(); |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 /** | 116 /** |
| 117 * Waits until a window having the given ID prefix appears. | 117 * Waits until a window having the given ID prefix appears. |
| 118 * @param {string} appIdPrefix ID prefix of the requested window. | 118 * @param {string} windowIdPrefix ID prefix of the requested window. |
| 119 * @param {Promise} promise Promise to be fulfilled with a found window's ID. | 119 * @return {Promise} promise Promise to be fulfilled with a found window's ID. |
| 120 */ | 120 */ |
| 121 function waitForWindow(windowIdPrefix) { | 121 function waitForWindow(windowIdPrefix) { |
| 122 return repeatUntil(function() { | 122 return repeatUntil(function() { |
| 123 return callRemoteTestUtil('getWindows', null, []).then(function(windows) { | 123 return callRemoteTestUtil('getWindows', null, []).then(function(windows) { |
| 124 for (var id in windows) { | 124 for (var id in windows) { |
| 125 if (id.indexOf(windowIdPrefix) === 0) | 125 if (id.indexOf(windowIdPrefix) === 0) |
| 126 return id; | 126 return id; |
| 127 } | 127 } |
| 128 return pending('Window with the prefix %s is not found.', windowIdPrefix); | 128 return pending('Window with the prefix %s is not found.', windowIdPrefix); |
| 129 }); | 129 }); |
| 130 }); | 130 }); |
| 131 } | 131 } |
| 132 | 132 |
| 133 /** | 133 /** |
| 134 * Closes a window and waits until the window is closed. |
| 135 * |
| 136 * @param {string} windowId ID of the window to close. |
| 137 * @return {Promise} promise Promise to be fulfilled with the result (true: |
| 138 * success, false: failed). |
| 139 */ |
| 140 function closeWindowAndWait(windowId) { |
| 141 // Closes the window. |
| 142 return callRemoteTestUtil('closeWindow', null, [windowId]).then( |
| 143 function(result) { |
| 144 // Returns false when the closing is failed. |
| 145 if (!result) |
| 146 return false; |
| 147 |
| 148 return repeatUntil(function() { |
| 149 return callRemoteTestUtil('getWindows', null, []).then( |
| 150 function(windows) { |
| 151 for (var id in windows) { |
| 152 if (id === windowId) { |
| 153 // Window is still available. Continues waiting. |
| 154 return pending('Window with the prefix %s is not found.', |
| 155 windowId); |
| 156 } |
| 157 } |
| 158 // Window is not available. Closing is done successfully. |
| 159 return true; |
| 160 } |
| 161 ); |
| 162 }); |
| 163 } |
| 164 ); |
| 165 } |
| 166 |
| 167 /** |
| 134 * Waits until the window turns to the given size. | 168 * Waits until the window turns to the given size. |
| 135 * @param {string} windowId Target window ID. | 169 * @param {string} windowId Target window ID. |
| 136 * @param {number} width Requested width in pixels. | 170 * @param {number} width Requested width in pixels. |
| 137 * @param {number} height Requested height in pixels. | 171 * @param {number} height Requested height in pixels. |
| 138 */ | 172 */ |
| 139 function waitForWindowGeometry(windowId, width, height) { | 173 function waitForWindowGeometry(windowId, width, height) { |
| 140 return repeatUntil(function() { | 174 return repeatUntil(function() { |
| 141 return callRemoteTestUtil('getWindows', null, []).then(function(windows) { | 175 return callRemoteTestUtil('getWindows', null, []).then(function(windows) { |
| 142 if (!windows[windowId]) | 176 if (!windows[windowId]) |
| 143 return pending('Window %s is not found.', windowId); | 177 return pending('Window %s is not found.', windowId); |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 chrome.test.runTests([function() { | 765 chrome.test.runTests([function() { |
| 732 chrome.test.fail(testCaseName + ' is not found.'); | 766 chrome.test.fail(testCaseName + ' is not found.'); |
| 733 }]); | 767 }]); |
| 734 return; | 768 return; |
| 735 } | 769 } |
| 736 chrome.test.runTests([testcase[testCaseName]]); | 770 chrome.test.runTests([testcase[testCaseName]]); |
| 737 } | 771 } |
| 738 ]; | 772 ]; |
| 739 steps.shift()(); | 773 steps.shift()(); |
| 740 }); | 774 }); |
| OLD | NEW |