summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authoryoshiki <yoshiki@chromium.org>2015-06-26 05:00:05 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-26 12:00:43 +0000
commit961f9ea9d61d3b6a474bb7919cdfe171b8975da7 (patch)
tree66b54bf1bcef34fc6474e852ee8c499fcb21ce6c /ui
parent3c16245b5b52fc947a9a2765ab038d13b375d5e3 (diff)
downloadchromium_src-961f9ea9d61d3b6a474bb7919cdfe171b8975da7.zip
chromium_src-961f9ea9d61d3b6a474bb7919cdfe171b8975da7.tar.gz
chromium_src-961f9ea9d61d3b6a474bb7919cdfe171b8975da7.tar.bz2
[Files.app tests] Combine methods commonly used among tests
The utility methods checkIfNoErrorsOccured() and testPromise() are commonly used among some tests, so this patch combines them into one. This patch is reland of https://crrev.com/3e38f58672a5ff43b94d4cdbe0a335694edd0635 BUG=none TEST=browser_tests TBR=fukino@chromium.org Review URL: https://codereview.chromium.org/1205413002 Cr-Commit-Position: refs/heads/master@{#336353}
Diffstat (limited to 'ui')
-rw-r--r--ui/file_manager/integration_tests/audio_player/background.js30
-rw-r--r--ui/file_manager/integration_tests/file_manager/background.js16
-rw-r--r--ui/file_manager/integration_tests/gallery/background.js29
-rw-r--r--ui/file_manager/integration_tests/test_util.js30
-rw-r--r--ui/file_manager/integration_tests/video_player/background.js30
5 files changed, 37 insertions, 98 deletions
diff --git a/ui/file_manager/integration_tests/audio_player/background.js b/ui/file_manager/integration_tests/audio_player/background.js
index 757bbf3..4c101c6 100644
--- a/ui/file_manager/integration_tests/audio_player/background.js
+++ b/ui/file_manager/integration_tests/audio_player/background.js
@@ -52,34 +52,6 @@ function launch(testVolumeName, volumeType, entries, opt_selected) {
}
/**
- * Verifies if there are no Javascript errors in any of the app windows.
- * @param {function()} Completion callback.
- */
-function checkIfNoErrorsOccured(callback) {
- var countPromise = remoteCallAudioPlayer.callRemoteTestUtil(
- 'getErrorCount', null, []);
- countPromise.then(function(count) {
- chrome.test.assertEq(0, count, 'The error count is not 0.');
- callback();
- });
-}
-
-/**
- * Adds check of chrome.test to the end of the given promise.
- * @param {Promise} promise Promise.
- */
-function testPromise(promise) {
- promise.then(function() {
- return new Promise(checkIfNoErrorsOccured);
- }).then(chrome.test.callbackPass(function() {
- // The callbacPass is necessary to avoid prematurely finishing tests.
- // Don't put chrome.test.succeed() here to avoid doubled success log.
- }), function(error) {
- chrome.test.fail(error.stack || error);
- });
-};
-
-/**
* Namespace for test cases.
*/
var testcase = {};
@@ -117,7 +89,7 @@ window.addEventListener('load', function() {
// Specify the name of test to the test system.
targetTest.generatedName = testCaseName;
chrome.test.runTests([function() {
- return testPromise(targetTest());
+ return testPromiseAndApps(targetTest(), [remoteCallAudioPlayer]);
}]);
}
];
diff --git a/ui/file_manager/integration_tests/file_manager/background.js b/ui/file_manager/integration_tests/file_manager/background.js
index 8448bd8..bbbafce 100644
--- a/ui/file_manager/integration_tests/file_manager/background.js
+++ b/ui/file_manager/integration_tests/file_manager/background.js
@@ -45,14 +45,9 @@ var videoPlayerApp = new RemoteCall(VIDEO_PLAYER_APP_ID);
* @param {Promise} promise Promise.
*/
function testPromise(promise) {
- promise.then(function() {
- return new Promise(checkIfNoErrorsOccured);
- }).then(chrome.test.callbackPass(function() {
- // The callbacPass is necessary to avoid prematurely finishing tests.
- // Don't put chrome.test.succeed() here to avoid doubled success log.
- }), function(error) {
- chrome.test.fail(error.stack || error);
- });
+ return testPromiseAndApps(
+ promise,
+ [remoteCall, galleryApp, audioPlayerApp, videoPlayerApp]);
};
/**
@@ -338,10 +333,7 @@ function setupAndWaitUntilReady(appState, initialRoot, opt_callback) {
* @param {function()} Completion callback.
*/
function checkIfNoErrorsOccured(callback) {
- remoteCall.callRemoteTestUtil('getErrorCount', null, [], function(count) {
- chrome.test.assertEq(0, count, 'The error count is not 0.');
- callback();
- });
+ checkIfNoErrorsOccuredOnApp(remoteCall, callback);
}
/**
diff --git a/ui/file_manager/integration_tests/gallery/background.js b/ui/file_manager/integration_tests/gallery/background.js
index f507799..ffaba3d 100644
--- a/ui/file_manager/integration_tests/gallery/background.js
+++ b/ui/file_manager/integration_tests/gallery/background.js
@@ -54,33 +54,6 @@ function launch(testVolumeName, volumeType, entries, opt_selected) {
}
/**
- * Verifies if there are no Javascript errors in any of the app windows.
- * @param {function()} Completion callback.
- */
-function checkIfNoErrorsOccured(callback) {
- var countPromise = gallery.callRemoteTestUtil('getErrorCount', null, []);
- countPromise.then(function(count) {
- chrome.test.assertEq(0, count, 'The error count is not 0.');
- callback();
- });
-}
-
-/**
- * Adds check of chrome.test to the end of the given promise.
- * @param {Promise} promise Promise.
- */
-function testPromise(promise) {
- promise.then(function() {
- return new Promise(checkIfNoErrorsOccured);
- }).then(chrome.test.callbackPass(function() {
- // The callbacPass is necessary to avoid prematurely finishing tests.
- // Don't put chrome.test.succeed() here to avoid doubled success log.
- }), function(error) {
- chrome.test.fail(error.stack || error);
- });
-};
-
-/**
* Namespace for test cases.
*/
var testcase = {};
@@ -118,7 +91,7 @@ window.addEventListener('load', function() {
// Specify the name of test to the test system.
targetTest.generatedName = testCaseName;
chrome.test.runTests([function() {
- return testPromise(targetTest());
+ return testPromiseAndApps(targetTest(), [gallery]);
}]);
}
];
diff --git a/ui/file_manager/integration_tests/test_util.js b/ui/file_manager/integration_tests/test_util.js
index 2b586a6..2db86ff 100644
--- a/ui/file_manager/integration_tests/test_util.js
+++ b/ui/file_manager/integration_tests/test_util.js
@@ -27,6 +27,36 @@ function wait(time) {
}
/**
+ * Verifies if there are no Javascript errors in any of the app windows.
+ * @param {function()} Completion callback.
+ */
+function checkIfNoErrorsOccuredOnApp(app, callback) {
+ var countPromise = app.callRemoteTestUtil('getErrorCount', null, []);
+ countPromise.then(function(count) {
+ chrome.test.assertEq(0, count, 'The error count is not 0.');
+ callback();
+ });
+}
+
+/**
+ * Adds check of chrome.test to the end of the given promise.
+ * @param {Promise} promise Promise.
+ */
+function testPromiseAndApps(promise, apps) {
+ promise.then(function() {
+ return Promise.all(
+ apps.map(function(app) {
+ return new Promise(checkIfNoErrorsOccuredOnApp.bind(null, app));
+ }));
+ }).then(chrome.test.callbackPass(function() {
+ // The callbacPass is necessary to avoid prematurely finishing tests.
+ // Don't put chrome.test.succeed() here to avoid doubled success log.
+ }), function(error) {
+ chrome.test.fail(error.stack || error);
+ });
+};
+
+/**
* Interval milliseconds between checks of repeatUntil.
* @type {number}
* @const
diff --git a/ui/file_manager/integration_tests/video_player/background.js b/ui/file_manager/integration_tests/video_player/background.js
index f1caec0..0a541b1 100644
--- a/ui/file_manager/integration_tests/video_player/background.js
+++ b/ui/file_manager/integration_tests/video_player/background.js
@@ -75,34 +75,6 @@ function openSingleVideo(volumeName, volumeType, entry) {
};
/**
- * Verifies if there are no Javascript errors in any of the app windows.
- * @param {function()} Completion callback.
- */
-function checkIfNoErrorsOccured(callback) {
- var countPromise = remoteCallVideoPlayer.callRemoteTestUtil(
- 'getErrorCount', null, []);
- countPromise.then(function(count) {
- chrome.test.assertEq(0, count, 'The error count is not 0.');
- callback();
- });
-}
-
-/**
- * Adds check of chrome.test to the end of the given promise.
- * @param {Promise} promise Promise.
- */
-function testPromise(promise) {
- promise.then(function() {
- return new Promise(checkIfNoErrorsOccured);
- }).then(chrome.test.callbackPass(function() {
- // The callbacPass is necessary to avoid prematurely finishing tests.
- // Don't put chrome.test.succeed() here to avoid doubled success log.
- }), function(error) {
- chrome.test.fail(error.stack || error);
- });
-};
-
-/**
* Namespace for test cases.
*/
var testcase = {};
@@ -140,7 +112,7 @@ window.addEventListener('load', function() {
// Specify the name of test to the test system.
targetTest.generatedName = testCaseName;
chrome.test.runTests([function() {
- return testPromise(targetTest());
+ return testPromiseAndApps(targetTest(), [remoteCallVideoPlayer]);
}]);
}
];