Commit f8374c81 authored by Jiewei Qian's avatar Jiewei Qian Committed by Commit Bot

system-web-apps: avoid calling SynchronizeInstallApps twice in SWA upgrade test

By default, we use an empty SWA list in test. When the test chrome
process starts, SystemWebAppManager first calls SynchronizeInstalledApps
with an empty list. In the upgrade test, this cause previously installed
apps to be uninstalled.

In the test body, we then use InstallSystemAppsForTesting to install the
real system apps. This effectively installs apps on a clean state, and
defeats the purpose of this test.

This CL adds a check so SystemWebAppManager uses the real SWA list, if
EnableAllSystemWebApps feature is enabled.

Fixed: 1143108
Change-Id: I7f60429bcae45c011eb0681a6d8c322e898a32c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2503374Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: Jiewei Qian  <qjw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822047}
parent 660c7da9
......@@ -381,7 +381,10 @@ SystemWebAppManager::SystemWebAppManager(Profile* profile)
// Always update in tests.
update_policy_ = UpdatePolicy::kAlwaysUpdate;
// Return early to avoid populating with real system apps.
// Populate with real system apps if the test asks for it.
if (base::FeatureList::IsEnabled(features::kEnableAllSystemWebApps))
system_app_infos_ = CreateSystemWebApps();
return;
}
......
......@@ -1104,18 +1104,29 @@ class SystemWebAppManagerUpgradeBrowserTest
}
~SystemWebAppManagerUpgradeBrowserTest() override = default;
// Don't use WaitForTestSystemAppInstall in this test, because it artificially
// resets the OnAppsSynchronized signal, and starts a new synchronize request.
void WaitForSystemAppsSynchronized() {
base::RunLoop run_loop;
WebAppProvider::Get(browser()->profile())
->system_web_app_manager()
.on_apps_synchronized()
.Post(FROM_HERE, run_loop.QuitClosure());
run_loop.Run();
}
private:
base::test::ScopedFeatureList features_;
};
IN_PROC_BROWSER_TEST_P(SystemWebAppManagerUpgradeBrowserTest, PRE_Upgrade) {
WaitForTestSystemAppInstall();
WaitForSystemAppsSynchronized();
EXPECT_GE(GetManager().GetRegisteredSystemAppsForTesting().size(),
GetManager().GetAppIds().size());
}
IN_PROC_BROWSER_TEST_P(SystemWebAppManagerUpgradeBrowserTest, Upgrade) {
WaitForTestSystemAppInstall();
WaitForSystemAppsSynchronized();
const auto& app_ids = GetManager().GetAppIds();
EXPECT_EQ(GetManager().GetRegisteredSystemAppsForTesting().size(),
......
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