Commit 309e8d55 authored by Eric Willigers's avatar Eric Willigers Committed by Commit Bot

Desktop PWAs: AppServiceWrapperTest cleanup

DesktopPWAsWithoutExtensions has shipped. The test no
longer needs to be paramaterized.


Bug: 1065748
Change-Id: Ie4d7ce9659179e6f925d21533c198f0c0030590d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2454595
Auto-Submit: Eric Willigers <ericwilligers@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814719}
parent 95b31038
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "chrome/browser/web_applications/test/test_system_web_app_manager.h" #include "chrome/browser/web_applications/test/test_system_web_app_manager.h"
#include "chrome/browser/web_applications/test/test_web_app_provider.h" #include "chrome/browser/web_applications/test/test_web_app_provider.h"
#include "chrome/browser/web_applications/test/web_app_install_test_utils.h" #include "chrome/browser/web_applications/test/web_app_install_test_utils.h"
#include "chrome/browser/web_applications/test/web_app_test.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/arc/mojom/app.mojom.h" #include "components/arc/mojom/app.mojom.h"
...@@ -49,7 +48,6 @@ ...@@ -49,7 +48,6 @@
#include "url/gurl.h" #include "url/gurl.h"
using web_app::GenerateAppIdFromURL; using web_app::GenerateAppIdFromURL;
using web_app::ProviderType;
using web_app::WebAppProviderBase; using web_app::WebAppProviderBase;
namespace chromeos { namespace chromeos {
...@@ -73,7 +71,7 @@ constexpr char kWebAppName2[] = "WebApp2"; ...@@ -73,7 +71,7 @@ constexpr char kWebAppName2[] = "WebApp2";
} // namespace } // namespace
class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> { class AppServiceWrapperTest : public ::testing::Test {
public: public:
class MockListener : public AppServiceWrapper::EventListener { class MockListener : public AppServiceWrapper::EventListener {
public: public:
...@@ -89,16 +87,7 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> { ...@@ -89,16 +87,7 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> {
}; };
protected: protected:
AppServiceWrapperTest() { AppServiceWrapperTest() = default;
if (GetParam() == ProviderType::kWebApps) {
scoped_feature_list_.InitAndEnableFeature(
features::kDesktopPWAsWithoutExtensions);
} else if (GetParam() == ProviderType::kBookmarkApps) {
scoped_feature_list_.InitAndDisableFeature(
features::kDesktopPWAsWithoutExtensions);
}
}
AppServiceWrapperTest(const AppServiceWrapperTest&) = delete; AppServiceWrapperTest(const AppServiceWrapperTest&) = delete;
AppServiceWrapperTest& operator=(const AppServiceWrapperTest&) = delete; AppServiceWrapperTest& operator=(const AppServiceWrapperTest&) = delete;
~AppServiceWrapperTest() override = default; ~AppServiceWrapperTest() override = default;
...@@ -120,8 +109,7 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> { ...@@ -120,8 +109,7 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> {
base::CommandLine::ForCurrentProcess(), base::FilePath(), false); base::CommandLine::ForCurrentProcess(), base::FilePath(), false);
extension_service_->Init(); extension_service_->Init();
if (base::FeatureList::IsEnabled(features::kDesktopPWAsWithoutExtensions)) ConfigureWebAppProvider();
ConfigureWebAppProvider();
app_service_test_.SetUp(&profile_); app_service_test_.SetUp(&profile_);
arc_test_.SetUp(&profile_); arc_test_.SetUp(&profile_);
...@@ -168,8 +156,7 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> { ...@@ -168,8 +156,7 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> {
return; return;
} }
if (base::FeatureList::IsEnabled(features::kDesktopPWAsWithoutExtensions) && if (app_id.app_type() == apps::mojom::AppType::kWeb) {
app_id.app_type() == apps::mojom::AppType::kWeb) {
DCHECK(url.has_value()); DCHECK(url.has_value());
const web_app::AppId installed_app_id = const web_app::AppId installed_app_id =
web_app::InstallDummyWebApp(&profile_, app_name, GURL(url.value())); web_app::InstallDummyWebApp(&profile_, app_name, GURL(url.value()));
...@@ -195,8 +182,7 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> { ...@@ -195,8 +182,7 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> {
return; return;
} }
if (base::FeatureList::IsEnabled(features::kDesktopPWAsWithoutExtensions) && if (app_id.app_type() == apps::mojom::AppType::kWeb) {
app_id.app_type() == apps::mojom::AppType::kWeb) {
base::RunLoop run_loop; base::RunLoop run_loop;
WebAppProviderBase::GetProviderBase(&profile_) WebAppProviderBase::GetProviderBase(&profile_)
->install_finalizer() ->install_finalizer()
...@@ -233,8 +219,7 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> { ...@@ -233,8 +219,7 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> {
return; return;
} }
if (base::FeatureList::IsEnabled(features::kDesktopPWAsWithoutExtensions) && if (app_id.app_type() == apps::mojom::AppType::kWeb) {
app_id.app_type() == apps::mojom::AppType::kWeb) {
WebAppProviderBase::GetProviderBase(&profile_) WebAppProviderBase::GetProviderBase(&profile_)
->registry_controller() ->registry_controller()
.SetAppIsDisabled(app_id.app_id(), disabled); .SetAppIsDisabled(app_id.app_id(), disabled);
...@@ -267,7 +252,6 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> { ...@@ -267,7 +252,6 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> {
provider->Start(); provider->Start();
} }
base::test::ScopedFeatureList scoped_feature_list_;
content::BrowserTaskEnvironment task_environment_; content::BrowserTaskEnvironment task_environment_;
base::test::ScopedFeatureList feature_list_; base::test::ScopedFeatureList feature_list_;
...@@ -282,7 +266,7 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> { ...@@ -282,7 +266,7 @@ class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> {
}; };
// Tests GetInstalledApps() method. // Tests GetInstalledApps() method.
TEST_P(AppServiceWrapperTest, GetInstalledApps) { TEST_F(AppServiceWrapperTest, GetInstalledApps) {
// Chrome is the only 'preinstalled' app. // Chrome is the only 'preinstalled' app.
const AppId chrome = const AppId chrome =
AppId(apps::mojom::AppType::kExtension, extension_misc::kChromeAppId); AppId(apps::mojom::AppType::kExtension, extension_misc::kChromeAppId);
...@@ -318,7 +302,7 @@ TEST_P(AppServiceWrapperTest, GetInstalledApps) { ...@@ -318,7 +302,7 @@ TEST_P(AppServiceWrapperTest, GetInstalledApps) {
} }
} }
TEST_P(AppServiceWrapperTest, GetAppName) { TEST_F(AppServiceWrapperTest, GetAppName) {
const AppId chrome(apps::mojom::AppType::kExtension, const AppId chrome(apps::mojom::AppType::kExtension,
extension_misc::kChromeAppId); extension_misc::kChromeAppId);
EXPECT_EQ(kExtensionNameChrome, tested_wrapper().GetAppName(chrome)); EXPECT_EQ(kExtensionNameChrome, tested_wrapper().GetAppName(chrome));
...@@ -344,7 +328,7 @@ TEST_P(AppServiceWrapperTest, GetAppName) { ...@@ -344,7 +328,7 @@ TEST_P(AppServiceWrapperTest, GetAppName) {
} }
// Tests installs and uninstalls of Arc apps. // Tests installs and uninstalls of Arc apps.
TEST_P(AppServiceWrapperTest, ArcAppInstallation) { TEST_F(AppServiceWrapperTest, ArcAppInstallation) {
// Only Chrome installed. // Only Chrome installed.
EXPECT_EQ(1u, tested_wrapper().GetInstalledApps().size()); EXPECT_EQ(1u, tested_wrapper().GetInstalledApps().size());
...@@ -376,7 +360,7 @@ TEST_P(AppServiceWrapperTest, ArcAppInstallation) { ...@@ -376,7 +360,7 @@ TEST_P(AppServiceWrapperTest, ArcAppInstallation) {
} }
// Tests installs and uninstalls of web apps. // Tests installs and uninstalls of web apps.
TEST_P(AppServiceWrapperTest, WebAppInstallation) { TEST_F(AppServiceWrapperTest, WebAppInstallation) {
// Only Chrome installed. // Only Chrome installed.
EXPECT_EQ(1u, tested_wrapper().GetInstalledApps().size()); EXPECT_EQ(1u, tested_wrapper().GetInstalledApps().size());
...@@ -409,7 +393,7 @@ TEST_P(AppServiceWrapperTest, WebAppInstallation) { ...@@ -409,7 +393,7 @@ TEST_P(AppServiceWrapperTest, WebAppInstallation) {
EXPECT_TRUE(base::Contains(installed_apps, app2)); EXPECT_TRUE(base::Contains(installed_apps, app2));
} }
TEST_P(AppServiceWrapperTest, ArcAppDisabled) { TEST_F(AppServiceWrapperTest, ArcAppDisabled) {
// Install ARC app. // Install ARC app.
const AppId app(apps::mojom::AppType::kArc, kArcPackage1); const AppId app(apps::mojom::AppType::kArc, kArcPackage1);
EXPECT_CALL(test_listener(), OnAppInstalled(app)).Times(1); EXPECT_CALL(test_listener(), OnAppInstalled(app)).Times(1);
...@@ -424,7 +408,7 @@ TEST_P(AppServiceWrapperTest, ArcAppDisabled) { ...@@ -424,7 +408,7 @@ TEST_P(AppServiceWrapperTest, ArcAppDisabled) {
SimulateAppDisabled(app, kArcApp1, false); SimulateAppDisabled(app, kArcApp1, false);
} }
TEST_P(AppServiceWrapperTest, WebAppDisabled) { TEST_F(AppServiceWrapperTest, WebAppDisabled) {
// Install web app. // Install web app.
const AppId app(apps::mojom::AppType::kWeb, const AppId app(apps::mojom::AppType::kWeb,
GenerateAppIdFromURL(GURL(kWebAppUrl1))); GenerateAppIdFromURL(GURL(kWebAppUrl1)));
...@@ -441,7 +425,7 @@ TEST_P(AppServiceWrapperTest, WebAppDisabled) { ...@@ -441,7 +425,7 @@ TEST_P(AppServiceWrapperTest, WebAppDisabled) {
} }
// PATL v1 does not support 'extensions' other than Chrome. // PATL v1 does not support 'extensions' other than Chrome.
TEST_P(AppServiceWrapperTest, IgnoreOtherExtensions) { TEST_F(AppServiceWrapperTest, IgnoreOtherExtensions) {
const AppId chrome(apps::mojom::AppType::kExtension, const AppId chrome(apps::mojom::AppType::kExtension,
extension_misc::kChromeAppId); extension_misc::kChromeAppId);
std::vector<AppId> installed_apps = tested_wrapper().GetInstalledApps(); std::vector<AppId> installed_apps = tested_wrapper().GetInstalledApps();
...@@ -464,11 +448,5 @@ TEST_P(AppServiceWrapperTest, IgnoreOtherExtensions) { ...@@ -464,11 +448,5 @@ TEST_P(AppServiceWrapperTest, IgnoreOtherExtensions) {
// TODO(agawronska): Add tests for ARC apps activity once crrev.com/c/1906614 is // TODO(agawronska): Add tests for ARC apps activity once crrev.com/c/1906614 is
// landed. // landed.
INSTANTIATE_TEST_SUITE_P(All,
AppServiceWrapperTest,
::testing::Values(ProviderType::kBookmarkApps,
ProviderType::kWebApps),
web_app::ProviderTypeParamToString);
} // namespace app_time } // namespace app_time
} // namespace chromeos } // namespace chromeos
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