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

Side by Side Diff: chrome/test/data/webui/settings/settings_toggle_button_tests.js

Issue 2691223002: Revert of MD Settings: Fix the Network Prediction toggle box. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/settings/privacy_page/privacy_page.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** @fileoverview Suite of tests for settings-toggle-button. */ 5 /** @fileoverview Suite of tests for settings-toggle-button. */
6 cr.define('settings_toggle_button', function() { 6 cr.define('settings_toggle_button', function() {
7 function registerTests() { 7 function registerTests() {
8 suite('SettingsToggleButton', function() { 8 suite('SettingsToggleButton', function() {
9 /** 9 /**
10 * Toggle button created before each test. 10 * Toggle button created before each test.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 assertTrue(testElement.checked); 87 assertTrue(testElement.checked);
88 88
89 testElement.removeAttribute('checked'); 89 testElement.removeAttribute('checked');
90 assertFalse(testElement.checked); 90 assertFalse(testElement.checked);
91 assertEquals(0, prefNum.value); 91 assertEquals(0, prefNum.value);
92 92
93 testElement.setAttribute('checked', ''); 93 testElement.setAttribute('checked', '');
94 assertTrue(testElement.checked); 94 assertTrue(testElement.checked);
95 assertEquals(1, prefNum.value); 95 assertEquals(1, prefNum.value);
96 }); 96 });
97
98 test('numerical pref with custom values', function() {
99 var prefNum = {
100 key: 'test',
101 type: chrome.settingsPrivate.PrefType.NUMBER,
102 value: 5
103 };
104
105 testElement.numericUncheckedValue = 5;
106
107 testElement.set('pref', prefNum);
108 assertFalse(testElement.checked);
109
110 testElement.setAttribute('checked', '');
111 assertTrue(testElement.checked);
112 assertEquals(1, prefNum.value);
113
114 testElement.removeAttribute('checked');
115 assertFalse(testElement.checked);
116 assertEquals(5, prefNum.value);
117 });
118
119 test('numerical pref with unknown inital value', function() {
120 prefNum = {
121 key: 'test',
122 type: chrome.settingsPrivate.PrefType.NUMBER,
123 value: 3
124 };
125
126 testElement.numericUncheckedValue = 5;
127
128 testElement.set('pref', prefNum);
129
130 // Unknown value should still count as checked.
131 assertTrue(testElement.checked);
132
133 // The control should not clobber an existing unknown value.
134 assertEquals(3, prefNum.value);
135
136 // Unchecking should still send the unchecked value to prefs.
137 testElement.removeAttribute('checked');
138 assertFalse(testElement.checked);
139 assertEquals(5, prefNum.value);
140
141 // Checking should still send the normal checked value to prefs.
142 testElement.setAttribute('checked', '');
143 assertTrue(testElement.checked);
144 assertEquals(1, prefNum.value);
145 });
146 }); 97 });
147 } 98 }
148 99
149 return { 100 return {
150 registerTests: registerTests, 101 registerTests: registerTests,
151 }; 102 };
152 }); 103 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/privacy_page/privacy_page.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698