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

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, 9 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..01a7583aaec18da34ab5002e3a2b32898fcf9472 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(
@@ -86,30 +69,46 @@ cr.define('site_settings_category', function() {
});
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);
- });
+ browserProxy.setPrefs(prefsLocationEnabled);
+ testElement.category = settings.ContentSettingsTypes.GEOLOCATION;
+ return browserProxy.whenCalled('getDefaultValueForContentType').then(
+ function(contentType) {
+ assertEquals(
+ settings.ContentSettingsTypes.GEOLOCATION, contentType);
+ assertTrue(testElement.categoryEnabled);
+ MockInteractions.tap(testElement.$.toggle);
+ return browserProxy.whenCalled(
+ 'setDefaultValueForContentType').then(
+ function(arguments) {
+ assertEquals(
+ settings.ContentSettingsTypes.GEOLOCATION, arguments[0]);
+ assertEquals(
+ settings.PermissionValues.BLOCK, arguments[1]);
+ assertFalse(testElement.categoryEnabled);
+ });
+ });
});
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);
- });
+ browserProxy.setPrefs(prefsLocationDisabled);
dpapad 2016/03/31 17:37:07 This test is identical to the previous one with th
Finnur 2016/04/04 13:59:24 Good catch. It got really scary, though, while I w
+ testElement.category = settings.ContentSettingsTypes.GEOLOCATION;
+ return browserProxy.whenCalled('getDefaultValueForContentType').then(
+ function(contentType) {
+ assertEquals(
+ settings.ContentSettingsTypes.GEOLOCATION, contentType);
+ assertFalse(testElement.categoryEnabled);
+ MockInteractions.tap(testElement.$.toggle);
+ return browserProxy.whenCalled(
+ 'setDefaultValueForContentType').then(
+ function(arguments) {
+ assertEquals(
+ settings.ContentSettingsTypes.GEOLOCATION, arguments[0]);
+ assertEquals(
+ settings.PermissionValues.ASK, arguments[1]);
+ assertTrue(testElement.categoryEnabled);
+ });
+ });
+
});
test('basic category tests', function() {

Powered by Google App Engine
This is Rietveld 408576698