Commit dd815982 authored by Lorne Mitchell's avatar Lorne Mitchell Committed by Commit Bot

dpwa: Forked system_web_app_manager_unittest.cc to support BMO.

Reworked system_web_app_manager_unittest.cc tests using the TestWebAppRegistryController.

Bug: 1082880,1088399
Change-Id: Ibe566c76b520f0b7d5177059bc0aa847fc20215f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2223978Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Commit-Queue: Lorne Mitchell <lomitch@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#784436}
parent 84bb7b68
...@@ -194,6 +194,7 @@ source_set("web_applications_unit_tests") { ...@@ -194,6 +194,7 @@ source_set("web_applications_unit_tests") {
"daily_metrics_helper_unittest.cc", "daily_metrics_helper_unittest.cc",
"external_web_app_manager_unittest.cc", "external_web_app_manager_unittest.cc",
"pending_app_manager_impl_unittest.cc", "pending_app_manager_impl_unittest.cc",
"system_web_app_manager_unittest.cc",
"web_app_database_unittest.cc", "web_app_database_unittest.cc",
"web_app_icon_manager_unittest.cc", "web_app_icon_manager_unittest.cc",
"web_app_install_manager_unittest.cc", "web_app_install_manager_unittest.cc",
......
...@@ -52,7 +52,9 @@ source_set("unit_tests") { ...@@ -52,7 +52,9 @@ source_set("unit_tests") {
"externally_installed_web_app_prefs_unittest.cc", "externally_installed_web_app_prefs_unittest.cc",
"install_manager_bookmark_app_unittest.cc", "install_manager_bookmark_app_unittest.cc",
"pending_app_install_task_unittest.cc", "pending_app_install_task_unittest.cc",
"system_web_app_manager_unittest.cc",
# TODO(crbug.com/1065748): Delete this deprecated unit tests file.
"system_web_app_manager_bookmark_apps_unittest.cc",
"web_app_policy_manager_unittest.cc", "web_app_policy_manager_unittest.cc",
"web_app_provider_unittest.cc", "web_app_provider_unittest.cc",
] ]
......
...@@ -71,23 +71,16 @@ ExternalInstallOptions GetWindowedInstallOptions() { ...@@ -71,23 +71,16 @@ ExternalInstallOptions GetWindowedInstallOptions() {
} // namespace } // namespace
class SystemWebAppManagerTest // TODO(crbug.com/1065748): Deprecated. Delete these tests and the test fixture.
: public ChromeRenderViewHostTestHarness, class SystemWebAppManagerTestBookmarkApps
public ::testing::WithParamInterface<ProviderType> { : public ChromeRenderViewHostTestHarness {
public: public:
SystemWebAppManagerTest() { SystemWebAppManagerTestBookmarkApps() {
if (GetParam() == ProviderType::kWebApps) { scoped_feature_list_.InitWithFeatures(
scoped_feature_list_.InitWithFeatures( {features::kSystemWebApps}, {features::kDesktopPWAsWithoutExtensions});
{features::kSystemWebApps, features::kDesktopPWAsWithoutExtensions},
{});
} else if (GetParam() == ProviderType::kBookmarkApps) {
scoped_feature_list_.InitWithFeatures(
{features::kSystemWebApps},
{features::kDesktopPWAsWithoutExtensions});
}
} }
~SystemWebAppManagerTest() override = default; ~SystemWebAppManagerTestBookmarkApps() override = default;
void SetUp() override { void SetUp() override {
ChromeRenderViewHostTestHarness::SetUp(); ChromeRenderViewHostTestHarness::SetUp();
...@@ -148,11 +141,13 @@ class SystemWebAppManagerTest ...@@ -148,11 +141,13 @@ class SystemWebAppManagerTest
TestSystemWebAppManager* system_web_app_manager_ = nullptr; TestSystemWebAppManager* system_web_app_manager_ = nullptr;
TestWebAppUiManager* ui_manager_ = nullptr; TestWebAppUiManager* ui_manager_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(SystemWebAppManagerTest); DISALLOW_COPY_AND_ASSIGN(SystemWebAppManagerTestBookmarkApps);
}; };
// Deprecated. See corresponding SystemWebAppManagerTest.Disabled test for web
// apps.
// Test that System Apps are uninstalled with the feature disabled. // Test that System Apps are uninstalled with the feature disabled.
TEST_P(SystemWebAppManagerTest, Disabled) { TEST_F(SystemWebAppManagerTestBookmarkApps, Disabled) {
base::test::ScopedFeatureList disable_feature_list; base::test::ScopedFeatureList disable_feature_list;
disable_feature_list.InitWithFeatures({}, {features::kSystemWebApps}); disable_feature_list.InitWithFeatures({}, {features::kSystemWebApps});
...@@ -177,8 +172,10 @@ TEST_P(SystemWebAppManagerTest, Disabled) { ...@@ -177,8 +172,10 @@ TEST_P(SystemWebAppManagerTest, Disabled) {
pending_app_manager()->uninstall_requests()); pending_app_manager()->uninstall_requests());
} }
// Deprecated. See corresponding SystemWebAppManagerTest.Enabled test for web
// apps.
// Test that System Apps do install with the feature enabled. // Test that System Apps do install with the feature enabled.
TEST_P(SystemWebAppManagerTest, Enabled) { TEST_F(SystemWebAppManagerTestBookmarkApps, Enabled) {
base::flat_map<SystemAppType, SystemAppInfo> system_apps; base::flat_map<SystemAppType, SystemAppInfo> system_apps;
system_apps.emplace(SystemAppType::SETTINGS, system_apps.emplace(SystemAppType::SETTINGS,
SystemAppInfo(kSettingsAppNameForLogging, AppUrl1())); SystemAppInfo(kSettingsAppNameForLogging, AppUrl1()));
...@@ -194,7 +191,8 @@ TEST_P(SystemWebAppManagerTest, Enabled) { ...@@ -194,7 +191,8 @@ TEST_P(SystemWebAppManagerTest, Enabled) {
} }
// Test that changing the set of System Apps uninstalls apps. // Test that changing the set of System Apps uninstalls apps.
TEST_P(SystemWebAppManagerTest, UninstallAppInstalledInPreviousSession) { TEST_F(SystemWebAppManagerTestBookmarkApps,
UninstallAppInstalledInPreviousSession) {
// Simulate System Apps and a regular app that were installed in the // Simulate System Apps and a regular app that were installed in the
// previous session. // previous session.
SimulatePreviouslyInstalledApp(AppUrl1(), SimulatePreviouslyInstalledApp(AppUrl1(),
...@@ -224,7 +222,7 @@ TEST_P(SystemWebAppManagerTest, UninstallAppInstalledInPreviousSession) { ...@@ -224,7 +222,7 @@ TEST_P(SystemWebAppManagerTest, UninstallAppInstalledInPreviousSession) {
pending_app_manager()->uninstall_requests()); pending_app_manager()->uninstall_requests());
} }
TEST_P(SystemWebAppManagerTest, AlwaysUpdate) { TEST_F(SystemWebAppManagerTestBookmarkApps, AlwaysUpdate) {
system_web_app_manager()->SetUpdatePolicy( system_web_app_manager()->SetUpdatePolicy(
SystemWebAppManager::UpdatePolicy::kAlwaysUpdate); SystemWebAppManager::UpdatePolicy::kAlwaysUpdate);
...@@ -267,7 +265,7 @@ TEST_P(SystemWebAppManagerTest, AlwaysUpdate) { ...@@ -267,7 +265,7 @@ TEST_P(SystemWebAppManagerTest, AlwaysUpdate) {
EXPECT_EQ(5u, pending_app_manager()->install_requests().size()); EXPECT_EQ(5u, pending_app_manager()->install_requests().size());
} }
TEST_P(SystemWebAppManagerTest, UpdateOnVersionChange) { TEST_F(SystemWebAppManagerTestBookmarkApps, UpdateOnVersionChange) {
const std::vector<ExternalInstallOptions>& install_requests = const std::vector<ExternalInstallOptions>& install_requests =
pending_app_manager()->install_requests(); pending_app_manager()->install_requests();
...@@ -352,7 +350,7 @@ TEST_P(SystemWebAppManagerTest, UpdateOnVersionChange) { ...@@ -352,7 +350,7 @@ TEST_P(SystemWebAppManagerTest, UpdateOnVersionChange) {
EXPECT_TRUE(IsInstalled(AppUrl3())); EXPECT_TRUE(IsInstalled(AppUrl3()));
} }
TEST_P(SystemWebAppManagerTest, UpdateOnLocaleChange) { TEST_F(SystemWebAppManagerTestBookmarkApps, UpdateOnLocaleChange) {
const std::vector<ExternalInstallOptions>& install_requests = const std::vector<ExternalInstallOptions>& install_requests =
pending_app_manager()->install_requests(); pending_app_manager()->install_requests();
...@@ -393,7 +391,7 @@ TEST_P(SystemWebAppManagerTest, UpdateOnLocaleChange) { ...@@ -393,7 +391,7 @@ TEST_P(SystemWebAppManagerTest, UpdateOnLocaleChange) {
EXPECT_FALSE(install_requests[2].force_reinstall); EXPECT_FALSE(install_requests[2].force_reinstall);
} }
TEST_P(SystemWebAppManagerTest, InstallResultHistogram) { TEST_F(SystemWebAppManagerTestBookmarkApps, InstallResultHistogram) {
base::HistogramTester histograms; base::HistogramTester histograms;
const std::string settings_app_install_result_histogram = const std::string settings_app_install_result_histogram =
std::string(SystemWebAppManager::kInstallResultHistogramName) + ".Apps." + std::string(SystemWebAppManager::kInstallResultHistogramName) + ".Apps." +
...@@ -500,10 +498,4 @@ TEST_P(SystemWebAppManagerTest, InstallResultHistogram) { ...@@ -500,10 +498,4 @@ TEST_P(SystemWebAppManagerTest, InstallResultHistogram) {
} }
} }
// TODO(crbug.com/1082880): Test with BMO enabled.
INSTANTIATE_TEST_SUITE_P(All,
SystemWebAppManagerTest,
::testing::Values(ProviderType::kBookmarkApps),
ProviderTypeParamToString);
} // namespace web_app } // namespace web_app
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