summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/file_manager/background/js
diff options
context:
space:
mode:
authoryoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-27 08:13:33 +0000
committeryoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-27 08:13:33 +0000
commit01f83530e6064ec0972055ad8d5a6aecb3945061 (patch)
treef82d76686cb191ea1843aec50256dc37a146c6f6 /chrome/browser/resources/file_manager/background/js
parent413508215e6422c2d756e3fd063975cb84466330 (diff)
downloadchromium_src-01f83530e6064ec0972055ad8d5a6aecb3945061.zip
chromium_src-01f83530e6064ec0972055ad8d5a6aecb3945061.tar.gz
chromium_src-01f83530e6064ec0972055ad8d5a6aecb3945061.tar.bz2
[Files.app] Add a test of default task execution.
This patch adds a test of executing the default task by double click on the file. BUG=none TEST=manually tested Review URL: https://codereview.chromium.org/90563002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237538 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/file_manager/background/js')
-rw-r--r--chrome/browser/resources/file_manager/background/js/test_util.js52
1 files changed, 51 insertions, 1 deletions
diff --git a/chrome/browser/resources/file_manager/background/js/test_util.js b/chrome/browser/resources/file_manager/background/js/test_util.js
index e43569e..2960920 100644
--- a/chrome/browser/resources/file_manager/background/js/test_util.js
+++ b/chrome/browser/resources/file_manager/background/js/test_util.js
@@ -688,7 +688,7 @@ test.util.sync.deleteFile = function(contentWindow, filename) {
*
* @param {Window} contentWindow Window to be tested.
* @param {Array.<object>} queries Queries that specifies the elements and
- * expected styles.
+ * expected styles.
* @param {function()} callback Callback function to be notified the change of
* the styles.
*/
@@ -719,6 +719,56 @@ test.util.sync.execCommand = function(contentWindow, command) {
};
/**
+ * Override the task-related methods in private api for test.
+ *
+ * @param {Window} contentWindow Window to be tested.
+ * @param {Array.<Object>} taskList List of tasks to be returned in
+ * fileBrowserPrivate.getFileTasks().
+ * @return {boolean} Always return true.
+ */
+test.util.sync.overrideTasks = function(contentWindow, taskList) {
+ var getFileTasks = function(urls, mime, onTasks) {
+ // Call onTask asynchronously (same with original getFileTasks).
+ setTimeout(function() {
+ onTasks(taskList);
+ });
+ };
+
+ var executeTask = function(taskId, url) {
+ test.util.executedTasks_.push(taskId);
+ };
+
+ test.util.executedTasks_ = [];
+ contentWindow.chrome.fileBrowserPrivate.getFileTasks = getFileTasks;
+ contentWindow.chrome.fileBrowserPrivate.executeTask = executeTask;
+ return true;
+};
+
+/**
+ * Check if Files.app has ordered to execute the given task or not yet. This
+ * method must be used with test.util.sync.overrideTasks().
+ *
+ * @param {Window} contentWindow Window to be tested.
+ * @param {string} taskId Taskid of the task which should be executed.
+ * @param {function()} callback Callback function to be notified the order of
+ * the execution.
+ */
+test.util.async.waitUntilTaskExecutes =
+ function(contentWindow, taskId, callback) {
+ if (!test.util.executedTasks_) {
+ console.error('Please call overrideTasks() first.');
+ return;
+ }
+
+ test.util.repeatUntilTrue_(function() {
+ if (test.util.executedTasks_.indexOf(taskId) === -1)
+ return false;
+ callback();
+ return true;
+ });
+};
+
+/**
* Registers message listener, which runs test utility functions.
*/
test.util.registerRemoteTestUtils = function() {