Commit f066f47e authored by wutao's avatar wutao Committed by Commit Bot

ambient: Enable photo preview for album selection

Bug: b/163888215
Test: passed current tests
Change-Id: I200f0f03d5ed71d6cdc317aecfd7698aa6f43472
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2399911
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarJimmy Gong <jimmyxgong@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805651}
parent 5a92cfa3
......@@ -8,6 +8,7 @@
#include "ash/public/cpp/ambient/common/ambient_settings.h"
#include "ash/public/cpp/ambient/fake_ambient_backend_controller_impl.h"
#include "ash/public/cpp/test/test_image_downloader.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "content/public/test/test_web_ui.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -46,6 +47,7 @@ class AmbientModeHandlerTest : public testing::Test {
handler_->AllowJavascript();
fake_backend_controller_ =
std::make_unique<ash::FakeAmbientBackendControllerImpl>();
image_downloader_ = std::make_unique<ash::TestImageDownloader>();
}
void RequestSettings() {
......@@ -184,6 +186,7 @@ class AmbientModeHandlerTest : public testing::Test {
std::unique_ptr<content::TestWebUI> web_ui_;
std::unique_ptr<ash::FakeAmbientBackendControllerImpl>
fake_backend_controller_;
std::unique_ptr<ash::TestImageDownloader> image_downloader_;
std::unique_ptr<TestAmbientModeHandler> handler_;
};
......
......@@ -51,9 +51,6 @@ suite('AmbientModeHandler', function() {
/** @type {SettingsAmbientModePageElement} */
let ambientModePage = null;
/** @type {SettingsAmbientModePhotosPageElement} */
let ambientModePhotosPage = null;
/** @type {?TestAmbientModeBrowserProxy} */
let browserProxy = null;
......@@ -68,10 +65,6 @@ suite('AmbientModeHandler', function() {
const prefElement = document.createElement('settings-prefs');
document.body.appendChild(prefElement);
ambientModePhotosPage =
document.createElement('settings-ambient-mode-photos-page');
document.body.appendChild(ambientModePhotosPage);
return CrSettingsPrefs.initialized.then(function() {
ambientModePage = document.createElement('settings-ambient-mode-page');
ambientModePage.prefs = prefElement.prefs;
......@@ -87,7 +80,6 @@ suite('AmbientModeHandler', function() {
teardown(function() {
ambientModePage.remove();
ambientModePhotosPage.remove();
settings.Router.getInstance().resetRouteForTesting();
});
......@@ -172,27 +164,6 @@ suite('AmbientModeHandler', function() {
'Topic sources row should be focused for settingId=502.');
});
test('hasAlbums', function() {
ambientModePhotosPage.albums = [
{albumId: 'id0', checked: true, title: 'album0'},
{albumId: 'id1', checked: false, title: 'album1'}
];
Polymer.dom.flush();
const ironList = ambientModePhotosPage.$$('iron-list');
const checkboxes = ironList.querySelectorAll('cr-checkbox');
assertEquals(2, checkboxes.length);
const checkbox0 = checkboxes[0];
const checkbox1 = checkboxes[1];
assertEquals('id0', checkbox0.dataset.id);
assertTrue(checkbox0.checked);
assertEquals('album0', checkbox0.label);
assertEquals('id1', checkbox1.dataset.id);
assertFalse(checkbox1.checked);
assertEquals('album1', checkbox1.label);
});
test('temperatureUnitRadioButtonsDisabled', () => {
// When |selectedTemperatureUnit_| is invalid the radio buttons should be
// disabled. This is the initial state.
......
......@@ -67,11 +67,11 @@ suite('AmbientModeHandler', function() {
* @private
*/
function assertCheckPosition(topicSource) {
ambientModePhotosPage.albums_ = [
{albumId: 'id0', checked: true, title: 'album0'},
{albumId: 'id1', checked: true, title: 'album1'}
ambientModePhotosPage.albums = [
{albumId: 'id0', checked: true, title: 'album0', url: 'url'},
{albumId: 'id1', checked: true, title: 'album1', url: 'url'}
];
ambientModePhotosPage.topicSource_ = topicSource;
ambientModePhotosPage.topicSource = topicSource;
Polymer.dom.flush();
const albumList = ambientModePhotosPage.$$('album-list');
......@@ -80,7 +80,7 @@ suite('AmbientModeHandler', function() {
albumItems.forEach((album) => {
const check = album.$$('.check');
const image = album.$.image;
const image = album.$$('#image');
const boundingWidth = image.getBoundingClientRect().width;
const scale = boundingWidth / image.offsetWidth;
......@@ -95,7 +95,41 @@ suite('AmbientModeHandler', function() {
});
}
test('hasAlbums', function() {
test('hasAlbumsWithoutPhotoPreview', function() {
// Disable photo preview feature and reload the |ambientModePhotosPage|.
loadTimeData.overrideValues({isAmbientModePhotoPreviewEnabled: false});
assertFalse(loadTimeData.getBoolean('isAmbientModePhotoPreviewEnabled'));
ambientModePhotosPage.remove();
ambientModePhotosPage =
document.createElement('settings-ambient-mode-photos-page');
document.body.appendChild(ambientModePhotosPage);
ambientModePhotosPage.albums = [
{albumId: 'id0', checked: true, title: 'album0'},
{albumId: 'id1', checked: false, title: 'album1'}
];
Polymer.dom.flush();
const ironList = ambientModePhotosPage.$$('iron-list');
const checkboxes = ironList.querySelectorAll('cr-checkbox');
assertEquals(2, checkboxes.length);
const checkbox0 = checkboxes[0];
const checkbox1 = checkboxes[1];
assertEquals('id0', checkbox0.dataset.id);
assertTrue(checkbox0.checked);
assertEquals('album0', checkbox0.label);
assertEquals('id1', checkbox1.dataset.id);
assertFalse(checkbox1.checked);
assertEquals('album1', checkbox1.label);
// Reset/enable photo preview feature.
loadTimeData.overrideValues({isAmbientModePhotoPreviewEnabled: true});
assertTrue(loadTimeData.getBoolean('isAmbientModePhotoPreviewEnabled'));
});
test('hasAlbumsWithPhotoPreview', function() {
ambientModePhotosPage.albums = [
{albumId: 'id0', checked: true, title: 'album0'},
{albumId: 'id1', checked: false, title: 'album1'}
......
......@@ -226,11 +226,6 @@ var OSSettingsAmbientModePageTest = class extends OSSettingsBrowserTest {
return super.browsePreload + 'ambient_mode_page/ambient_mode_page.html';
}
/** @override */
get featureList() {
return {enabled: ['chromeos::features::kAmbientModeFeature']};
}
/** @override */
get extraLibraries() {
return super.extraLibraries.concat([
......@@ -254,16 +249,6 @@ var OSSettingsAmbientModePhotosPageTest = class extends OSSettingsBrowserTest {
'ambient_mode_page/ambient_mode_photos_page.html';
}
/** @override */
get featureList() {
return {
enabled: [
'chromeos::features::kAmbientModeFeature',
'chromeos::features::kAmbientModePhotoPreviewFeature',
]
};
}
/** @override */
get extraLibraries() {
return super.extraLibraries.concat([
......
......@@ -28,7 +28,7 @@ const base::Feature kAmbientModeFeature{"ChromeOSAmbientMode",
// Controls whether to enable Ambient mode album selection with photo previews.
const base::Feature kAmbientModePhotoPreviewFeature{
"ChromeOSAmbientModePhotoPreview", base::FEATURE_DISABLED_BY_DEFAULT};
"ChromeOSAmbientModePhotoPreview", base::FEATURE_ENABLED_BY_DEFAULT};
// Controls whether to allow Dev channel to use Prod server feature.
const base::Feature kAmbientModeDevUseProdFeature{
......
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