summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources
diff options
context:
space:
mode:
authormtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-28 11:46:12 +0000
committermtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-28 11:46:12 +0000
commit2cfcba505a811a26e4f3a7de795ec49fb9b120c4 (patch)
treee8c56f9597e33b5d8615575b43a63bca44aa46fc /chrome/browser/resources
parent4418989a581d011e90caa3f1abef9761891efc10 (diff)
downloadchromium_src-2cfcba505a811a26e4f3a7de795ec49fb9b120c4.zip
chromium_src-2cfcba505a811a26e4f3a7de795ec49fb9b120c4.tar.gz
chromium_src-2cfcba505a811a26e4f3a7de795ec49fb9b120c4.tar.bz2
Added basic tests to test the audio player in Files.app.
This patch tests if the audio player handles OGG audio files properly. The added tests validate if the window has been opened, if the audio tag is loaded and if the title and artist field are filled out correctly. TBR=yoshiki@chromium.org TEST=browser_tests BUG=244146 Review URL: https://chromiumcodereview.appspot.com/16092002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202536 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r--chrome/browser/resources/file_manager/js/test_util.js31
1 files changed, 29 insertions, 2 deletions
diff --git a/chrome/browser/resources/file_manager/js/test_util.js b/chrome/browser/resources/file_manager/js/test_util.js
index c5c7c45..fd2a7cb 100644
--- a/chrome/browser/resources/file_manager/js/test_util.js
+++ b/chrome/browser/resources/file_manager/js/test_util.js
@@ -49,6 +49,28 @@ test.util.openMainWindow = function(path, callback) {
};
/**
+ * Waits for a window with the specified App ID prefix. Eg. `files` will match
+ * windows such as files#0, files#1, etc.
+ *
+ * @param {string} appIdPrefix ID prefix of the requested window.
+ * @param {function(string)} callback Completion callback with the new window's
+ * App ID.
+ */
+test.util.waitForWindow = function(appIdPrefix, callback) {
+ var appId;
+ function helper() {
+ for (var appId in appWindows) {
+ if (appId.indexOf(appIdPrefix) == 0) {
+ callback(appId);
+ return;
+ }
+ }
+ window.setTimeout(helper, 50);
+ }
+ helper();
+};
+
+/**
* Gets a document in the Files.app's window, including iframes.
*
* @param {Window} contentWindow Window to be used.
@@ -140,7 +162,8 @@ test.util.getFileList = function(contentWindow) {
* @param {Window} contentWindow Window to be tested.
* @param {string} targetQuery Query to specify the element.
* @param {?string} iframeQuery Iframe selector or null if no iframe.
- * @param {function(Object)} callback Callback with a hash array of attributes.
+ * @param {function(Object)} callback Callback with a hash array of attributes
+ * and contents as text.
*/
test.util.waitForElement = function(
contentWindow, targetQuery, iframeQuery, callback) {
@@ -154,7 +177,8 @@ test.util.waitForElement = function(
attributes[element.attributes[i].nodeName] =
element.attributes[i].nodeValue;
}
- callback(attributes);
+ var text = element.textContent;
+ callback({attributes: attributes, text: text});
return;
}
}
@@ -483,6 +507,9 @@ test.util.registerRemoteTestUtils = function() {
case 'openMainWindow':
test.util.openMainWindow(request.args[0], sendResponse);
return true;
+ case 'waitForWindow':
+ test.util.waitForWindow(request.args[0], sendResponse);
+ return true;
case 'getErrorCount':
sendResponse(test.util.getErrorCount());
return true;