Commit 6731dc06 authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

Define macros to help instantiate system web app manager tests.

The current approach isn't maintainable, and a new param is needed for
better coverage of incognito and guest mode profiles.

Bug: b/166730281
Change-Id: Iea8b7ec6ced3867d83fc5224499830db9c6f53bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2397982
Commit-Queue: Trent Apted <tapted@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarJiewei Qian  <qjw@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805616}
parent 34d9af8e
......@@ -31,11 +31,5 @@ IN_PROC_BROWSER_TEST_P(DiagnosticsAppIntegrationTest,
web_app::SystemAppType::DIAGNOSTICS, url, "Diagnostics"));
}
INSTANTIATE_TEST_SUITE_P(
All,
DiagnosticsAppIntegrationTest,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
::testing::Values(web_app::InstallationType::kWebAppInfoInstall)),
web_app::ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P(
DiagnosticsAppIntegrationTest);
......@@ -398,14 +398,8 @@ IN_PROC_BROWSER_TEST_P(HelpAppIntegrationTest, HelpAppOpenKeyboardShortcut) {
#endif
}
INSTANTIATE_TEST_SUITE_P(
All,
HelpAppIntegrationTest,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
::testing::Values(web_app::InstallationType::kManifestInstall)),
web_app::ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P(
HelpAppIntegrationTest);
class HelpAppGuestSessionIntegrationTest : public HelpAppIntegrationTest {
protected:
......@@ -465,11 +459,5 @@ IN_PROC_BROWSER_TEST_P(HelpAppGuestSessionIntegrationTest,
WaitForAppToOpen(GURL("chrome://help-app/help/sub/3399710/id/9739838")));
}
INSTANTIATE_TEST_SUITE_P(
All,
HelpAppGuestSessionIntegrationTest,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
::testing::Values(web_app::InstallationType::kManifestInstall)),
web_app::ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P(
HelpAppGuestSessionIntegrationTest);
......@@ -453,20 +453,8 @@ IN_PROC_BROWSER_TEST_P(MediaAppIntegrationWithFilesAppTest, RenameFile) {
EXPECT_EQ(expected_contents, renamed_contents);
}
INSTANTIATE_TEST_SUITE_P(
All,
MediaAppIntegrationTest,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
::testing::Values(web_app::InstallationType::kWebAppInfoInstall)),
web_app::ProviderAndInstallationTypeToString);
INSTANTIATE_TEST_SUITE_P(
All,
MediaAppIntegrationWithFilesAppTest,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
::testing::Values(web_app::InstallationType::kWebAppInfoInstall)),
web_app::ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_WEB_APP_INFO_INSTALL_P(
MediaAppIntegrationTest);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_WEB_APP_INFO_INSTALL_P(
MediaAppIntegrationWithFilesAppTest);
......@@ -30,11 +30,5 @@ IN_PROC_BROWSER_TEST_P(PrintManagementAppIntegrationTest,
web_app::SystemAppType::PRINT_MANAGEMENT, url, "Print Jobs"));
}
INSTANTIATE_TEST_SUITE_P(
All,
PrintManagementAppIntegrationTest,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
::testing::Values(web_app::InstallationType::kManifestInstall)),
web_app::ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P(
PrintManagementAppIntegrationTest);
......@@ -18,11 +18,5 @@ IN_PROC_BROWSER_TEST_P(SampleSystemWebAppIntegrationTest, SampleSystemWebApp) {
web_app::SystemAppType::SAMPLE, url, "Sample System Web App"));
}
INSTANTIATE_TEST_SUITE_P(
All,
SampleSystemWebAppIntegrationTest,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
::testing::Values(web_app::InstallationType::kWebAppInfoInstall)),
web_app::ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P(
SampleSystemWebAppIntegrationTest);
......@@ -30,11 +30,5 @@ IN_PROC_BROWSER_TEST_P(ScanningAppIntegrationTest, ScanningAppInLauncher) {
ExpectSystemWebAppValid(web_app::SystemAppType::SCANNING, url, "Scan"));
}
INSTANTIATE_TEST_SUITE_P(
All,
ScanningAppIntegrationTest,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
::testing::Values(web_app::InstallationType::kWebAppInfoInstall)),
web_app::ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P(
ScanningAppIntegrationTest);
......@@ -57,11 +57,5 @@ IN_PROC_BROWSER_TEST_P(SettingsAppIntegrationTest, SettingsAppDisabled) {
web_contents->GetTitle());
}
INSTANTIATE_TEST_SUITE_P(
All,
SettingsAppIntegrationTest,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
::testing::Values(web_app::InstallationType::kManifestInstall)),
web_app::ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P(
SettingsAppIntegrationTest);
......@@ -91,16 +91,10 @@ class TelemetryExtensionWithDirIntegrationTest
}
};
INSTANTIATE_TEST_SUITE_P(
All,
TelemetryExtensionIntegrationTest,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
// TODO: Change this ::testing::Value(false) to
// ::testing::Bool() when a WebApplicationProvider is ready
::testing::Values(false)),
web_app::ProviderAndInstallationTypeToString);
// TODO: Change MANIFEST_INSTALL to ALL_INSTALL_TYPES when a
// WebApplicationProvider is ready.
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P(
TelemetryExtensionIntegrationTest);
// Tests that TelemetryExtensionUntrustedSource can successfully load a resource
// from disk.
......@@ -138,14 +132,7 @@ IN_PROC_BROWSER_TEST_P(
content::NavigateToURL(web_contents, non_existent_resource_gurl));
}
INSTANTIATE_TEST_SUITE_P(
All,
TelemetryExtensionWithDirIntegrationTest,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
// TODO: Change this ::testing::Values(kManifestInstall) to
// ::testing::Values(kManifestInstall, kWebAppInfoInstall) when a
// WebApplicationProvider is ready
::testing::Values(web_app::InstallationType::kManifestInstall)),
web_app::ProviderAndInstallationTypeToString);
// TODO: Change MANIFEST_INSTALL to ALL_INSTALL_TYPES when a
// WebApplicationProvider is ready.
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P(
TelemetryExtensionWithDirIntegrationTest);
......@@ -340,11 +340,5 @@ IN_PROC_BROWSER_TEST_P(SystemWebAppSessionRestoreTestChromeOS,
}
}
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppSessionRestoreTestChromeOS,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
::testing::Values(web_app::InstallationType::kManifestInstall)),
web_app::ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P(
SystemWebAppSessionRestoreTestChromeOS);
......@@ -43,11 +43,5 @@ IN_PROC_BROWSER_TEST_P(SystemWebAppNonClientFrameViewBrowserTest,
PageActionIconType::kNativeFileSystemAccess));
}
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppNonClientFrameViewBrowserTest,
::testing::Combine(
::testing::Values(web_app::ProviderType::kBookmarkApps,
web_app::ProviderType::kWebApps),
::testing::Values(web_app::InstallationType::kManifestInstall)),
web_app::ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P(
SystemWebAppNonClientFrameViewBrowserTest);
......@@ -419,13 +419,7 @@ IN_PROC_BROWSER_TEST_P(SystemWebAppLinkCaptureBrowserTest,
EXPECT_FALSE(app_browser->app_controller()->ShouldShowCustomTabBar());
}
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppLinkCaptureBrowserTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppLinkCaptureBrowserTest);
} // namespace web_app
......@@ -228,12 +228,10 @@ IN_PROC_BROWSER_TEST_P(SystemWebAppManagerWebAppInfoBrowserTest, Install) {
#endif // defined(OS_CHROMEOS)
}
// We test with and without enabling kDesktopPWAsWithoutExtensions.
std::string ProviderAndInstallationTypeToString(
const ::testing::TestParamInfo<ProviderTypeAndInstallationType>&
provider_type) {
std::string SystemWebAppManagerTestParamsToString(
const ::testing::TestParamInfo<SystemWebAppManagerTestParams>& param_info) {
std::string output;
switch (std::get<0>(provider_type.param)) {
switch (std::get<0>(param_info.param)) {
case ProviderType::kBookmarkApps:
output.append("BookmarkApps");
break;
......@@ -241,11 +239,9 @@ std::string ProviderAndInstallationTypeToString(
output.append("WebApps");
break;
}
if (std::get<1>(provider_type.param) ==
InstallationType::kWebAppInfoInstall) {
if (std::get<1>(param_info.param) == InstallationType::kWebAppInfoInstall) {
output.append("_WebAppInfoInstall");
}
return output;
}
......@@ -355,7 +351,7 @@ IN_PROC_BROWSER_TEST_P(SystemWebAppManagerWebAppInfoBrowserTest,
// policies.
class SystemWebAppManagerFileHandlingBrowserTestBase
: public SystemWebAppManagerBrowserTestBase,
public ::testing::WithParamInterface<ProviderTypeAndInstallationType> {
public ::testing::WithParamInterface<SystemWebAppManagerTestParams> {
public:
using IncludeLaunchDirectory =
TestSystemWebAppInstallation::IncludeLaunchDirectory;
......@@ -1511,127 +1507,49 @@ IN_PROC_BROWSER_TEST_P(SystemWebAppManagerAppSuspensionBrowserTest,
GetAppIconKey(*settings_id)->icon_effects);
}
// This feature will only work when DesktopPWAsWithoutExtensions launches.
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerAppSuspensionBrowserTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerAppSuspensionBrowserTest);
#endif // defined(OS_CHROMEOS)
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerWebAppInfoBrowserTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerLaunchFilesBrowserTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerLaunchDirectoryBrowserTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerWebAppInfoBrowserTest);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerLaunchFilesBrowserTest);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerLaunchDirectoryBrowserTest);
#if defined(OS_CHROMEOS)
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerLaunchDirectoryFileSystemProviderBrowserTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerLaunchDirectoryFileSystemProviderBrowserTest);
#endif
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerNotShownInLauncherTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerNotShownInSearchTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerAdditionalSearchTermsTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerChromeUntrustedTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerOriginTrialsBrowserTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerFileHandlingOriginTrialsBrowserTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerUninstallBrowserTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerNotShownInLauncherTest);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerNotShownInSearchTest);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerAdditionalSearchTermsTest);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerChromeUntrustedTest);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerOriginTrialsBrowserTest);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerFileHandlingOriginTrialsBrowserTest);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerUninstallBrowserTest);
#if defined(OS_CHROMEOS)
INSTANTIATE_TEST_SUITE_P(
All,
SystemWebAppManagerUpgradeBrowserTest,
::testing::Combine(::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
::testing::Values(InstallationType::kManifestInstall,
InstallationType::kWebAppInfoInstall)),
ProviderAndInstallationTypeToString);
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P(
SystemWebAppManagerUpgradeBrowserTest);
#endif
} // namespace web_app
......@@ -102,18 +102,16 @@ class SystemWebAppManagerBrowserTestBase : public InProcessBrowserTest {
enum class InstallationType { kManifestInstall, kWebAppInfoInstall };
using ProviderTypeAndInstallationType =
std::tuple<web_app::ProviderType, InstallationType>;
using SystemWebAppManagerTestParams =
std::tuple<ProviderType, InstallationType>;
class SystemWebAppManagerBrowserTest
: public SystemWebAppManagerBrowserTestBase,
public ::testing::WithParamInterface<ProviderTypeAndInstallationType> {
public ::testing::WithParamInterface<SystemWebAppManagerTestParams> {
public:
explicit SystemWebAppManagerBrowserTest(bool install_mock = true);
~SystemWebAppManagerBrowserTest() override = default;
web_app::ProviderType provider_type() const {
return std::get<0>(GetParam());
}
ProviderType provider_type() const { return std::get<0>(GetParam()); }
bool install_from_web_app_info() const {
return std::get<1>(GetParam()) == InstallationType::kWebAppInfoInstall;
}
......@@ -124,9 +122,41 @@ class SystemWebAppManagerBrowserTest
using SystemWebAppManagerWebAppInfoBrowserTest = SystemWebAppManagerBrowserTest;
std::string ProviderAndInstallationTypeToString(
const ::testing::TestParamInfo<ProviderTypeAndInstallationType>&
provider_type);
std::string SystemWebAppManagerTestParamsToString(
const ::testing::TestParamInfo<SystemWebAppManagerTestParams>& param_info);
} // namespace web_app
#define INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_P(SUITE, PARAMS) \
INSTANTIATE_TEST_SUITE_P(All, SUITE, PARAMS, \
web_app::SystemWebAppManagerTestParamsToString)
#define INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_ALL_INSTALL_TYPES_P( \
SUITE) \
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_P( \
SUITE, \
::testing::Combine( \
::testing::Values(web_app::ProviderType::kBookmarkApps, \
web_app::ProviderType::kWebApps), \
::testing::Values(web_app::InstallationType::kManifestInstall, \
web_app::InstallationType::kWebAppInfoInstall)))
#define INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_MANIFEST_INSTALL_P( \
SUITE) \
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_P( \
SUITE, \
::testing::Combine( \
::testing::Values(web_app::ProviderType::kBookmarkApps, \
web_app::ProviderType::kWebApps), \
::testing::Values(web_app::InstallationType::kManifestInstall)))
#define INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_WEB_APP_INFO_INSTALL_P( \
SUITE) \
INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_P( \
SUITE, \
::testing::Combine( \
::testing::Values(web_app::ProviderType::kBookmarkApps, \
web_app::ProviderType::kWebApps), \
::testing::Values(web_app::InstallationType::kWebAppInfoInstall)))
#endif // CHROME_BROWSER_WEB_APPLICATIONS_SYSTEM_WEB_APP_MANAGER_BROWSERTEST_H_
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