Commit d8f7b886 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[unified-consent] Move 'Drive suggestions' toggle to 'Other Google services'

- The 'Drive search suggestions' toggle is moved to the
  settings-personalization-options element. This means it is
  under the 'Other Google services' section.

- A test setup for non-offical builds is added to the
  settings_personalization_options tests.

- The frequently failing test 'displaying toggles depending on
  unified consent' is removed from the official tests.
  Reason: This test is not part of the CQ tests and oftentimes
  forgotten. Since there is no big value in keeping this test,
  it is removed.

Bug: 916191
Change-Id: I1ab1c876f1cedcaf22c167c3a2d0b238223e42b5
Reviewed-on: https://chromium-review.googlesource.com/c/1425607
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625629}
parent 23a4df69
......@@ -218,7 +218,8 @@
</div>
</template>
<template is="dom-if" if="[[driveSuggestAvailable_]]">
<template is="dom-if"
if="[[shouldShowDriveSuggest_(unifiedConsentEnabled)]]" restamp>
<settings-toggle-button
class$="[[getListItemClass_(unifiedConsentEnabled)]]"
pref="{{prefs.documentsuggest.enabled}}"
......@@ -325,7 +326,7 @@
<h2>$i18n{nonPersonalizedServicesSectionLabel}</h2>
</div>
<settings-personalization-options class="list-frame" prefs="{{prefs}}"
page-visibility="[[pageVisibility]]"
page-visibility="[[pageVisibility]]" sync-status="[[syncStatus]]"
unified-consent-enabled="[[unifiedConsentEnabled]]">
</settings-personalization-options>
</template>
......
......@@ -133,14 +133,6 @@ Polymer({
'syncStatus.hasError, syncStatus.statusAction)',
},
/** @private */
driveSuggestAvailable_: {
type: Boolean,
value: function() {
return loadTimeData.getBoolean('driveSuggestAvailable');
}
},
// <if expr="not chromeos">
diceEnabled: Boolean,
// </if>
......@@ -542,6 +534,15 @@ Polymer({
onSyncAdvancedTap_: function() {
settings.navigateTo(settings.routes.SYNC_ADVANCED);
},
/**
* @return {boolean}
* @private
*/
shouldShowDriveSuggest_: function() {
return loadTimeData.getBoolean('driveSuggestAvailable') &&
!this.unifiedConsentEnabled;
},
});
})();
......@@ -82,6 +82,14 @@
hidden="[[!showSpellCheckControl_(prefs.spellcheck.dictionaries)]]">
</settings-toggle-button>
</if><!-- _google_chrome -->
<template is="dom-if" if="[[shouldShowDriveSuggest_(unifiedConsentEnabled,
syncStatus, syncStatus.signedIn, syncStatus.statusAction)]]" restamp>
<settings-toggle-button id="driveSuggestControl"
pref="{{prefs.documentsuggest.enabled}}"
label="$i18n{driveSuggestPref}"
sub-label="$i18n{driveSuggestPrefDesc}">
</settings-toggle-button>
</template>
</template>
<script src="personalization_options.js"></script>
</dom-module>
......@@ -52,6 +52,9 @@ Polymer({
unifiedConsentEnabled: Boolean,
/** @type {settings.SyncStatus} */
syncStatus: Object,
// <if expr="_google_chrome and not chromeos">
// TODO(dbeam): make a virtual.* pref namespace and set/get this normally
// (but handled differently in C++).
......@@ -136,5 +139,16 @@ Polymer({
/** @type {!Array<string>} */
(this.prefs.spellcheck.dictionaries.value).length > 0);
},
/**
* @return {boolean}
* @private
*/
shouldShowDriveSuggest_: function() {
return loadTimeData.getBoolean('driveSuggestAvailable') &&
!!this.unifiedConsentEnabled && !!this.syncStatus &&
!!this.syncStatus.signedIn &&
this.syncStatus.statusAction !== settings.StatusAction.REAUTHENTICATE;
},
});
})();
......@@ -1011,9 +1011,9 @@ TEST_F('CrSettingsCertificateManagerTest', 'All', function() {
GEN('#endif // defined(USE_NSS_CERTS)');
GEN('#if defined(GOOGLE_CHROME_BUILD)');
/**
* Test fixture for chrome/browser/resources/settings/privacy_page/.
* Test fixture for
* chrome/browser/resources/settings/privacy_page/personalization_options.html.
* @constructor
* @extends {CrSettingsBrowserTest}
*/
......@@ -1035,14 +1035,19 @@ CrSettingsPersonalizationOptionsTest.prototype = {
]),
};
TEST_F('CrSettingsPersonalizationOptionsTest', 'AllBuilds', function() {
mocha.grep('PersonalizationOptionsTests_AllBuilds').run();
});
GEN('#if defined(GOOGLE_CHROME_BUILD)');
TEST_F('CrSettingsPersonalizationOptionsTest', 'OfficialBuild', function() {
mocha.run();
mocha.grep('PersonalizationOptionsTests_OfficialBuild').run();
});
GEN('#endif');
/**
* Test fixture for chrome/browser/resources/settings/privacy_page/.
* Test fixture for
* chrome/browser/resources/settings/privacy_page/privacy_page.html.
* @constructor
* @extends {CrSettingsBrowserTest}
*/
......
......@@ -153,7 +153,7 @@ cr.define('settings_people_page_sync_page', function() {
assertTrue(syncPage.$$('#sync-separator').hidden);
assertTrue(otherItems.classList.contains('list-frame'));
assertEquals(
otherItems.querySelectorAll(':scope > .list-item').length, 5);
otherItems.querySelectorAll(':scope > .list-item').length, 4);
// Test sync paused state.
syncPage.syncStatus = {
......
......@@ -3,36 +3,69 @@
// found in the LICENSE file.
cr.define('settings_personalization_options', function() {
suite('SafeBrowsingExtendedReportingOfficialBuild', function() {
suite('PersonalizationOptionsTests_AllBuilds', function() {
/** @type {settings.TestPrivacyPageBrowserProxy} */
let testBrowserProxy;
/** @type {SettingsPersonalizationOptionsElement} */
let testElement;
suiteSetup(function() {
loadTimeData.overrideValues({
driveSuggestAvailable: true,
});
});
setup(function() {
testBrowserProxy = new TestPrivacyPageBrowserProxy();
settings.PrivacyPageBrowserProxyImpl.instance_ = testBrowserProxy;
PolymerTest.clearBody();
testElement = document.createElement('settings-personalization-options');
document.body.appendChild(testElement);
Polymer.dom.flush();
});
teardown(function() {
testElement.remove();
});
test('displaying toggles depending on unified consent', function() {
testElement.unifiedConsentEnabled = false;
Polymer.dom.flush();
assertEquals(
7,
testElement.root.querySelectorAll('settings-toggle-button').length);
test('DriveSearchSuggestControl', function() {
assertFalse(!!testElement.$$('#driveSuggestControl'));
testElement.unifiedConsentEnabled = true;
testElement.syncStatus = {
signedIn: true,
statusAction: settings.StatusAction.NO_ACTION
};
Polymer.dom.flush();
assertTrue(!!testElement.$$('#driveSuggestControl'));
testElement.syncStatus = {
signedIn: true,
statusAction: settings.StatusAction.REAUTHENTICATE
};
Polymer.dom.flush();
assertEquals(
8,
testElement.root.querySelectorAll('settings-toggle-button').length);
assertFalse(!!testElement.$$('#driveSuggestControl'));
});
});
suite('PersonalizationOptionsTests_OfficialBuild', function() {
/** @type {settings.TestPrivacyPageBrowserProxy} */
let testBrowserProxy;
/** @type {SettingsPersonalizationOptionsElement} */
let testElement;
setup(function() {
testBrowserProxy = new TestPrivacyPageBrowserProxy();
settings.PrivacyPageBrowserProxyImpl.instance_ = testBrowserProxy;
PolymerTest.clearBody();
testElement = document.createElement('settings-personalization-options');
document.body.appendChild(testElement);
});
teardown(function() {
testElement.remove();
});
test('UnifiedConsent spellcheck toggle', function() {
......
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