Commit a690f286 authored by Demetrios Papadopoulos's avatar Demetrios Papadopoulos Committed by Commit Bot

Fix and re-enable CrSettingsSiteSettingsPageTest.All test.

It was previously failing because it was asserting on the value of a
cr-link-row's sublabel before it was actually updated in the prod code.

Introducing a 'site-settings-list-labels-updated-for-testing' event to give a
singal on the test code on when to assert fixes the issue.

Bug: 1061249
Change-Id: Ia9c31229da79ac83acb38254ccee053b26f3ec1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2111778
Commit-Queue: Sean Harrison <harrisonsean@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Reviewed-by: default avatarSean Harrison <harrisonsean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751988}
parent c9ca74b9
...@@ -64,15 +64,12 @@ cr.define('settings', function() { ...@@ -64,15 +64,12 @@ cr.define('settings', function() {
this.browserProxy_ = this.browserProxy_ =
settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); settings.SiteSettingsPrefsBrowserProxyImpl.getInstance();
for (const item of this.categoryList) { Promise
// Default labels are not applicable to ZOOM_LEVELS or PDF. .all(this.categoryList.map(
if (item.id === settings.ContentSettingsTypes.ZOOM_LEVELS || item => this.refreshDefaultValueLabel_(item.id)))
item.id === 'pdfDocuments') { .then(() => {
continue; this.fire('site-settings-list-labels-updated-for-testing');
} });
this.refreshDefaultValueLabel_(item.id);
}
this.addWebUIListener( this.addWebUIListener(
'contentSettingCategoryChanged', 'contentSettingCategoryChanged',
...@@ -111,16 +108,25 @@ cr.define('settings', function() { ...@@ -111,16 +108,25 @@ cr.define('settings', function() {
/** /**
* @param {!settings.ContentSettingsTypes} category The category to refresh * @param {!settings.ContentSettingsTypes} category The category to refresh
* (fetch current value + update UI) * (fetch current value + update UI)
* @return {!Promise<void>} A promise firing after the label has been
* updated.
* @private * @private
*/ */
refreshDefaultValueLabel_(category) { refreshDefaultValueLabel_(category) {
// Default labels are not applicable to ZOOM_LEVELS or PDF.
if (category === settings.ContentSettingsTypes.ZOOM_LEVELS ||
category === 'pdfDocuments') {
return Promise.resolve();
}
if (category == settings.ContentSettingsTypes.COOKIES && if (category == settings.ContentSettingsTypes.COOKIES &&
loadTimeData.getBoolean('privacySettingsRedesignEnabled')) { loadTimeData.getBoolean('privacySettingsRedesignEnabled')) {
// Updates to the cookies label are handled by the // Updates to the cookies label are handled by the
// cookieSettingDescriptionChanged event listener. // cookieSettingDescriptionChanged event listener.
return; return Promise.resolve();
} }
this.browserProxy_.getDefaultValueForContentType(category).then(
return this.browserProxy_.getDefaultValueForContentType(category).then(
defaultValue => { defaultValue => {
this.updateDefaultValueLabel_(category, defaultValue.setting); this.updateDefaultValueLabel_(category, defaultValue.setting);
}); });
......
...@@ -1185,7 +1185,7 @@ CrSettingsSiteSettingsPageTest.prototype = { ...@@ -1185,7 +1185,7 @@ CrSettingsSiteSettingsPageTest.prototype = {
]) ])
}; };
TEST_F('CrSettingsSiteSettingsPageTest', 'DISABLED_All', function() { TEST_F('CrSettingsSiteSettingsPageTest', 'All', function() {
mocha.run(); mocha.run();
}); });
......
...@@ -69,15 +69,17 @@ suite('SiteSettingsPage', function() { ...@@ -69,15 +69,17 @@ suite('SiteSettingsPage', function() {
settings.ContentSetting.IMPORTANT_CONTENT, 'a', 'b', 'c')); settings.ContentSetting.IMPORTANT_CONTENT, 'a', 'b', 'c'));
}); });
test('CookiesLinkRowSublabel', function() { test('CookiesLinkRowSublabel', async function() {
loadTimeData.overrideValues({ loadTimeData.overrideValues({
privacySettingsRedesignEnabled: false, privacySettingsRedesignEnabled: false,
}); });
setupPage(); setupPage();
const allSettingsList = page.$$('#allSettingsList'); const allSettingsList = page.$$('#allSettingsList');
await test_util.eventToPromise(
'site-settings-list-labels-updated-for-testing', allSettingsList);
assertEquals( assertEquals(
allSettingsList.$$('#cookies').subLabel, allSettingsList.i18n('siteSettingsCookiesAllowed'),
allSettingsList.i18n('siteSettingsCookiesAllowed')); allSettingsList.$$('#cookies').subLabel);
}); });
test('CookiesLinkRowSublabel_Redesign', async function() { test('CookiesLinkRowSublabel_Redesign', async function() {
...@@ -88,9 +90,9 @@ suite('SiteSettingsPage', function() { ...@@ -88,9 +90,9 @@ suite('SiteSettingsPage', function() {
await siteSettingsBrowserProxy.whenCalled('getCookieSettingDescription'); await siteSettingsBrowserProxy.whenCalled('getCookieSettingDescription');
Polymer.dom.flush(); Polymer.dom.flush();
const cookiesLinkRow = page.$$('#basicContentList').$$('#cookies'); const cookiesLinkRow = page.$$('#basicContentList').$$('#cookies');
assertEquals(cookiesLinkRow.subLabel, testLabels[0]); assertEquals(testLabels[0], cookiesLinkRow.subLabel);
cr.webUIListenerCallback('cookieSettingDescriptionChanged', testLabels[1]); cr.webUIListenerCallback('cookieSettingDescriptionChanged', testLabels[1]);
assertEquals(cookiesLinkRow.subLabel, testLabels[1]); assertEquals(testLabels[1], cookiesLinkRow.subLabel);
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment