Chromium Code Reviews| 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 ' + | |
|
hirono
2014/03/05 03:55:14
nit: You can use %s format for the pending message
yoshiki
2014/03/05 04:23:02
Done.
| |
| 155 windowId + | |
| 156 ' is not found.'); | |
| 157 } | |
| 158 } | |
| 159 // Window is not available. Closing is done successfully. | |
| 160 return true; | |
| 161 } | |
| 162 ); | |
| 163 }); | |
| 164 } | |
| 165 ); | |
| 166 } | |
| 167 | |
| 168 /** | |
| 134 * Waits until the window turns to the given size. | 169 * Waits until the window turns to the given size. |
| 135 * @param {string} windowId Target window ID. | 170 * @param {string} windowId Target window ID. |
| 136 * @param {number} width Requested width in pixels. | 171 * @param {number} width Requested width in pixels. |
| 137 * @param {number} height Requested height in pixels. | 172 * @param {number} height Requested height in pixels. |
| 138 */ | 173 */ |
| 139 function waitForWindowGeometry(windowId, width, height) { | 174 function waitForWindowGeometry(windowId, width, height) { |
| 140 return repeatUntil(function() { | 175 return repeatUntil(function() { |
| 141 return callRemoteTestUtil('getWindows', null, []).then(function(windows) { | 176 return callRemoteTestUtil('getWindows', null, []).then(function(windows) { |
| 142 if (!windows[windowId]) | 177 if (!windows[windowId]) |
| 143 return pending('Window %s is not found.', windowId); | 178 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() { | 766 chrome.test.runTests([function() { |
| 732 chrome.test.fail(testCaseName + ' is not found.'); | 767 chrome.test.fail(testCaseName + ' is not found.'); |
| 733 }]); | 768 }]); |
| 734 return; | 769 return; |
| 735 } | 770 } |
| 736 chrome.test.runTests([testcase[testCaseName]]); | 771 chrome.test.runTests([testcase[testCaseName]]); |
| 737 } | 772 } |
| 738 ]; | 773 ]; |
| 739 steps.shift()(); | 774 steps.shift()(); |
| 740 }); | 775 }); |
| OLD | NEW |