Commit aa4e005a authored by khmel@google.com's avatar khmel@google.com Committed by Commit Bot

arc: Fix default ARC app icons are not loaded.

This fix the issue when default ARC app icons are not loaded in case
of provisioning is not finished for new user flow.

Test: Manually + unit_test
Bug: 833596
Change-Id: I99af81eafb78c65857b6fe5a6475d3372e08beb5
Reviewed-on: https://chromium-review.googlesource.com/1014326
Commit-Queue: Yury Khmel <khmel@google.com>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551182}
parent e3634cb4
......@@ -793,7 +793,6 @@ void ArcAppListPrefs::SetDefaultAppsFilterLevel() {
void ArcAppListPrefs::OnDefaultAppsReady() {
// Apply uninstalled packages now.
const std::vector<std::string> uninstalled_package_names =
GetPackagesFromPrefs(false /* check_arc_alive */, false /* installed */);
for (const auto& uninstalled_package_name : uninstalled_package_names)
......@@ -816,8 +815,19 @@ void ArcAppListPrefs::RegisterDefaultApps() {
if (!default_apps_.HasApp(app_id))
continue;
// Skip already tracked app.
if (tracked_apps_.count(app_id))
if (tracked_apps_.count(app_id)) {
// Icon should be already taken from the cache. Play Store icon is loaded
// from internal resources.
if (ready_apps_.count(app_id) || app_id == arc::kPlayStoreAppId)
continue;
// Notify that icon is ready for default app.
for (auto& observer : observer_list_) {
for (ui::ScaleFactor scale_factor : ui::GetSupportedScaleFactors())
observer.OnAppIconUpdated(app_id, scale_factor);
}
continue;
}
const ArcDefaultAppList::AppInfo& app_info = *default_app.second.get();
AddAppAndShortcut(
false /* app_ready */, app_info.name, app_info.package_name,
......
......@@ -111,7 +111,10 @@ void ArcAppTest::SetUp(Profile* profile) {
app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_));
arc_service_manager_->arc_bridge_service()->app()->SetInstance(
app_instance_.get());
WaitForInstanceReady(arc_service_manager_->arc_bridge_service()->app());
// TODO(khmel): Resolve this gracefully. Set of default app tests does not
// expect waiting in ArcAppTest setup.
if (wait_default_apps_)
WaitForInstanceReady(arc_service_manager_->arc_bridge_service()->app());
}
void ArcAppTest::WaitForDefaultApps() {
......
......@@ -1945,6 +1945,23 @@ TEST_P(ArcDefaulAppTest, DefaultApps) {
}
}
TEST_P(ArcAppLauncherForDefaulAppTest, AppIconUpdated) {
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
ASSERT_NE(nullptr, prefs);
ASSERT_FALSE(fake_default_apps().empty());
const arc::mojom::AppInfo& app = fake_default_apps()[0];
const std::string app_id = ArcAppTest::GetAppId(app);
FakeAppIconLoaderDelegate icon_delegate;
ArcAppIconLoader icon_loader(profile(), app_list::kListIconSize,
&icon_delegate);
icon_loader.FetchImage(app_id);
arc_test()->WaitForDefaultApps();
icon_delegate.WaitForIconUpdates(1);
}
TEST_P(ArcAppLauncherForDefaulAppTest, AppLauncherForDefaultApps) {
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
ASSERT_NE(nullptr, prefs);
......
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