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

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

Issue 1838213002: Simplify Site Settings tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 8 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/test/data/webui/settings/site_settings_category_tests.js
diff --git a/chrome/test/data/webui/settings/site_settings_category_tests.js b/chrome/test/data/webui/settings/site_settings_category_tests.js
index 230ca937d7c76cf28c53897f1af44a91198aad2e..9568cfe0adb08efac2bbf38a9571000fa244310e 100644
--- a/chrome/test/data/webui/settings/site_settings_category_tests.js
+++ b/chrome/test/data/webui/settings/site_settings_category_tests.js
@@ -59,23 +59,6 @@ cr.define('site_settings_category', function() {
document.body.appendChild(testElement);
});
- /**
- * Returns a promise that resolves once the selected item is updated.
- * @param {function()} action is executed after the listener is set up.
- * @return {!Promise} a Promise fulfilled when the selected item changes.
- */
- function runAndResolveWhenCategoryEnabledChanged(action) {
- return new Promise(function(resolve, reject) {
- var handler = function() {
- testElement.removeEventListener(
- 'category-enabled-changed', handler);
- resolve();
- };
- testElement.addEventListener('category-enabled-changed', handler);
- action();
- });
- }
-
test('getDefaultValueForContentType API used', function() {
testElement.category = settings.ContentSettingsTypes.GEOLOCATION;
return browserProxy.whenCalled('getDefaultValueForContentType').then(
@@ -85,31 +68,37 @@ cr.define('site_settings_category', function() {
});
});
+ function testCategoryEnabled(testElement, enabled) {
+ browserProxy.setPrefs(
+ enabled ? prefsLocationEnabled : prefsLocationDisabled);
+
+ testElement.category = settings.ContentSettingsTypes.GEOLOCATION;
+ return browserProxy.whenCalled('getDefaultValueForContentType').then(
+ function(contentType) {
+ assertEquals(
+ settings.ContentSettingsTypes.GEOLOCATION, contentType);
+ assertEquals(enabled, testElement.categoryEnabled);
+ MockInteractions.tap(testElement.$.toggle);
+ return browserProxy.whenCalled(
+ 'setDefaultValueForContentType').then(
+ function(arguments) {
+ assertEquals(
+ settings.ContentSettingsTypes.GEOLOCATION, arguments[0]);
+ assertEquals(
+ enabled ? settings.PermissionValues.BLOCK :
+ settings.PermissionValues.ASK,
+ arguments[1]);
+ assertNotEquals(enabled, testElement.categoryEnabled);
+ });
+ });
+ }
+
test('categoryEnabled correctly represents prefs (enabled)', function() {
- return runAndResolveWhenCategoryEnabledChanged(function() {
- browserProxy.setPrefs(prefsLocationEnabled);
- testElement.category = settings.ContentSettingsTypes.GEOLOCATION;
- }).then(function() {
- assertTrue(testElement.categoryEnabled);
- MockInteractions.tap(testElement.$.toggle);
- assertFalse(testElement.categoryEnabled);
- });
+ return testCategoryEnabled(testElement, true);
});
test('categoryEnabled correctly represents prefs (disabled)', function() {
- // In order for the 'change' event to trigger, the value monitored needs
- // to actually change (the event is not sent otherwise). Therefore,
- // ensure the initial state of enabledness is opposite of what we expect
- // it to end at.
- testElement.categoryEnabled = true;
- return runAndResolveWhenCategoryEnabledChanged(function() {
- browserProxy.setPrefs(prefsLocationDisabled);
- testElement.category = settings.ContentSettingsTypes.GEOLOCATION;
- }).then(function() {
- assertFalse(testElement.categoryEnabled);
- MockInteractions.tap(testElement.$.toggle);
- assertTrue(testElement.categoryEnabled);
- });
+ return testCategoryEnabled(testElement, false);
});
test('basic category tests', function() {

Powered by Google App Engine
This is Rietveld 408576698