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

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

Issue 2517753002: [MD settings] settings toggle control browser test addtion (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | 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 dfc7456a4855762a1a4a5f5d57069830bae48507..30524978bbcc8399d7c999e9c57e1e9feacb8848 100644
--- a/chrome/test/data/webui/settings/settings_toggle_button_tests.js
+++ b/chrome/test/data/webui/settings/settings_toggle_button_tests.js
@@ -12,18 +12,19 @@ cr.define('settings_toggle_button', function() {
*/
var testElement;
- /**
- * Pref value used in tests, should reflect the 'checked' attribute.
- * @type {SettingsCheckbox}
- */
- var pref = {
- key: 'test',
- type: chrome.settingsPrivate.PrefType.BOOLEAN,
- value: true
- };
-
// Initialize a checked control before each test.
setup(function() {
+ /**
+ * Pref value used in tests, should reflect the 'checked' attribute.
+ * Create a new pref for each test() to prevent order (state)
+ * dependencies between tests.
+ * @type {SettingsCheckbox}
dpapad 2016/11/30 20:14:39 This type annotation seems wrong. Should it be chr
dschuyler 2016/12/01 19:34:25 Done.
+ */
+ var pref = {
+ key: 'test',
+ type: chrome.settingsPrivate.PrefType.BOOLEAN,
+ value: true
+ };
PolymerTest.clearBody();
testElement = document.createElement('settings-toggle-button');
testElement.set('pref', pref);
@@ -35,11 +36,24 @@ cr.define('settings_toggle_button', function() {
testElement.removeAttribute('checked');
assertFalse(testElement.checked);
- assertFalse(pref.value);
+ assertFalse(testElement.pref.value);
testElement.setAttribute('checked', '');
assertTrue(testElement.checked);
- assertTrue(pref.value);
+ assertTrue(testElement.pref.value);
+ });
+
+ test('value changes on tap', function() {
+ assertTrue(testElement.checked);
+ assertTrue(testElement.pref.value);
+
+ MockInteractions.tap(testElement.$.control);
+ assertFalse(testElement.checked);
+ assertFalse(testElement.pref.value);
+
+ MockInteractions.tap(testElement.$.control);
+ assertTrue(testElement.checked);
+ assertTrue(testElement.pref.value);
});
test('fires a change event', function(done) {
@@ -47,6 +61,7 @@ cr.define('settings_toggle_button', function() {
assertFalse(testElement.checked);
done();
});
+ assertTrue(testElement.checked);
MockInteractions.tap(testElement.$.control);
});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698