Commit c68fccf2 authored by Eric Willigers's avatar Eric Willigers Committed by Commit Bot

Desktop PWAs: Parameterize unit tests for BMO

This CL is in preparation for enabling the Bookmark Apps
without Extensions (BMO) flag "DesktopPWAsWithoutExtensions",
to maximize time on Canary.

Each unit test that does not yet pass with the
DesktopPWAsWithoutExtensions flag enabled is parameterized
and a TODO is added.

We will work over the next few weeks to update these unit
tests, or their test intrastructure, so they pass with the
flag enabled.


Bug: 877898
Change-Id: I1835b78c12429d2372377b609ae9b7d187aec695
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2206298
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769965}
parent 76ab913a
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "chrome/browser/extensions/test_extension_system.h" #include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/ui/app_list/arc/arc_app_test.h" #include "chrome/browser/ui/app_list/arc/arc_app_test.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h" #include "chrome/browser/web_applications/components/web_app_helpers.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/services/app_service/public/cpp/app_update.h" #include "chrome/services/app_service/public/cpp/app_update.h"
#include "chrome/services/app_service/public/mojom/types.mojom.h" #include "chrome/services/app_service/public/mojom/types.mojom.h"
...@@ -36,6 +37,8 @@ ...@@ -36,6 +37,8 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h" #include "url/gurl.h"
using web_app::ProviderType;
namespace chromeos { namespace chromeos {
namespace app_time { namespace app_time {
...@@ -57,7 +60,7 @@ constexpr char kWebAppName2[] = "WebApp2"; ...@@ -57,7 +60,7 @@ constexpr char kWebAppName2[] = "WebApp2";
} // namespace } // namespace
class AppServiceWrapperTest : public testing::Test { class AppServiceWrapperTest : public ::testing::TestWithParam<ProviderType> {
public: public:
class MockListener : public AppServiceWrapper::EventListener { class MockListener : public AppServiceWrapper::EventListener {
public: public:
...@@ -73,7 +76,16 @@ class AppServiceWrapperTest : public testing::Test { ...@@ -73,7 +76,16 @@ class AppServiceWrapperTest : public testing::Test {
}; };
protected: protected:
AppServiceWrapperTest() = default; AppServiceWrapperTest() {
if (GetParam() == web_app::ProviderType::kWebApps) {
scoped_feature_list_.InitAndEnableFeature(
features::kDesktopPWAsWithoutExtensions);
} else if (GetParam() == web_app::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;
...@@ -193,6 +205,7 @@ class AppServiceWrapperTest : public testing::Test { ...@@ -193,6 +205,7 @@ class AppServiceWrapperTest : public testing::Test {
} }
private: private:
base::test::ScopedFeatureList scoped_feature_list_;
content::BrowserTaskEnvironment task_environment_; content::BrowserTaskEnvironment task_environment_;
base::test::ScopedFeatureList feature_list_; base::test::ScopedFeatureList feature_list_;
...@@ -207,7 +220,7 @@ class AppServiceWrapperTest : public testing::Test { ...@@ -207,7 +220,7 @@ class AppServiceWrapperTest : public testing::Test {
}; };
// Tests GetInstalledApps() method. // Tests GetInstalledApps() method.
TEST_F(AppServiceWrapperTest, GetInstalledApps) { TEST_P(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);
...@@ -243,7 +256,7 @@ TEST_F(AppServiceWrapperTest, GetInstalledApps) { ...@@ -243,7 +256,7 @@ TEST_F(AppServiceWrapperTest, GetInstalledApps) {
} }
} }
TEST_F(AppServiceWrapperTest, GetAppName) { TEST_P(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));
...@@ -269,7 +282,7 @@ TEST_F(AppServiceWrapperTest, GetAppName) { ...@@ -269,7 +282,7 @@ TEST_F(AppServiceWrapperTest, GetAppName) {
} }
// Tests installs and uninstalls of Arc apps. // Tests installs and uninstalls of Arc apps.
TEST_F(AppServiceWrapperTest, ArcAppInstallation) { TEST_P(AppServiceWrapperTest, ArcAppInstallation) {
// Only Chrome installed. // Only Chrome installed.
EXPECT_EQ(1u, tested_wrapper().GetInstalledApps().size()); EXPECT_EQ(1u, tested_wrapper().GetInstalledApps().size());
...@@ -301,7 +314,7 @@ TEST_F(AppServiceWrapperTest, ArcAppInstallation) { ...@@ -301,7 +314,7 @@ TEST_F(AppServiceWrapperTest, ArcAppInstallation) {
} }
// Tests installs and uninstalls of web apps. // Tests installs and uninstalls of web apps.
TEST_F(AppServiceWrapperTest, WebAppInstallation) { TEST_P(AppServiceWrapperTest, WebAppInstallation) {
// Only Chrome installed. // Only Chrome installed.
EXPECT_EQ(1u, tested_wrapper().GetInstalledApps().size()); EXPECT_EQ(1u, tested_wrapper().GetInstalledApps().size());
...@@ -334,7 +347,7 @@ TEST_F(AppServiceWrapperTest, WebAppInstallation) { ...@@ -334,7 +347,7 @@ TEST_F(AppServiceWrapperTest, WebAppInstallation) {
EXPECT_TRUE(base::Contains(installed_apps, app2)); EXPECT_TRUE(base::Contains(installed_apps, app2));
} }
TEST_F(AppServiceWrapperTest, ArcAppDisabled) { TEST_P(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);
...@@ -349,7 +362,7 @@ TEST_F(AppServiceWrapperTest, ArcAppDisabled) { ...@@ -349,7 +362,7 @@ TEST_F(AppServiceWrapperTest, ArcAppDisabled) {
SimulateAppDisabled(app, kArcApp1, false); SimulateAppDisabled(app, kArcApp1, false);
} }
TEST_F(AppServiceWrapperTest, WebAppDisabled) { TEST_P(AppServiceWrapperTest, WebAppDisabled) {
// Install web app. // Install web app.
const AppId app(apps::mojom::AppType::kWeb, const AppId app(apps::mojom::AppType::kWeb,
web_app::GenerateAppIdFromURL(GURL(kWebAppUrl1))); web_app::GenerateAppIdFromURL(GURL(kWebAppUrl1)));
...@@ -366,7 +379,7 @@ TEST_F(AppServiceWrapperTest, WebAppDisabled) { ...@@ -366,7 +379,7 @@ TEST_F(AppServiceWrapperTest, WebAppDisabled) {
} }
// PATL v1 does not support 'extensions' other than Chrome. // PATL v1 does not support 'extensions' other than Chrome.
TEST_F(AppServiceWrapperTest, IgnoreOtherExtensions) { TEST_P(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();
...@@ -389,5 +402,11 @@ TEST_F(AppServiceWrapperTest, IgnoreOtherExtensions) { ...@@ -389,5 +402,11 @@ TEST_F(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.
// TODO(crbug.com/1082878): Test with BMO enabled.
INSTANTIATE_TEST_SUITE_P(All,
AppServiceWrapperTest,
::testing::Values(ProviderType::kBookmarkApps),
web_app::ProviderTypeParamToString);
} // namespace app_time } // namespace app_time
} // namespace chromeos } // namespace chromeos
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "chrome/browser/web_applications/test/test_app_registrar.h" #include "chrome/browser/web_applications/test/test_app_registrar.h"
#include "chrome/browser/web_applications/test/test_file_handler_manager.h" #include "chrome/browser/web_applications/test/test_file_handler_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_test.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
#include "extensions/browser/entry_info.h" #include "extensions/browser/entry_info.h"
...@@ -23,22 +25,34 @@ ...@@ -23,22 +25,34 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/features.h"
using web_app::ProviderType;
namespace file_manager { namespace file_manager {
namespace file_tasks { namespace file_tasks {
class WebFileTasksTest : public testing::Test { class WebFileTasksTest : public ::testing::TestWithParam<ProviderType> {
protected: protected:
WebFileTasksTest() {} WebFileTasksTest() {
if (GetParam() == web_app::ProviderType::kWebApps) {
scoped_feature_list_.InitAndEnableFeature(
features::kDesktopPWAsWithoutExtensions);
} else if (GetParam() == web_app::ProviderType::kBookmarkApps) {
scoped_feature_list_.InitAndDisableFeature(
features::kDesktopPWAsWithoutExtensions);
}
}
void SetUp() override { void SetUp() override {
app_provider_ = web_app::TestWebAppProvider::Get(&profile_); profile_ = std::make_unique<TestingProfile>();
app_provider_ = web_app::TestWebAppProvider::Get(profile_.get());
auto app_registrar = std::make_unique<web_app::TestAppRegistrar>(); auto app_registrar = std::make_unique<web_app::TestAppRegistrar>();
app_registrar_ = app_registrar.get(); app_registrar_ = app_registrar.get();
app_provider_->SetRegistrar(std::move(app_registrar)); app_provider_->SetRegistrar(std::move(app_registrar));
auto file_handler_manager = auto file_handler_manager =
std::make_unique<web_app::TestFileHandlerManager>(&profile_); std::make_unique<web_app::TestFileHandlerManager>(profile_.get());
file_handler_manager_ = file_handler_manager.get(); file_handler_manager_ = file_handler_manager.get();
app_provider_->SetFileHandlerManager(std::move(file_handler_manager)); app_provider_->SetFileHandlerManager(std::move(file_handler_manager));
...@@ -53,20 +67,21 @@ class WebFileTasksTest : public testing::Test { ...@@ -53,20 +67,21 @@ class WebFileTasksTest : public testing::Test {
file_handler_manager_->InstallFileHandler(app_id, install_url, accept); file_handler_manager_->InstallFileHandler(app_id, install_url, accept);
} }
Profile* profile() { return &profile_; } Profile* profile() { return profile_.get(); }
web_app::TestFileHandlerManager* file_handler_manager() { web_app::TestFileHandlerManager* file_handler_manager() {
return file_handler_manager_; return file_handler_manager_;
} }
private: private:
base::test::ScopedFeatureList scoped_feature_list_;
content::BrowserTaskEnvironment task_environment_; content::BrowserTaskEnvironment task_environment_;
TestingProfile profile_; std::unique_ptr<TestingProfile> profile_;
web_app::TestWebAppProvider* app_provider_; web_app::TestWebAppProvider* app_provider_;
web_app::TestAppRegistrar* app_registrar_; web_app::TestAppRegistrar* app_registrar_;
web_app::TestFileHandlerManager* file_handler_manager_; web_app::TestFileHandlerManager* file_handler_manager_;
}; };
TEST_F(WebFileTasksTest, WebAppFileHandlingCanBeDisabledByFlag) { TEST_P(WebFileTasksTest, WebAppFileHandlingCanBeDisabledByFlag) {
const char kGraphrId[] = "graphr-app-id"; const char kGraphrId[] = "graphr-app-id";
const char kGraphrAction[] = "https://graphr.tld/csv"; const char kGraphrAction[] = "https://graphr.tld/csv";
InstallFileHandler(kGraphrId, GURL(kGraphrAction), {{"text/csv", {".csv"}}}); InstallFileHandler(kGraphrId, GURL(kGraphrAction), {{"text/csv", {".csv"}}});
...@@ -112,7 +127,7 @@ TEST_F(WebFileTasksTest, WebAppFileHandlingCanBeDisabledByFlag) { ...@@ -112,7 +127,7 @@ TEST_F(WebFileTasksTest, WebAppFileHandlingCanBeDisabledByFlag) {
} }
} }
TEST_F(WebFileTasksTest, DisabledFileHandlersAreNotVisible) { TEST_P(WebFileTasksTest, DisabledFileHandlersAreNotVisible) {
const char kGraphrId[] = "graphr-app-id"; const char kGraphrId[] = "graphr-app-id";
const char kGraphrAction[] = "https://graphr.tld/csv"; const char kGraphrAction[] = "https://graphr.tld/csv";
...@@ -149,7 +164,7 @@ TEST_F(WebFileTasksTest, DisabledFileHandlersAreNotVisible) { ...@@ -149,7 +164,7 @@ TEST_F(WebFileTasksTest, DisabledFileHandlersAreNotVisible) {
EXPECT_EQ(kFooId, tasks[0].task_descriptor().app_id); EXPECT_EQ(kFooId, tasks[0].task_descriptor().app_id);
} }
TEST_F(WebFileTasksTest, FindWebFileHandlerTasks) { TEST_P(WebFileTasksTest, FindWebFileHandlerTasks) {
base::test::ScopedFeatureList scoped_feature_list; base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures({blink::features::kNativeFileSystemAPI, scoped_feature_list.InitWithFeatures({blink::features::kNativeFileSystemAPI,
blink::features::kFileHandlingAPI}, blink::features::kFileHandlingAPI},
...@@ -199,7 +214,7 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTasks) { ...@@ -199,7 +214,7 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTasks) {
FindWebTasks(profile(), entries, &tasks); FindWebTasks(profile(), entries, &tasks);
} }
TEST_F(WebFileTasksTest, FindWebFileHandlerTask_Generic) { TEST_P(WebFileTasksTest, FindWebFileHandlerTask_Generic) {
base::test::ScopedFeatureList scoped_feature_list; base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures({blink::features::kNativeFileSystemAPI, scoped_feature_list.InitWithFeatures({blink::features::kNativeFileSystemAPI,
blink::features::kFileHandlingAPI}, blink::features::kFileHandlingAPI},
...@@ -284,5 +299,11 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTask_Generic) { ...@@ -284,5 +299,11 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTask_Generic) {
EXPECT_TRUE(tasks[2].is_generic_file_handler()); EXPECT_TRUE(tasks[2].is_generic_file_handler());
} }
// TODO(crbug.com/1082883): Test with BMO enabled.
INSTANTIATE_TEST_SUITE_P(All,
WebFileTasksTest,
::testing::Values(ProviderType::kBookmarkApps),
web_app::ProviderTypeParamToString);
} // namespace file_tasks } // namespace file_tasks
} // namespace file_manager } // namespace file_manager
...@@ -7,16 +7,19 @@ ...@@ -7,16 +7,19 @@
#include <memory> #include <memory>
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/web_applications/test/test_app_registrar.h" #include "chrome/browser/web_applications/test/test_app_registrar.h"
#include "chrome/browser/web_applications/test/test_install_finalizer.h" #include "chrome/browser/web_applications/test/test_install_finalizer.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/test_web_app_registry_controller.h" #include "chrome/browser/web_applications/test/test_web_app_registry_controller.h"
#include "chrome/browser/web_applications/test/web_app_test.h"
#include "chrome/browser/web_applications/web_app.h" #include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_provider_factory.h" #include "chrome/browser/web_applications/web_app_provider_factory.h"
#include "chrome/browser/web_applications/web_app_registrar.h" #include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/policy/proto/device_management_backend.pb.h" #include "components/policy/proto/device_management_backend.pb.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
...@@ -27,6 +30,8 @@ using ::testing::AllOf; ...@@ -27,6 +30,8 @@ using ::testing::AllOf;
using ::testing::ElementsAre; using ::testing::ElementsAre;
using ::testing::Property; using ::testing::Property;
using web_app::ProviderType;
namespace em = enterprise_management; namespace em = enterprise_management;
namespace policy { namespace policy {
...@@ -43,7 +48,18 @@ auto EqApp(const std::string& app_id, ...@@ -43,7 +48,18 @@ auto EqApp(const std::string& app_id,
Property(&em::AppInfo::app_type, app_type)); Property(&em::AppInfo::app_type, app_type));
} }
class AppInfoGeneratorTest : public ::testing::Test { class AppInfoGeneratorTest : public ::testing::TestWithParam<ProviderType> {
public:
AppInfoGeneratorTest() {
if (GetParam() == web_app::ProviderType::kWebApps) {
scoped_feature_list_.InitAndEnableFeature(
features::kDesktopPWAsWithoutExtensions);
} else if (GetParam() == web_app::ProviderType::kBookmarkApps) {
scoped_feature_list_.InitAndDisableFeature(
features::kDesktopPWAsWithoutExtensions);
}
}
protected: protected:
static apps::mojom::AppPtr MakeApp(const std::string& app_id, static apps::mojom::AppPtr MakeApp(const std::string& app_id,
const std::string& name, const std::string& name,
...@@ -92,12 +108,13 @@ class AppInfoGeneratorTest : public ::testing::Test { ...@@ -92,12 +108,13 @@ class AppInfoGeneratorTest : public ::testing::Test {
Profile& profile() { return *profile_; } Profile& profile() { return *profile_; }
private: private:
base::test::ScopedFeatureList scoped_feature_list_;
content::BrowserTaskEnvironment task_environment_; content::BrowserTaskEnvironment task_environment_;
std::unique_ptr<TestingProfile> profile_; std::unique_ptr<TestingProfile> profile_;
web_app::TestAppRegistrar* app_registrar_; web_app::TestAppRegistrar* app_registrar_;
}; };
TEST_F(AppInfoGeneratorTest, GenerateInventoryList) { TEST_P(AppInfoGeneratorTest, GenerateInventoryList) {
std::vector<apps::mojom::AppPtr> deltas; std::vector<apps::mojom::AppPtr> deltas;
deltas.push_back(MakeApp("a", "FirstApp", deltas.push_back(MakeApp("a", "FirstApp",
apps::mojom::Readiness::kDisabledByPolicy, "1.1", apps::mojom::Readiness::kDisabledByPolicy, "1.1",
...@@ -121,7 +138,7 @@ TEST_F(AppInfoGeneratorTest, GenerateInventoryList) { ...@@ -121,7 +138,7 @@ TEST_F(AppInfoGeneratorTest, GenerateInventoryList) {
"", em::AppInfo_AppType_TYPE_CROSTINI))); "", em::AppInfo_AppType_TYPE_CROSTINI)));
} }
TEST_F(AppInfoGeneratorTest, GenerateWebApp) { TEST_P(AppInfoGeneratorTest, GenerateWebApp) {
std::vector<apps::mojom::AppPtr> deltas; std::vector<apps::mojom::AppPtr> deltas;
deltas.push_back(MakeApp("c", "App", deltas.push_back(MakeApp("c", "App",
apps::mojom::Readiness::kUninstalledByUser, "", apps::mojom::Readiness::kUninstalledByUser, "",
...@@ -141,4 +158,10 @@ TEST_F(AppInfoGeneratorTest, GenerateWebApp) { ...@@ -141,4 +158,10 @@ TEST_F(AppInfoGeneratorTest, GenerateWebApp) {
em::AppInfo_AppType_TYPE_WEB))); em::AppInfo_AppType_TYPE_WEB)));
} }
// TODO(crbug.com/1083855): Test with BMO enabled.
INSTANTIATE_TEST_SUITE_P(All,
AppInfoGeneratorTest,
::testing::Values(ProviderType::kBookmarkApps),
web_app::ProviderTypeParamToString);
} // namespace policy } // namespace policy
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include "chrome/browser/ui/app_list/internal_app/internal_app_metadata.h" #include "chrome/browser/ui/app_list/internal_app/internal_app_metadata.h"
#include "chrome/browser/ui/app_list/test/fake_app_list_model_updater.h" #include "chrome/browser/ui/app_list/test/fake_app_list_model_updater.h"
#include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h" #include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h"
#include "chrome/browser/web_applications/test/web_app_test.h"
#include "chrome/common/chrome_features.h"
#include "chrome/services/app_service/public/cpp/app_update.h" #include "chrome/services/app_service/public/cpp/app_update.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/arc/test/fake_app_instance.h" #include "components/arc/test/fake_app_instance.h"
...@@ -40,6 +42,8 @@ ...@@ -40,6 +42,8 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
using web_app::ProviderType;
namespace { namespace {
class FakeAppContextMenuDelegate : public app_list::AppContextMenuDelegate { class FakeAppContextMenuDelegate : public app_list::AppContextMenuDelegate {
...@@ -138,9 +142,19 @@ std::unique_ptr<ui::SimpleMenuModel> GetMenuModel( ...@@ -138,9 +142,19 @@ std::unique_ptr<ui::SimpleMenuModel> GetMenuModel(
} // namespace } // namespace
class AppContextMenuTest : public AppListTestBase { class AppContextMenuTest : public AppListTestBase,
public ::testing::WithParamInterface<ProviderType> {
public: public:
AppContextMenuTest() = default; AppContextMenuTest() {
if (GetParam() == web_app::ProviderType::kWebApps) {
scoped_feature_list_.InitAndEnableFeature(
features::kDesktopPWAsWithoutExtensions);
} else if (GetParam() == web_app::ProviderType::kBookmarkApps) {
scoped_feature_list_.InitAndDisableFeature(
features::kDesktopPWAsWithoutExtensions);
}
}
~AppContextMenuTest() override { ~AppContextMenuTest() override {
// Release profile file in order to keep right sequence. // Release profile file in order to keep right sequence.
profile_.reset(); profile_.reset();
...@@ -266,16 +280,16 @@ class AppContextMenuTest : public AppListTestBase { ...@@ -266,16 +280,16 @@ class AppContextMenuTest : public AppListTestBase {
} }
private: private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<KeyedService> menu_manager_; std::unique_ptr<KeyedService> menu_manager_;
std::unique_ptr<FakeAppListControllerDelegate> controller_; std::unique_ptr<FakeAppListControllerDelegate> controller_;
std::unique_ptr<FakeAppContextMenuDelegate> menu_delegate_; std::unique_ptr<FakeAppContextMenuDelegate> menu_delegate_;
std::unique_ptr<FakeAppListModelUpdater> model_updater_; std::unique_ptr<FakeAppListModelUpdater> model_updater_;
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(AppContextMenuTest); DISALLOW_COPY_AND_ASSIGN(AppContextMenuTest);
}; };
TEST_F(AppContextMenuTest, ExtensionApp) { TEST_P(AppContextMenuTest, ExtensionApp) {
app_list::ExtensionAppContextMenu::DisableInstalledExtensionCheckForTesting( app_list::ExtensionAppContextMenu::DisableInstalledExtensionCheckForTesting(
false); false);
for (extensions::LaunchType launch_type = extensions::LAUNCH_TYPE_FIRST; for (extensions::LaunchType launch_type = extensions::LAUNCH_TYPE_FIRST;
...@@ -298,13 +312,13 @@ TEST_F(AppContextMenuTest, ExtensionApp) { ...@@ -298,13 +312,13 @@ TEST_F(AppContextMenuTest, ExtensionApp) {
} }
} }
TEST_F(AppContextMenuTest, ChromeApp) { TEST_P(AppContextMenuTest, ChromeApp) {
app_list::ExtensionAppContextMenu::DisableInstalledExtensionCheckForTesting( app_list::ExtensionAppContextMenu::DisableInstalledExtensionCheckForTesting(
true); true);
TestChromeApp(); TestChromeApp();
} }
TEST_F(AppContextMenuTest, NonExistingExtensionApp) { TEST_P(AppContextMenuTest, NonExistingExtensionApp) {
app_list::ExtensionAppContextMenu::DisableInstalledExtensionCheckForTesting( app_list::ExtensionAppContextMenu::DisableInstalledExtensionCheckForTesting(
false); false);
app_list::ExtensionAppContextMenu menu( app_list::ExtensionAppContextMenu menu(
...@@ -314,7 +328,7 @@ TEST_F(AppContextMenuTest, NonExistingExtensionApp) { ...@@ -314,7 +328,7 @@ TEST_F(AppContextMenuTest, NonExistingExtensionApp) {
EXPECT_EQ(nullptr, menu_model); EXPECT_EQ(nullptr, menu_model);
} }
TEST_F(AppContextMenuTest, ArcMenu) { TEST_P(AppContextMenuTest, ArcMenu) {
apps::AppServiceTest app_service_test; apps::AppServiceTest app_service_test;
app_service_test.SetUp(profile()); app_service_test.SetUp(profile());
ArcAppTest arc_test; ArcAppTest arc_test;
...@@ -428,7 +442,7 @@ TEST_F(AppContextMenuTest, ArcMenu) { ...@@ -428,7 +442,7 @@ TEST_F(AppContextMenuTest, ArcMenu) {
EXPECT_EQ(0, menu->GetItemCount()); EXPECT_EQ(0, menu->GetItemCount());
} }
TEST_F(AppContextMenuTest, ArcMenuShortcut) { TEST_P(AppContextMenuTest, ArcMenuShortcut) {
apps::AppServiceTest app_service_test; apps::AppServiceTest app_service_test;
app_service_test.SetUp(profile()); app_service_test.SetUp(profile());
ArcAppTest arc_test; ArcAppTest arc_test;
...@@ -493,7 +507,7 @@ TEST_F(AppContextMenuTest, ArcMenuShortcut) { ...@@ -493,7 +507,7 @@ TEST_F(AppContextMenuTest, ArcMenuShortcut) {
} }
} }
TEST_F(AppContextMenuTest, ArcMenuStickyItem) { TEST_P(AppContextMenuTest, ArcMenuStickyItem) {
apps::AppServiceTest app_service_test; apps::AppServiceTest app_service_test;
app_service_test.SetUp(profile()); app_service_test.SetUp(profile());
ArcAppTest arc_test; ArcAppTest arc_test;
...@@ -536,7 +550,7 @@ TEST_F(AppContextMenuTest, ArcMenuStickyItem) { ...@@ -536,7 +550,7 @@ TEST_F(AppContextMenuTest, ArcMenuStickyItem) {
} }
// In suspended state app does not have launch item. // In suspended state app does not have launch item.
TEST_F(AppContextMenuTest, ArcMenuSuspendedItem) { TEST_P(AppContextMenuTest, ArcMenuSuspendedItem) {
apps::AppServiceTest app_service_test; apps::AppServiceTest app_service_test;
app_service_test.SetUp(profile()); app_service_test.SetUp(profile());
ArcAppTest arc_test; ArcAppTest arc_test;
...@@ -574,7 +588,7 @@ TEST_F(AppContextMenuTest, ArcMenuSuspendedItem) { ...@@ -574,7 +588,7 @@ TEST_F(AppContextMenuTest, ArcMenuSuspendedItem) {
} }
} }
TEST_F(AppContextMenuTest, CommandIdsMatchEnumsForHistograms) { TEST_P(AppContextMenuTest, CommandIdsMatchEnumsForHistograms) {
// Tests that CommandId enums are not changed as the values are used in // Tests that CommandId enums are not changed as the values are used in
// histograms. // histograms.
EXPECT_EQ(9, ash::NOTIFICATION_CONTAINER); EXPECT_EQ(9, ash::NOTIFICATION_CONTAINER);
...@@ -595,7 +609,7 @@ TEST_F(AppContextMenuTest, CommandIdsMatchEnumsForHistograms) { ...@@ -595,7 +609,7 @@ TEST_F(AppContextMenuTest, CommandIdsMatchEnumsForHistograms) {
} }
// Tests that internal app's context menu is correct. // Tests that internal app's context menu is correct.
TEST_F(AppContextMenuTest, InternalAppMenu) { TEST_P(AppContextMenuTest, InternalAppMenu) {
for (const auto& internal_app : app_list::GetInternalAppList(profile())) { for (const auto& internal_app : app_list::GetInternalAppList(profile())) {
controller()->SetAppPinnable(internal_app.app_id, controller()->SetAppPinnable(internal_app.app_id,
AppListControllerDelegate::PIN_EDITABLE); AppListControllerDelegate::PIN_EDITABLE);
...@@ -608,3 +622,9 @@ TEST_F(AppContextMenuTest, InternalAppMenu) { ...@@ -608,3 +622,9 @@ TEST_F(AppContextMenuTest, InternalAppMenu) {
ValidateItemState(menu.get(), 0, MenuState(ash::TOGGLE_PIN)); ValidateItemState(menu.get(), 0, MenuState(ash::TOGGLE_PIN));
} }
} }
// TODO(crbug.com/1082877): Test with BMO enabled.
INSTANTIATE_TEST_SUITE_P(All,
AppContextMenuTest,
::testing::Values(ProviderType::kBookmarkApps),
web_app::ProviderTypeParamToString);
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "chrome/browser/ui/app_list/search/search_result_ranker/ranking_item_util.h" #include "chrome/browser/ui/app_list/search/search_result_ranker/ranking_item_util.h"
#include "chrome/browser/ui/app_list/test/fake_app_list_model_updater.h" #include "chrome/browser/ui/app_list/test/fake_app_list_model_updater.h"
#include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h" #include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h"
#include "chrome/browser/web_applications/test/web_app_test.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/services/app_service/public/cpp/stub_icon_loader.h" #include "chrome/services/app_service/public/cpp/stub_icon_loader.h"
...@@ -57,6 +58,8 @@ ...@@ -57,6 +58,8 @@
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using web_app::ProviderType;
namespace app_list { namespace app_list {
namespace test { namespace test {
...@@ -693,7 +696,27 @@ TEST_F(AppSearchProviderTest, FetchInternalApp) { ...@@ -693,7 +696,27 @@ TEST_F(AppSearchProviderTest, FetchInternalApp) {
EXPECT_EQ(kSettingsInternalName, RunQuery("Set")); EXPECT_EQ(kSettingsInternalName, RunQuery("Set"));
} }
TEST_F(AppSearchProviderTest, CrostiniTerminal) { class AppSearchProviderCrostiniTest
: public AppSearchProviderTest,
public ::testing::WithParamInterface<ProviderType> {
protected:
AppSearchProviderCrostiniTest() {
if (GetParam() == web_app::ProviderType::kWebApps) {
scoped_feature_list_.InitAndEnableFeature(
features::kDesktopPWAsWithoutExtensions);
} else if (GetParam() == web_app::ProviderType::kBookmarkApps) {
scoped_feature_list_.InitAndDisableFeature(
features::kDesktopPWAsWithoutExtensions);
}
}
~AppSearchProviderCrostiniTest() override = default;
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
TEST_P(AppSearchProviderCrostiniTest, CrostiniTerminal) {
CreateSearch(); CreateSearch();
// Crostini UI is not allowed yet. // Crostini UI is not allowed yet.
...@@ -726,7 +749,7 @@ TEST_F(AppSearchProviderTest, CrostiniTerminal) { ...@@ -726,7 +749,7 @@ TEST_F(AppSearchProviderTest, CrostiniTerminal) {
EXPECT_EQ("Terminal", RunQuery("cros")); EXPECT_EQ("Terminal", RunQuery("cros"));
} }
TEST_F(AppSearchProviderTest, CrostiniApp) { TEST_P(AppSearchProviderCrostiniTest, CrostiniApp) {
// This both allows Crostini UI and enables Crostini. // This both allows Crostini UI and enables Crostini.
crostini::CrostiniTestHelper crostini_test_helper(testing_profile()); crostini::CrostiniTestHelper crostini_test_helper(testing_profile());
crostini_test_helper.ReInitializeAppServiceIntegration(); crostini_test_helper.ReInitializeAppServiceIntegration();
...@@ -935,14 +958,6 @@ TEST_P(AppSearchProviderWithExtensionInstallType, OemResultsOnFirstBoot) { ...@@ -935,14 +958,6 @@ TEST_P(AppSearchProviderWithExtensionInstallType, OemResultsOnFirstBoot) {
} }
} }
INSTANTIATE_TEST_SUITE_P(
All,
AppSearchProviderWithExtensionInstallType,
::testing::ValuesIn({TestExtensionInstallType::CONTROLLED_BY_POLICY,
TestExtensionInstallType::CHROME_COMPONENT,
TestExtensionInstallType::INSTALLED_BY_DEFAULT,
TestExtensionInstallType::INSTALLED_BY_OEM}));
enum class TestArcAppInstallType { enum class TestArcAppInstallType {
CONTROLLED_BY_POLICY, CONTROLLED_BY_POLICY,
INSTALLED_BY_DEFAULT, INSTALLED_BY_DEFAULT,
...@@ -1026,11 +1041,25 @@ TEST_P(AppSearchProviderWithArcAppInstallType, ...@@ -1026,11 +1041,25 @@ TEST_P(AppSearchProviderWithArcAppInstallType,
RunQuery(kRankingAppQuery)); RunQuery(kRankingAppQuery));
} }
INSTANTIATE_TEST_SUITE_P(
All,
AppSearchProviderWithExtensionInstallType,
::testing::ValuesIn({TestExtensionInstallType::CONTROLLED_BY_POLICY,
TestExtensionInstallType::CHROME_COMPONENT,
TestExtensionInstallType::INSTALLED_BY_DEFAULT,
TestExtensionInstallType::INSTALLED_BY_OEM}));
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(
All, All,
AppSearchProviderWithArcAppInstallType, AppSearchProviderWithArcAppInstallType,
::testing::ValuesIn({TestArcAppInstallType::CONTROLLED_BY_POLICY, ::testing::ValuesIn({TestArcAppInstallType::CONTROLLED_BY_POLICY,
TestArcAppInstallType::INSTALLED_BY_DEFAULT})); TestArcAppInstallType::INSTALLED_BY_DEFAULT}));
// TODO(crbug.com/1082884): Test with BMO enabled.
INSTANTIATE_TEST_SUITE_P(All,
AppSearchProviderCrostiniTest,
::testing::Values(ProviderType::kBookmarkApps),
web_app::ProviderTypeParamToString);
} // namespace test } // namespace test
} // namespace app_list } // namespace app_list
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/apps/app_service/app_service_test.h" #include "chrome/browser/apps/app_service/app_service_test.h"
#include "chrome/browser/chromeos/arc/icon_decode_request.h" #include "chrome/browser/chromeos/arc/icon_decode_request.h"
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/launcher/extension_shelf_context_menu.h" #include "chrome/browser/ui/ash/launcher/extension_shelf_context_menu.h"
#include "chrome/browser/ui/ash/launcher/internal_app_shelf_context_menu.h" #include "chrome/browser/ui/ash/launcher/internal_app_shelf_context_menu.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/chrome_ash_test_base.h" #include "chrome/test/base/chrome_ash_test_base.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
...@@ -50,6 +52,8 @@ ...@@ -50,6 +52,8 @@
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
using web_app::ProviderType;
namespace { namespace {
bool IsItemPresentInMenu(ui::MenuModel* menu, int command_id) { bool IsItemPresentInMenu(ui::MenuModel* menu, int command_id) {
...@@ -71,9 +75,20 @@ std::string GetAppNameInShelfGroup(uint32_t task_id) { ...@@ -71,9 +75,20 @@ std::string GetAppNameInShelfGroup(uint32_t task_id) {
return base::StringPrintf("AppInShelfGroup%d", task_id); return base::StringPrintf("AppInShelfGroup%d", task_id);
} }
class ShelfContextMenuTest : public ChromeAshTestBase { class ShelfContextMenuTest
: public ChromeAshTestBase,
public ::testing::WithParamInterface<ProviderType> {
protected: protected:
ShelfContextMenuTest() = default; ShelfContextMenuTest() {
if (GetParam() == web_app::ProviderType::kWebApps) {
scoped_feature_list_.InitAndEnableFeature(
features::kDesktopPWAsWithoutExtensions);
} else if (GetParam() == web_app::ProviderType::kBookmarkApps) {
scoped_feature_list_.InitAndDisableFeature(
features::kDesktopPWAsWithoutExtensions);
}
}
~ShelfContextMenuTest() override = default; ~ShelfContextMenuTest() override = default;
void SetUp() override { void SetUp() override {
...@@ -172,6 +187,7 @@ class ShelfContextMenuTest : public ChromeAshTestBase { ...@@ -172,6 +187,7 @@ class ShelfContextMenuTest : public ChromeAshTestBase {
} }
private: private:
base::test::ScopedFeatureList scoped_feature_list_;
TestingProfile profile_; TestingProfile profile_;
ArcAppTest arc_test_; ArcAppTest arc_test_;
apps::AppServiceTest app_service_test_; apps::AppServiceTest app_service_test_;
...@@ -184,7 +200,7 @@ class ShelfContextMenuTest : public ChromeAshTestBase { ...@@ -184,7 +200,7 @@ class ShelfContextMenuTest : public ChromeAshTestBase {
// Verifies that "New Incognito window" menu item in the launcher context // Verifies that "New Incognito window" menu item in the launcher context
// menu is disabled when Incognito mode is switched off (by a policy). // menu is disabled when Incognito mode is switched off (by a policy).
TEST_F(ShelfContextMenuTest, TEST_P(ShelfContextMenuTest,
NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff) { NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff) {
const int64_t display_id = GetPrimaryDisplay().id(); const int64_t display_id = GetPrimaryDisplay().id();
// Initially, "New Incognito window" should be enabled. // Initially, "New Incognito window" should be enabled.
...@@ -209,7 +225,7 @@ TEST_F(ShelfContextMenuTest, ...@@ -209,7 +225,7 @@ TEST_F(ShelfContextMenuTest,
// Verifies that "New window" menu item in the launcher context // Verifies that "New window" menu item in the launcher context
// menu is disabled when Incognito mode is forced (by a policy). // menu is disabled when Incognito mode is forced (by a policy).
TEST_F(ShelfContextMenuTest, NewWindowMenuIsDisabledWhenIncognitoModeForced) { TEST_P(ShelfContextMenuTest, NewWindowMenuIsDisabledWhenIncognitoModeForced) {
const int64_t display_id = GetPrimaryDisplay().id(); const int64_t display_id = GetPrimaryDisplay().id();
// Initially, "New window" should be enabled. // Initially, "New window" should be enabled.
std::unique_ptr<ShelfContextMenu> shelf_context_menu = std::unique_ptr<ShelfContextMenu> shelf_context_menu =
...@@ -230,7 +246,7 @@ TEST_F(ShelfContextMenuTest, NewWindowMenuIsDisabledWhenIncognitoModeForced) { ...@@ -230,7 +246,7 @@ TEST_F(ShelfContextMenuTest, NewWindowMenuIsDisabledWhenIncognitoModeForced) {
// Verifies that "Close" is not shown in context menu if no browser window is // Verifies that "Close" is not shown in context menu if no browser window is
// opened. // opened.
TEST_F(ShelfContextMenuTest, DesktopShellShelfContextMenuVerifyCloseItem) { TEST_P(ShelfContextMenuTest, DesktopShellShelfContextMenuVerifyCloseItem) {
const int64_t display_id = GetPrimaryDisplay().id(); const int64_t display_id = GetPrimaryDisplay().id();
std::unique_ptr<ShelfContextMenu> shelf_context_menu = std::unique_ptr<ShelfContextMenu> shelf_context_menu =
CreateShelfContextMenu(ash::TYPE_BROWSER_SHORTCUT, display_id); CreateShelfContextMenu(ash::TYPE_BROWSER_SHORTCUT, display_id);
...@@ -240,7 +256,7 @@ TEST_F(ShelfContextMenuTest, DesktopShellShelfContextMenuVerifyCloseItem) { ...@@ -240,7 +256,7 @@ TEST_F(ShelfContextMenuTest, DesktopShellShelfContextMenuVerifyCloseItem) {
// Verifies context menu and app menu items for ARC app. // Verifies context menu and app menu items for ARC app.
// The 0th item is sticky but not the following. // The 0th item is sticky but not the following.
TEST_F(ShelfContextMenuTest, ArcLauncherMenusCheck) { TEST_P(ShelfContextMenuTest, ArcLauncherMenusCheck) {
arc_test().app_instance()->SendRefreshAppList( arc_test().app_instance()->SendRefreshAppList(
std::vector<arc::mojom::AppInfo>(arc_test().fake_apps().begin(), std::vector<arc::mojom::AppInfo>(arc_test().fake_apps().begin(),
arc_test().fake_apps().begin() + 1)); arc_test().fake_apps().begin() + 1));
...@@ -379,7 +395,7 @@ TEST_F(ShelfContextMenuTest, ArcLauncherMenusCheck) { ...@@ -379,7 +395,7 @@ TEST_F(ShelfContextMenuTest, ArcLauncherMenusCheck) {
} }
} }
TEST_F(ShelfContextMenuTest, ArcLauncherSuspendAppMenu) { TEST_P(ShelfContextMenuTest, ArcLauncherSuspendAppMenu) {
arc::mojom::AppInfo app = arc_test().fake_apps()[0]; arc::mojom::AppInfo app = arc_test().fake_apps()[0];
app.suspended = true; app.suspended = true;
SendRefreshAppList({app}); SendRefreshAppList({app});
...@@ -407,7 +423,7 @@ TEST_F(ShelfContextMenuTest, ArcLauncherSuspendAppMenu) { ...@@ -407,7 +423,7 @@ TEST_F(ShelfContextMenuTest, ArcLauncherSuspendAppMenu) {
EXPECT_FALSE(IsItemEnabledInMenu(menu.get(), ash::UNINSTALL)); EXPECT_FALSE(IsItemEnabledInMenu(menu.get(), ash::UNINSTALL));
} }
TEST_F(ShelfContextMenuTest, ArcDeferredShelfContextMenuItemCheck) { TEST_P(ShelfContextMenuTest, ArcDeferredShelfContextMenuItemCheck) {
SendRefreshAppList(std::vector<arc::mojom::AppInfo>( SendRefreshAppList(std::vector<arc::mojom::AppInfo>(
arc_test().fake_apps().begin(), arc_test().fake_apps().begin() + 2)); arc_test().fake_apps().begin(), arc_test().fake_apps().begin() + 2));
const std::string app_id1 = ArcAppTest::GetAppId(arc_test().fake_apps()[0]); const std::string app_id1 = ArcAppTest::GetAppId(arc_test().fake_apps()[0]);
...@@ -454,7 +470,7 @@ TEST_F(ShelfContextMenuTest, ArcDeferredShelfContextMenuItemCheck) { ...@@ -454,7 +470,7 @@ TEST_F(ShelfContextMenuTest, ArcDeferredShelfContextMenuItemCheck) {
EXPECT_FALSE(IsItemEnabledInMenu(menu.get(), ash::UNINSTALL)); EXPECT_FALSE(IsItemEnabledInMenu(menu.get(), ash::UNINSTALL));
} }
TEST_F(ShelfContextMenuTest, CommandIdsMatchEnumsForHistograms) { TEST_P(ShelfContextMenuTest, CommandIdsMatchEnumsForHistograms) {
// Tests that CommandId enums are not changed as the values are used in // Tests that CommandId enums are not changed as the values are used in
// histograms. // histograms.
EXPECT_EQ(0, ash::MENU_OPEN_NEW); EXPECT_EQ(0, ash::MENU_OPEN_NEW);
...@@ -469,7 +485,7 @@ TEST_F(ShelfContextMenuTest, CommandIdsMatchEnumsForHistograms) { ...@@ -469,7 +485,7 @@ TEST_F(ShelfContextMenuTest, CommandIdsMatchEnumsForHistograms) {
EXPECT_EQ(9, ash::NOTIFICATION_CONTAINER); EXPECT_EQ(9, ash::NOTIFICATION_CONTAINER);
} }
TEST_F(ShelfContextMenuTest, ArcContextMenuOptions) { TEST_P(ShelfContextMenuTest, ArcContextMenuOptions) {
// Tests that there are the right number of ARC app context menu options. If // Tests that there are the right number of ARC app context menu options. If
// you're adding a context menu option ensure that you have added the enum to // you're adding a context menu option ensure that you have added the enum to
// tools/metrics/histograms/enums.xml and that you haven't modified the order // tools/metrics/histograms/enums.xml and that you haven't modified the order
...@@ -494,7 +510,7 @@ TEST_F(ShelfContextMenuTest, ArcContextMenuOptions) { ...@@ -494,7 +510,7 @@ TEST_F(ShelfContextMenuTest, ArcContextMenuOptions) {
} }
// Tests that the context menu of internal app is correct. // Tests that the context menu of internal app is correct.
TEST_F(ShelfContextMenuTest, InternalAppShelfContextMenu) { TEST_P(ShelfContextMenuTest, InternalAppShelfContextMenu) {
const std::vector<app_list::InternalApp> internal_apps( const std::vector<app_list::InternalApp> internal_apps(
app_list::GetInternalAppList(profile())); app_list::GetInternalAppList(profile()));
for (const auto& internal_app : internal_apps) { for (const auto& internal_app : internal_apps) {
...@@ -526,7 +542,7 @@ TEST_F(ShelfContextMenuTest, InternalAppShelfContextMenu) { ...@@ -526,7 +542,7 @@ TEST_F(ShelfContextMenuTest, InternalAppShelfContextMenu) {
} }
// Tests that the number of context menu options of internal app is correct. // Tests that the number of context menu options of internal app is correct.
TEST_F(ShelfContextMenuTest, InternalAppShelfContextMenuOptionsNumber) { TEST_P(ShelfContextMenuTest, InternalAppShelfContextMenuOptionsNumber) {
const std::vector<app_list::InternalApp> internal_apps( const std::vector<app_list::InternalApp> internal_apps(
app_list::GetInternalAppList(profile())); app_list::GetInternalAppList(profile()));
for (const auto& internal_app : internal_apps) { for (const auto& internal_app : internal_apps) {
...@@ -551,7 +567,7 @@ TEST_F(ShelfContextMenuTest, InternalAppShelfContextMenuOptionsNumber) { ...@@ -551,7 +567,7 @@ TEST_F(ShelfContextMenuTest, InternalAppShelfContextMenuOptionsNumber) {
// Checks some properties for crostini's terminal app's context menu, // Checks some properties for crostini's terminal app's context menu,
// specifically that every menu item has an icon. // specifically that every menu item has an icon.
TEST_F(ShelfContextMenuTest, CrostiniTerminalApp) { TEST_P(ShelfContextMenuTest, CrostiniTerminalApp) {
crostini::CrostiniTestHelper crostini_helper(profile()); crostini::CrostiniTestHelper crostini_helper(profile());
crostini_helper.ReInitializeAppServiceIntegration(); crostini_helper.ReInitializeAppServiceIntegration();
const std::string app_id = crostini::GetTerminalId(); const std::string app_id = crostini::GetTerminalId();
...@@ -580,7 +596,7 @@ TEST_F(ShelfContextMenuTest, CrostiniTerminalApp) { ...@@ -580,7 +596,7 @@ TEST_F(ShelfContextMenuTest, CrostiniTerminalApp) {
// Checks the context menu for a "normal" crostini app (i.e. a registered one). // Checks the context menu for a "normal" crostini app (i.e. a registered one).
// Particularly, we ensure that the density changing option exists. // Particularly, we ensure that the density changing option exists.
TEST_F(ShelfContextMenuTest, CrostiniNormalApp) { TEST_P(ShelfContextMenuTest, CrostiniNormalApp) {
crostini::CrostiniTestHelper crostini_helper(profile()); crostini::CrostiniTestHelper crostini_helper(profile());
crostini_helper.ReInitializeAppServiceIntegration(); crostini_helper.ReInitializeAppServiceIntegration();
...@@ -623,7 +639,7 @@ TEST_F(ShelfContextMenuTest, CrostiniNormalApp) { ...@@ -623,7 +639,7 @@ TEST_F(ShelfContextMenuTest, CrostiniNormalApp) {
// Confirms the menu items for unregistered crostini apps (i.e. apps that do not // Confirms the menu items for unregistered crostini apps (i.e. apps that do not
// have an associated .desktop file, and therefore can only be closed). // have an associated .desktop file, and therefore can only be closed).
TEST_F(ShelfContextMenuTest, CrostiniUnregisteredApps) { TEST_P(ShelfContextMenuTest, CrostiniUnregisteredApps) {
crostini::CrostiniTestHelper crostini_helper(profile()); crostini::CrostiniTestHelper crostini_helper(profile());
crostini_helper.ReInitializeAppServiceIntegration(); crostini_helper.ReInitializeAppServiceIntegration();
...@@ -646,4 +662,10 @@ TEST_F(ShelfContextMenuTest, CrostiniUnregisteredApps) { ...@@ -646,4 +662,10 @@ TEST_F(ShelfContextMenuTest, CrostiniUnregisteredApps) {
EXPECT_FALSE(IsItemEnabledInMenu(menu.get(), ash::MENU_NEW_WINDOW)); EXPECT_FALSE(IsItemEnabledInMenu(menu.get(), ash::MENU_NEW_WINDOW));
} }
// TODO(crbug.com/1082887): Test with BMO enabled.
INSTANTIATE_TEST_SUITE_P(All,
ShelfContextMenuTest,
::testing::Values(ProviderType::kBookmarkApps),
web_app::ProviderTypeParamToString);
} // namespace } // namespace
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#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/test_web_app_ui_manager.h" #include "chrome/browser/web_applications/test/test_web_app_ui_manager.h"
#include "chrome/browser/web_applications/test/web_app_test.h"
#include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
...@@ -70,11 +71,20 @@ ExternalInstallOptions GetWindowedInstallOptions() { ...@@ -70,11 +71,20 @@ ExternalInstallOptions GetWindowedInstallOptions() {
} // namespace } // namespace
class SystemWebAppManagerTest : public ChromeRenderViewHostTestHarness { class SystemWebAppManagerTest
: public ChromeRenderViewHostTestHarness,
public ::testing::WithParamInterface<ProviderType> {
public: public:
SystemWebAppManagerTest() { SystemWebAppManagerTest() {
scoped_feature_list_.InitWithFeatures( if (GetParam() == ProviderType::kWebApps) {
{features::kSystemWebApps}, {features::kDesktopPWAsWithoutExtensions}); scoped_feature_list_.InitWithFeatures(
{features::kSystemWebApps, features::kDesktopPWAsWithoutExtensions},
{});
} else if (GetParam() == ProviderType::kBookmarkApps) {
scoped_feature_list_.InitWithFeatures(
{features::kSystemWebApps},
{features::kDesktopPWAsWithoutExtensions});
}
} }
~SystemWebAppManagerTest() override = default; ~SystemWebAppManagerTest() override = default;
...@@ -142,7 +152,7 @@ class SystemWebAppManagerTest : public ChromeRenderViewHostTestHarness { ...@@ -142,7 +152,7 @@ class SystemWebAppManagerTest : public ChromeRenderViewHostTestHarness {
}; };
// Test that System Apps are uninstalled with the feature disabled. // Test that System Apps are uninstalled with the feature disabled.
TEST_F(SystemWebAppManagerTest, Disabled) { TEST_P(SystemWebAppManagerTest, 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});
...@@ -168,7 +178,7 @@ TEST_F(SystemWebAppManagerTest, Disabled) { ...@@ -168,7 +178,7 @@ TEST_F(SystemWebAppManagerTest, Disabled) {
} }
// Test that System Apps do install with the feature enabled. // Test that System Apps do install with the feature enabled.
TEST_F(SystemWebAppManagerTest, Enabled) { TEST_P(SystemWebAppManagerTest, 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()));
...@@ -184,7 +194,7 @@ TEST_F(SystemWebAppManagerTest, Enabled) { ...@@ -184,7 +194,7 @@ TEST_F(SystemWebAppManagerTest, Enabled) {
} }
// Test that changing the set of System Apps uninstalls apps. // Test that changing the set of System Apps uninstalls apps.
TEST_F(SystemWebAppManagerTest, UninstallAppInstalledInPreviousSession) { TEST_P(SystemWebAppManagerTest, 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(),
...@@ -214,7 +224,7 @@ TEST_F(SystemWebAppManagerTest, UninstallAppInstalledInPreviousSession) { ...@@ -214,7 +224,7 @@ TEST_F(SystemWebAppManagerTest, UninstallAppInstalledInPreviousSession) {
pending_app_manager()->uninstall_requests()); pending_app_manager()->uninstall_requests());
} }
TEST_F(SystemWebAppManagerTest, AlwaysUpdate) { TEST_P(SystemWebAppManagerTest, AlwaysUpdate) {
system_web_app_manager()->SetUpdatePolicy( system_web_app_manager()->SetUpdatePolicy(
SystemWebAppManager::UpdatePolicy::kAlwaysUpdate); SystemWebAppManager::UpdatePolicy::kAlwaysUpdate);
...@@ -257,7 +267,7 @@ TEST_F(SystemWebAppManagerTest, AlwaysUpdate) { ...@@ -257,7 +267,7 @@ TEST_F(SystemWebAppManagerTest, AlwaysUpdate) {
EXPECT_EQ(5u, pending_app_manager()->install_requests().size()); EXPECT_EQ(5u, pending_app_manager()->install_requests().size());
} }
TEST_F(SystemWebAppManagerTest, UpdateOnVersionChange) { TEST_P(SystemWebAppManagerTest, UpdateOnVersionChange) {
const std::vector<ExternalInstallOptions>& install_requests = const std::vector<ExternalInstallOptions>& install_requests =
pending_app_manager()->install_requests(); pending_app_manager()->install_requests();
...@@ -342,7 +352,7 @@ TEST_F(SystemWebAppManagerTest, UpdateOnVersionChange) { ...@@ -342,7 +352,7 @@ TEST_F(SystemWebAppManagerTest, UpdateOnVersionChange) {
EXPECT_TRUE(IsInstalled(AppUrl3())); EXPECT_TRUE(IsInstalled(AppUrl3()));
} }
TEST_F(SystemWebAppManagerTest, UpdateOnLocaleChange) { TEST_P(SystemWebAppManagerTest, UpdateOnLocaleChange) {
const std::vector<ExternalInstallOptions>& install_requests = const std::vector<ExternalInstallOptions>& install_requests =
pending_app_manager()->install_requests(); pending_app_manager()->install_requests();
...@@ -383,7 +393,7 @@ TEST_F(SystemWebAppManagerTest, UpdateOnLocaleChange) { ...@@ -383,7 +393,7 @@ TEST_F(SystemWebAppManagerTest, UpdateOnLocaleChange) {
EXPECT_FALSE(install_requests[2].force_reinstall); EXPECT_FALSE(install_requests[2].force_reinstall);
} }
TEST_F(SystemWebAppManagerTest, InstallResultHistogram) { TEST_P(SystemWebAppManagerTest, 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." +
...@@ -490,4 +500,10 @@ TEST_F(SystemWebAppManagerTest, InstallResultHistogram) { ...@@ -490,4 +500,10 @@ TEST_F(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
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/web_applications/components/app_registrar.h" #include "chrome/browser/web_applications/components/app_registrar.h"
...@@ -19,7 +20,9 @@ ...@@ -19,7 +20,9 @@
#include "chrome/browser/web_applications/components/web_app_constants.h" #include "chrome/browser/web_applications/components/web_app_constants.h"
#include "chrome/browser/web_applications/test/test_pending_app_manager.h" #include "chrome/browser/web_applications/test/test_pending_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_test.h"
#include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
...@@ -165,9 +168,19 @@ ExternalInstallOptions GetCreateDesktopShorcutTrueInstallOptions() { ...@@ -165,9 +168,19 @@ ExternalInstallOptions GetCreateDesktopShorcutTrueInstallOptions() {
} // namespace } // namespace
class WebAppPolicyManagerTest : public ChromeRenderViewHostTestHarness { class WebAppPolicyManagerTest
: public ChromeRenderViewHostTestHarness,
public ::testing::WithParamInterface<ProviderType> {
public: public:
WebAppPolicyManagerTest() {} WebAppPolicyManagerTest() {
if (GetParam() == web_app::ProviderType::kWebApps) {
scoped_feature_list_.InitAndEnableFeature(
features::kDesktopPWAsWithoutExtensions);
} else if (GetParam() == web_app::ProviderType::kBookmarkApps) {
scoped_feature_list_.InitAndDisableFeature(
features::kDesktopPWAsWithoutExtensions);
}
}
~WebAppPolicyManagerTest() override = default; ~WebAppPolicyManagerTest() override = default;
...@@ -206,6 +219,7 @@ class WebAppPolicyManagerTest : public ChromeRenderViewHostTestHarness { ...@@ -206,6 +219,7 @@ class WebAppPolicyManagerTest : public ChromeRenderViewHostTestHarness {
WebAppPolicyManager* policy_manager() { return web_app_policy_manager_; } WebAppPolicyManager* policy_manager() { return web_app_policy_manager_; }
private: private:
base::test::ScopedFeatureList scoped_feature_list_;
TestAppRegistrar* test_app_registrar_ = nullptr; TestAppRegistrar* test_app_registrar_ = nullptr;
TestPendingAppManager* test_pending_app_manager_ = nullptr; TestPendingAppManager* test_pending_app_manager_ = nullptr;
WebAppPolicyManager* web_app_policy_manager_ = nullptr; WebAppPolicyManager* web_app_policy_manager_ = nullptr;
...@@ -213,7 +227,7 @@ class WebAppPolicyManagerTest : public ChromeRenderViewHostTestHarness { ...@@ -213,7 +227,7 @@ class WebAppPolicyManagerTest : public ChromeRenderViewHostTestHarness {
DISALLOW_COPY_AND_ASSIGN(WebAppPolicyManagerTest); DISALLOW_COPY_AND_ASSIGN(WebAppPolicyManagerTest);
}; };
TEST_F(WebAppPolicyManagerTest, NoForceInstalledAppsPrefValue) { TEST_P(WebAppPolicyManagerTest, NoForceInstalledAppsPrefValue) {
policy_manager()->Start(); policy_manager()->Start();
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
...@@ -222,7 +236,7 @@ TEST_F(WebAppPolicyManagerTest, NoForceInstalledAppsPrefValue) { ...@@ -222,7 +236,7 @@ TEST_F(WebAppPolicyManagerTest, NoForceInstalledAppsPrefValue) {
EXPECT_TRUE(install_requests.empty()); EXPECT_TRUE(install_requests.empty());
} }
TEST_F(WebAppPolicyManagerTest, NoForceInstalledApps) { TEST_P(WebAppPolicyManagerTest, NoForceInstalledApps) {
profile()->GetPrefs()->Set(prefs::kWebAppInstallForceList, profile()->GetPrefs()->Set(prefs::kWebAppInstallForceList,
base::Value(base::Value::Type::LIST)); base::Value(base::Value::Type::LIST));
...@@ -233,7 +247,7 @@ TEST_F(WebAppPolicyManagerTest, NoForceInstalledApps) { ...@@ -233,7 +247,7 @@ TEST_F(WebAppPolicyManagerTest, NoForceInstalledApps) {
EXPECT_TRUE(install_requests.empty()); EXPECT_TRUE(install_requests.empty());
} }
TEST_F(WebAppPolicyManagerTest, TwoForceInstalledApps) { TEST_P(WebAppPolicyManagerTest, TwoForceInstalledApps) {
// Add two sites, one that opens in a window and one that opens in a tab. // Add two sites, one that opens in a window and one that opens in a tab.
base::Value list(base::Value::Type::LIST); base::Value list(base::Value::Type::LIST);
list.Append(GetWindowedItem()); list.Append(GetWindowedItem());
...@@ -252,7 +266,7 @@ TEST_F(WebAppPolicyManagerTest, TwoForceInstalledApps) { ...@@ -252,7 +266,7 @@ TEST_F(WebAppPolicyManagerTest, TwoForceInstalledApps) {
EXPECT_EQ(install_requests, expected_install_options_list); EXPECT_EQ(install_requests, expected_install_options_list);
} }
TEST_F(WebAppPolicyManagerTest, ForceInstallAppWithNoDefaultLaunchContainer) { TEST_P(WebAppPolicyManagerTest, ForceInstallAppWithNoDefaultLaunchContainer) {
base::Value list(base::Value::Type::LIST); base::Value list(base::Value::Type::LIST);
list.Append(GetNoContainerItem()); list.Append(GetNoContainerItem());
profile()->GetPrefs()->Set(prefs::kWebAppInstallForceList, std::move(list)); profile()->GetPrefs()->Set(prefs::kWebAppInstallForceList, std::move(list));
...@@ -268,7 +282,7 @@ TEST_F(WebAppPolicyManagerTest, ForceInstallAppWithNoDefaultLaunchContainer) { ...@@ -268,7 +282,7 @@ TEST_F(WebAppPolicyManagerTest, ForceInstallAppWithNoDefaultLaunchContainer) {
EXPECT_EQ(install_requests, expected_install_options_list); EXPECT_EQ(install_requests, expected_install_options_list);
} }
TEST_F(WebAppPolicyManagerTest, TEST_P(WebAppPolicyManagerTest,
ForceInstallAppWithDefaultCreateDesktopShorcut) { ForceInstallAppWithDefaultCreateDesktopShorcut) {
base::Value list(base::Value::Type::LIST); base::Value list(base::Value::Type::LIST);
list.Append(GetCreateDesktopShorcutDefaultItem()); list.Append(GetCreateDesktopShorcutDefaultItem());
...@@ -286,7 +300,7 @@ TEST_F(WebAppPolicyManagerTest, ...@@ -286,7 +300,7 @@ TEST_F(WebAppPolicyManagerTest,
EXPECT_EQ(install_requests, expected_install_options_list); EXPECT_EQ(install_requests, expected_install_options_list);
} }
TEST_F(WebAppPolicyManagerTest, ForceInstallAppWithCreateDesktopShortcut) { TEST_P(WebAppPolicyManagerTest, ForceInstallAppWithCreateDesktopShortcut) {
base::Value list(base::Value::Type::LIST); base::Value list(base::Value::Type::LIST);
list.Append(GetCreateDesktopShorcutFalseItem()); list.Append(GetCreateDesktopShorcutFalseItem());
list.Append(GetCreateDesktopShorcutTrueItem()); list.Append(GetCreateDesktopShorcutTrueItem());
...@@ -306,7 +320,7 @@ TEST_F(WebAppPolicyManagerTest, ForceInstallAppWithCreateDesktopShortcut) { ...@@ -306,7 +320,7 @@ TEST_F(WebAppPolicyManagerTest, ForceInstallAppWithCreateDesktopShortcut) {
EXPECT_EQ(install_requests, expected_install_options_list); EXPECT_EQ(install_requests, expected_install_options_list);
} }
TEST_F(WebAppPolicyManagerTest, DynamicRefresh) { TEST_P(WebAppPolicyManagerTest, DynamicRefresh) {
base::Value first_list(base::Value::Type::LIST); base::Value first_list(base::Value::Type::LIST);
first_list.Append(GetWindowedItem()); first_list.Append(GetWindowedItem());
profile()->GetPrefs()->Set(prefs::kWebAppInstallForceList, profile()->GetPrefs()->Set(prefs::kWebAppInstallForceList,
...@@ -334,7 +348,7 @@ TEST_F(WebAppPolicyManagerTest, DynamicRefresh) { ...@@ -334,7 +348,7 @@ TEST_F(WebAppPolicyManagerTest, DynamicRefresh) {
EXPECT_EQ(install_requests, expected_install_options_list); EXPECT_EQ(install_requests, expected_install_options_list);
} }
TEST_F(WebAppPolicyManagerTest, UninstallAppInstalledInPreviousSession) { TEST_P(WebAppPolicyManagerTest, UninstallAppInstalledInPreviousSession) {
// Simulate two policy apps and a regular app that were installed in the // Simulate two policy apps and a regular app that were installed in the
// previous session. // previous session.
SimulatePreviouslyInstalledApp(WindowedUrl(), SimulatePreviouslyInstalledApp(WindowedUrl(),
...@@ -366,7 +380,7 @@ TEST_F(WebAppPolicyManagerTest, UninstallAppInstalledInPreviousSession) { ...@@ -366,7 +380,7 @@ TEST_F(WebAppPolicyManagerTest, UninstallAppInstalledInPreviousSession) {
// Tests that we correctly uninstall an app that we installed in the same // Tests that we correctly uninstall an app that we installed in the same
// session. // session.
TEST_F(WebAppPolicyManagerTest, UninstallAppInstalledInCurrentSession) { TEST_P(WebAppPolicyManagerTest, UninstallAppInstalledInCurrentSession) {
policy_manager()->Start(); policy_manager()->Start();
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
...@@ -404,7 +418,7 @@ TEST_F(WebAppPolicyManagerTest, UninstallAppInstalledInCurrentSession) { ...@@ -404,7 +418,7 @@ TEST_F(WebAppPolicyManagerTest, UninstallAppInstalledInCurrentSession) {
} }
// Tests that we correctly reinstall a placeholder app. // Tests that we correctly reinstall a placeholder app.
TEST_F(WebAppPolicyManagerTest, ReinstallPlaceholderApp) { TEST_P(WebAppPolicyManagerTest, ReinstallPlaceholderApp) {
base::Value list(base::Value::Type::LIST); base::Value list(base::Value::Type::LIST);
list.Append(GetWindowedItem()); list.Append(GetWindowedItem());
profile()->GetPrefs()->Set(prefs::kWebAppInstallForceList, std::move(list)); profile()->GetPrefs()->Set(prefs::kWebAppInstallForceList, std::move(list));
...@@ -430,7 +444,7 @@ TEST_F(WebAppPolicyManagerTest, ReinstallPlaceholderApp) { ...@@ -430,7 +444,7 @@ TEST_F(WebAppPolicyManagerTest, ReinstallPlaceholderApp) {
EXPECT_EQ(expected_options_list, install_options_list); EXPECT_EQ(expected_options_list, install_options_list);
} }
TEST_F(WebAppPolicyManagerTest, TryToInexistentPlaceholderApp) { TEST_P(WebAppPolicyManagerTest, TryToInexistentPlaceholderApp) {
base::Value list(base::Value::Type::LIST); base::Value list(base::Value::Type::LIST);
list.Append(GetWindowedItem()); list.Append(GetWindowedItem());
profile()->GetPrefs()->Set(prefs::kWebAppInstallForceList, std::move(list)); profile()->GetPrefs()->Set(prefs::kWebAppInstallForceList, std::move(list));
...@@ -451,7 +465,7 @@ TEST_F(WebAppPolicyManagerTest, TryToInexistentPlaceholderApp) { ...@@ -451,7 +465,7 @@ TEST_F(WebAppPolicyManagerTest, TryToInexistentPlaceholderApp) {
EXPECT_EQ(expected_options_list, install_options_list); EXPECT_EQ(expected_options_list, install_options_list);
} }
TEST_F(WebAppPolicyManagerTest, SayRefreshTwoTimesQuickly) { TEST_P(WebAppPolicyManagerTest, SayRefreshTwoTimesQuickly) {
policy_manager()->Start(); policy_manager()->Start();
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
// Add an app. // Add an app.
...@@ -488,7 +502,7 @@ TEST_F(WebAppPolicyManagerTest, SayRefreshTwoTimesQuickly) { ...@@ -488,7 +502,7 @@ TEST_F(WebAppPolicyManagerTest, SayRefreshTwoTimesQuickly) {
EXPECT_EQ(it.second, TabbedUrl()); EXPECT_EQ(it.second, TabbedUrl());
} }
TEST_F(WebAppPolicyManagerTest, InstallResultHistogram) { TEST_P(WebAppPolicyManagerTest, InstallResultHistogram) {
base::HistogramTester histograms; base::HistogramTester histograms;
policy_manager()->Start(); policy_manager()->Start();
{ {
...@@ -525,4 +539,10 @@ TEST_F(WebAppPolicyManagerTest, InstallResultHistogram) { ...@@ -525,4 +539,10 @@ TEST_F(WebAppPolicyManagerTest, InstallResultHistogram) {
} }
} }
// TODO(crbug.com/1082881): Test with BMO enabled.
INSTANTIATE_TEST_SUITE_P(All,
WebAppPolicyManagerTest,
::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