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

Unified Diff: chrome/test/data/webui/settings/checkbox_tests.js

Issue 1486953003: Support numbers in settings-checkbox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure type of boolean pref also Created 5 years 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/test/data/webui/settings/checkbox_tests.js
diff --git a/chrome/test/data/webui/settings/checkbox_tests.js b/chrome/test/data/webui/settings/checkbox_tests.js
index 88b0e5fdc2e441dc60b0cfdc0ff14ec94355e1f4..48eb689926988008ab94de3f2cfbbb1c8bef57b6 100644
--- a/chrome/test/data/webui/settings/checkbox_tests.js
+++ b/chrome/test/data/webui/settings/checkbox_tests.js
@@ -41,11 +41,11 @@ cr.define('settings_checkbox', function() {
testElement.removeAttribute('checked');
assertFalse(testElement.checked);
- assertFalse(pref.value);
+ assertEquals(false, pref.value);
testElement.setAttribute('checked', '');
assertTrue(testElement.checked);
- assertTrue(pref.value);
+ assertEquals(true, pref.value);
Dan Beam 2015/12/02 21:48:57 why is this better?
stevenjb 2015/12/02 22:07:27 It's not. I made the incorrect assumption that ass
});
test('fires a change event', function(done) {
@@ -66,6 +66,28 @@ cr.define('settings_checkbox', function() {
assertFalse(testElement.checked);
assertFalse(testElement.$.checkbox.checked);
});
+
+ test('numerical pref', function() {
+ var prefNum = {
+ key: 'test',
+ type: chrome.settingsPrivate.PrefType.NUMBER,
+ value: 1
+ };
+
+ var testElementNum = document.createElement('settings-checkbox');
+ testElementNum.set('pref', prefNum);
Dan Beam 2015/12/02 21:48:57 why can't we just re-use the testElement fixture a
stevenjb 2015/12/02 22:07:27 We can. Done.
+ document.body.appendChild(testElementNum);
Dan Beam 2015/12/02 21:48:57 why does this need to be inserted into the DOM?
stevenjb 2015/12/02 22:07:27 Acknowledged.
+
+ assertTrue(testElementNum.checked);
+
+ testElementNum.removeAttribute('checked');
+ assertFalse(testElementNum.checked);
+ assertEquals(0, prefNum.value);
+
+ testElementNum.setAttribute('checked', '');
+ assertTrue(testElementNum.checked);
+ assertEquals(1, prefNum.value);
+ });
});
}

Powered by Google App Engine
This is Rietveld 408576698