Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Unified Diff: ui/webui/resources/js/webui_resource_test.js

Issue 2940933003: DO NOT SUBMIT results of new clang-format (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/webui/resources/js/webui_resource_test.js
diff --git a/ui/webui/resources/js/webui_resource_test.js b/ui/webui/resources/js/webui_resource_test.js
index b4fadbdf9b75d52c3b3482e12985d6004cac577b..12b3c37f510161154fcb09fdc9ac9a53329f9545 100644
--- a/ui/webui/resources/js/webui_resource_test.js
+++ b/ui/webui/resources/js/webui_resource_test.js
@@ -119,88 +119,88 @@ function assertDeepEquals(expected, observed, opt_message) {
* Defines runTests.
*/
(function(exports) {
- /**
- * List of test cases.
- * @type {Array<string>} List of function names for tests to run.
- */
- var testCases = [];
+/**
+ * List of test cases.
+ * @type {Array<string>} List of function names for tests to run.
+ */
+var testCases = [];
- /**
- * Indicates if all tests have run successfully.
- * @type {boolean}
- */
- var cleanTestRun = true;
+/**
+ * Indicates if all tests have run successfully.
+ * @type {boolean}
+ */
+var cleanTestRun = true;
- /**
- * Armed during setup of a test to call the matching tear down code.
- * @type {Function}
- */
- var pendingTearDown = null;
+/**
+ * Armed during setup of a test to call the matching tear down code.
+ * @type {Function}
+ */
+var pendingTearDown = null;
- /**
- * Runs all functions starting with test and reports success or
- * failure of the test suite.
- */
- function runTests() {
- for (var name in window) {
- // To avoid unnecessary getting properties, test name first.
- if (/^test/.test(name) && typeof window[name] == 'function')
- testCases.push(name);
- }
- if (!testCases.length) {
- console.error('Failed to find test cases.');
- cleanTestRun = false;
- }
+/**
+ * Runs all functions starting with test and reports success or
+ * failure of the test suite.
+ */
+function runTests() {
+ for (var name in window) {
+ // To avoid unnecessary getting properties, test name first.
+ if (/^test/.test(name) && typeof window[name] == 'function')
+ testCases.push(name);
+ }
+ if (!testCases.length) {
+ console.error('Failed to find test cases.');
+ cleanTestRun = false;
+ }
+ try {
+ if (window.setUpPage)
+ window.setUpPage();
+ } catch (err) {
+ cleanTestRun = false;
+ }
+ continueTesting();
+}
+
+/**
+ * Runs the next test in the queue. Reports the test results if the queue is
+ * empty.
+ * @param {boolean=} opt_asyncTestFailure Optional parameter indicated if the
+ * last asynchronous test failed.
+ */
+function continueTesting(opt_asyncTestFailure) {
+ if (opt_asyncTestFailure)
+ cleanTestRun = false;
+ var done = false;
+ if (pendingTearDown) {
+ pendingTearDown();
+ pendingTearDown = null;
+ }
+ if (testCases.length > 0) {
+ var fn = testCases.pop();
+ var isAsyncTest = window[fn].length;
try {
- if (window.setUpPage)
- window.setUpPage();
+ if (window.setUp)
+ window.setUp();
+ pendingTearDown = window.tearDown;
+ window[fn](continueTesting);
} catch (err) {
+ console.error('Failure in test ' + fn + '\n' + err);
+ console.log(err.stack);
cleanTestRun = false;
}
- continueTesting();
+ // Asynchronous tests must manually call continueTesting when complete.
+ if (!isAsyncTest)
+ continueTesting();
+ } else {
+ done = true;
+ endTests(cleanTestRun);
}
-
- /**
- * Runs the next test in the queue. Reports the test results if the queue is
- * empty.
- * @param {boolean=} opt_asyncTestFailure Optional parameter indicated if the
- * last asynchronous test failed.
- */
- function continueTesting(opt_asyncTestFailure) {
- if (opt_asyncTestFailure)
- cleanTestRun = false;
- var done = false;
- if (pendingTearDown) {
- pendingTearDown();
- pendingTearDown = null;
- }
- if (testCases.length > 0) {
- var fn = testCases.pop();
- var isAsyncTest = window[fn].length;
- try {
- if (window.setUp)
- window.setUp();
- pendingTearDown = window.tearDown;
- window[fn](continueTesting);
- } catch (err) {
- console.error('Failure in test ' + fn + '\n' + err);
- console.log(err.stack);
- cleanTestRun = false;
- }
- // Asynchronous tests must manually call continueTesting when complete.
- if (!isAsyncTest)
- continueTesting();
- } else {
- done = true;
- endTests(cleanTestRun);
- }
- if (!done) {
- domAutomationController.setAutomationId(1);
- domAutomationController.send('PENDING');
- }
+ if (!done) {
+ domAutomationController.setAutomationId(1);
+ domAutomationController.send('PENDING');
}
+}
- exports.runTests = runTests;
+exports.runTests = runTests;
})(this);
/**

Powered by Google App Engine
This is Rietveld 408576698