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

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

Issue 2692213005: Reland: MD Settings: Fix the Network Prediction toggle box. (Closed)
Patch Set: Address comments Created 3 years, 10 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
« no previous file with comments | « chrome/test/data/webui/settings/checkbox_tests.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/settings/settings_toggle_button_tests.js
diff --git a/chrome/test/data/webui/settings/settings_toggle_button_tests.js b/chrome/test/data/webui/settings/settings_toggle_button_tests.js
index 212cf2d8b652ce82a8a278e59b26dfa5de485ffb..151dfa9d4a72241fe8be67141c53cfdde2d400d2 100644
--- a/chrome/test/data/webui/settings/settings_toggle_button_tests.js
+++ b/chrome/test/data/webui/settings/settings_toggle_button_tests.js
@@ -31,18 +31,6 @@ cr.define('settings_toggle_button', function() {
document.body.appendChild(testElement);
});
- test('responds to checked attribute', function() {
- assertTrue(testElement.checked);
-
- testElement.removeAttribute('checked');
- assertFalse(testElement.checked);
- assertFalse(testElement.pref.value);
-
- testElement.setAttribute('checked', '');
- assertTrue(testElement.checked);
- assertTrue(testElement.pref.value);
- });
-
test('value changes on tap', function() {
assertTrue(testElement.checked);
assertTrue(testElement.pref.value);
@@ -86,11 +74,60 @@ cr.define('settings_toggle_button', function() {
testElement.set('pref', prefNum);
assertTrue(testElement.checked);
- testElement.removeAttribute('checked');
+ MockInteractions.tap(testElement.$.control);
assertFalse(testElement.checked);
assertEquals(0, prefNum.value);
- testElement.setAttribute('checked', '');
+ MockInteractions.tap(testElement.$.control);
+ assertTrue(testElement.checked);
+ assertEquals(1, prefNum.value);
+ });
+
+ test('numerical pref with custom values', function() {
+ var prefNum = {
+ key: 'test',
+ type: chrome.settingsPrivate.PrefType.NUMBER,
+ value: 5
+ };
+
+ testElement._setNumericUncheckedValue(5);
+
+ testElement.set('pref', prefNum);
+ assertFalse(testElement.checked);
+
+ MockInteractions.tap(testElement.$.control);
+ assertTrue(testElement.checked);
+ assertEquals(1, prefNum.value);
+
+ MockInteractions.tap(testElement.$.control);
+ assertFalse(testElement.checked);
+ assertEquals(5, prefNum.value);
+ });
+
+ test('numerical pref with unknown inital value', function() {
+ prefNum = {
+ key: 'test',
+ type: chrome.settingsPrivate.PrefType.NUMBER,
+ value: 3
+ };
+
+ testElement._setNumericUncheckedValue(5);
+
+ testElement.set('pref', prefNum);
+
+ // Unknown value should still count as checked.
+ assertTrue(testElement.checked);
+
+ // The control should not clobber an existing unknown value.
+ assertEquals(3, prefNum.value);
+
+ // Unchecking should still send the unchecked value to prefs.
+ MockInteractions.tap(testElement.$.control);
+ assertFalse(testElement.checked);
+ assertEquals(5, prefNum.value);
+
+ // Checking should still send the normal checked value to prefs.
+ MockInteractions.tap(testElement.$.control);
assertTrue(testElement.checked);
assertEquals(1, prefNum.value);
});
« no previous file with comments | « chrome/test/data/webui/settings/checkbox_tests.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698