Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
personalization: re-fetch screensaver albums
When user navigates back to the albums subpage, begin a request to refresh available google photos albums. When the user is on ambient subpage, focuses another window, and then comes back to personalization app, also begin another request to refresh google photos albums. This allows a user to edit albums live in photos.google.com and see immediate updates in personalization app. BUG=b:238198024 TEST=browser_tests --gtest_filter="*PersonalizationAppAmbient*" Change-Id: I3a545c8f503cce757e38f93ff5a6d56beed79b41 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3792352 Commit-Queue: Jeffrey Young <cowmoo@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org> Reviewed-by: Tao Wu <wutao@chromium.org> Cr-Commit-Position: refs/heads/main@{#1031145}
- Loading branch information
Showing
15 changed files
with
179 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
chrome/test/data/webui/chromeos/personalization_app/ambient_observer_test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Copyright 2022 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'chrome://personalization/strings.m.js'; | ||
import 'chrome://webui-test/mojo_webui_test_support.js'; | ||
|
||
import {AmbientActionName, AmbientModeAlbum, AmbientObserver, emptyState, SetAlbumsAction, TopicSource} from 'chrome://personalization/js/personalization_app.js'; | ||
import {assertDeepEquals, assertEquals} from 'chrome://webui-test/chai_assert.js'; | ||
|
||
import {baseSetup} from './personalization_app_test_utils.js'; | ||
import {TestAmbientProvider} from './test_ambient_interface_provider.js'; | ||
import {TestPersonalizationStore} from './test_personalization_store.js'; | ||
|
||
suite('AmbientObserverTest', function() { | ||
let ambientProvider: TestAmbientProvider; | ||
let personalizationStore: TestPersonalizationStore; | ||
|
||
setup(() => { | ||
const mocks = baseSetup(); | ||
ambientProvider = mocks.ambientProvider; | ||
personalizationStore = mocks.personalizationStore; | ||
AmbientObserver.initAmbientObserverIfNeeded(); | ||
}); | ||
|
||
teardown(() => { | ||
AmbientObserver.shutdown(); | ||
}); | ||
|
||
test('requests fetchSettingsAndAlbums on first load', async () => { | ||
await ambientProvider.whenCalled('fetchSettingsAndAlbums'); | ||
}); | ||
|
||
test('sets albums in store', async () => { | ||
personalizationStore.setReducersEnabled(true); | ||
// Make sure state starts as expected. | ||
assertDeepEquals(emptyState(), personalizationStore.data); | ||
assertEquals(null, personalizationStore.data.ambient.albums); | ||
|
||
personalizationStore.expectAction(AmbientActionName.SET_ALBUMS); | ||
ambientProvider.ambientObserverRemote!.onAlbumsChanged( | ||
ambientProvider.albums); | ||
|
||
const {albums} = await personalizationStore.waitForAction( | ||
AmbientActionName.SET_ALBUMS) as SetAlbumsAction; | ||
|
||
assertDeepEquals(ambientProvider.albums, albums); | ||
}); | ||
|
||
test('keeps recent highlights preview image', async () => { | ||
const initialAlbums: AmbientModeAlbum[] = [ | ||
{ | ||
id: 'RecentHighlights', | ||
checked: false, | ||
numberOfPhotos: 210, | ||
title: 'Recent Highlights title', | ||
description: 'Recent Highlights description', | ||
topicSource: TopicSource.kGooglePhotos, | ||
url: {url: 'asdf'}, | ||
}, | ||
{ | ||
id: 'abcdef', | ||
checked: false, | ||
numberOfPhotos: 3, | ||
title: 'Another album', | ||
description: 'Another album description', | ||
topicSource: TopicSource.kGooglePhotos, | ||
url: {url: 'qwerty'}, | ||
}, | ||
]; | ||
personalizationStore.data.ambient.albums = initialAlbums; | ||
|
||
personalizationStore.expectAction(AmbientActionName.SET_ALBUMS); | ||
|
||
ambientProvider.ambientObserverRemote!.onAlbumsChanged([ | ||
{ | ||
...initialAlbums[0]!, | ||
url: { | ||
url: 'new-recent-highlights-url', | ||
}, | ||
}, | ||
{ | ||
...initialAlbums[1]!, | ||
url: { | ||
url: 'new-regular-album-url', | ||
}, | ||
}, | ||
]); | ||
|
||
const {albums} = await personalizationStore.waitForAction( | ||
AmbientActionName.SET_ALBUMS) as SetAlbumsAction; | ||
|
||
assertEquals('RecentHighlights', albums[0]!.id); | ||
assertEquals( | ||
'asdf', albums[0]!.url.url, 'kept original url for recent highlights'); | ||
assertEquals( | ||
'new-regular-album-url', albums[1]!.url.url, | ||
'used updated regular album url'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.