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

Unified Diff: chrome/browser/resources/chromeos/chromevox/testing/assert_additions.js

Issue 484063003: Port braille related tests from ChromeVox upstream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Rename a fake class. Created 6 years, 3 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: chrome/browser/resources/chromeos/chromevox/testing/assert_additions.js
diff --git a/chrome/browser/resources/chromeos/chromevox/testing/assert_additions.js b/chrome/browser/resources/chromeos/chromevox/testing/assert_additions.js
index 93689aa8eabb9fbf8573004a9336838de3fc9020..394a0ea34781ce1fb6b8e4f5904ee700d9dad2a2 100644
--- a/chrome/browser/resources/chromeos/chromevox/testing/assert_additions.js
+++ b/chrome/browser/resources/chromeos/chromevox/testing/assert_additions.js
@@ -13,6 +13,18 @@ function assertUndefined(a) {
}
/**
+ * Asserts that the argument is neither null nor undefined.
+ * @param {object} obj The argument to check.
+ * @param {string=} opt_message Error message if the condition is not met.
+ */
+function assertNotNullNorUndefined(obj, opt_message) {
+ if (obj === undefined || obj === null) {
+ throw new Error('Can\'t be null or undefined: ' + (opt_message || '') +
+ '\n' + 'Actual: ' + a);
+ }
+}
+
+/**
* Asserts that a given function call throws an exception.
* @param {string} msg Message to print if exception not thrown.
* @param {Function} fn The function to call.
@@ -56,13 +68,15 @@ function assertEqualStringArrays(array1, array2) {
/**
* Asserts that two objects have the same JSON serialization.
- * @param {Object} obj1 The expected object.
- * @param {Object} obj2 The actual object.
+ * @param {Object} expected The expected object.
+ * @param {Object} actual The actual object.
+ * @param {string=} opt_message Message used for errors.
*/
-function assertEqualsJSON(obj1, obj2) {
- if (!eqJSON(obj1, obj2)) {
- throw new Error('Expected ' + JSON.stringify(obj1) +
- ', got ' + JSON.stringify(obj2));
+function assertEqualsJSON(expected, actual, opt_message) {
+ if (JSON.stringify(actual) !== JSON.stringify(expected)) {
+ throw new Error((opt_message ? opt_message + '\n' : '') +
+ 'Expected ' + JSON.stringify(expected) + '\n' +
+ 'Got ' + JSON.stringify(actual));
}
}

Powered by Google App Engine
This is Rietveld 408576698