Commit 2b2c6f27 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Update Web Applications tests to cover ephemeral Guest profiles.

Web Applications tests are updated to cover ephemeral Guest profiles.

Please see go/ephemeral-guest-profiles for more context.

Bug: 1125474
Change-Id: Ie60624795a286f0cfbcb6dfed2e8c605d61e6136
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2560125Reviewed-by: default avatarEric Willigers <ericwilligers@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831266}
parent e3600e5a
...@@ -26,9 +26,25 @@ ...@@ -26,9 +26,25 @@
namespace web_app { namespace web_app {
using WebAppUtilsTest = WebAppTest;
using ::testing::ElementsAre; using ::testing::ElementsAre;
class WebAppUtilsTest : public WebAppTest,
public ::testing::WithParamInterface<bool> {
public:
WebAppUtilsTest() : is_ephemeral_guest_(GetParam()) {
// Update for platforms which do not support ephemeral Guest profiles.
is_ephemeral_guest_ &=
TestingProfile::SetScopedFeatureListForEphemeralGuestProfiles(
scoped_feature_list_, is_ephemeral_guest_);
}
bool is_ephemeral_guest() const { return is_ephemeral_guest_; }
private:
base::test::ScopedFeatureList scoped_feature_list_;
bool is_ephemeral_guest_;
};
// Sanity check that iteration order of SortedSizesPx is ascending. The // Sanity check that iteration order of SortedSizesPx is ascending. The
// correctness of most usage of SortedSizesPx depends on this. // correctness of most usage of SortedSizesPx depends on this.
TEST(WebAppTest, SortedSizesPxIsAscending) { TEST(WebAppTest, SortedSizesPxIsAscending) {
...@@ -48,7 +64,7 @@ TEST(WebAppTest, SortedSizesPxIsAscending) { ...@@ -48,7 +64,7 @@ TEST(WebAppTest, SortedSizesPxIsAscending) {
ASSERT_THAT(base_reversed, ElementsAre(512, 256, 64, 32, 16)); ASSERT_THAT(base_reversed, ElementsAre(512, 256, 64, 32, 16));
} }
TEST_F(WebAppUtilsTest, AreWebAppsEnabled) { TEST_P(WebAppUtilsTest, AreWebAppsEnabled) {
Profile* regular_profile = profile(); Profile* regular_profile = profile();
EXPECT_FALSE(AreWebAppsEnabled(nullptr)); EXPECT_FALSE(AreWebAppsEnabled(nullptr));
...@@ -62,7 +78,8 @@ TEST_F(WebAppUtilsTest, AreWebAppsEnabled) { ...@@ -62,7 +78,8 @@ TEST_F(WebAppUtilsTest, AreWebAppsEnabled) {
Profile* guest_profile = profile_manager.CreateGuestProfile(); Profile* guest_profile = profile_manager.CreateGuestProfile();
EXPECT_TRUE(AreWebAppsEnabled(guest_profile)); EXPECT_TRUE(AreWebAppsEnabled(guest_profile));
EXPECT_TRUE(AreWebAppsEnabled(guest_profile->GetPrimaryOTRProfile())); if (!is_ephemeral_guest())
EXPECT_TRUE(AreWebAppsEnabled(guest_profile->GetPrimaryOTRProfile()));
Profile* system_profile = profile_manager.CreateSystemProfile(); Profile* system_profile = profile_manager.CreateSystemProfile();
EXPECT_FALSE(AreWebAppsEnabled(system_profile)); EXPECT_FALSE(AreWebAppsEnabled(system_profile));
...@@ -102,7 +119,7 @@ TEST_F(WebAppUtilsTest, AreWebAppsEnabled) { ...@@ -102,7 +119,7 @@ TEST_F(WebAppUtilsTest, AreWebAppsEnabled) {
#endif #endif
} }
TEST_F(WebAppUtilsTest, AreWebAppsUserInstallable) { TEST_P(WebAppUtilsTest, AreWebAppsUserInstallable) {
Profile* regular_profile = profile(); Profile* regular_profile = profile();
EXPECT_FALSE(AreWebAppsEnabled(nullptr)); EXPECT_FALSE(AreWebAppsEnabled(nullptr));
...@@ -118,8 +135,10 @@ TEST_F(WebAppUtilsTest, AreWebAppsUserInstallable) { ...@@ -118,8 +135,10 @@ TEST_F(WebAppUtilsTest, AreWebAppsUserInstallable) {
Profile* guest_profile = profile_manager.CreateGuestProfile(); Profile* guest_profile = profile_manager.CreateGuestProfile();
EXPECT_FALSE(AreWebAppsUserInstallable(guest_profile)); EXPECT_FALSE(AreWebAppsUserInstallable(guest_profile));
EXPECT_FALSE( if (!is_ephemeral_guest()) {
AreWebAppsUserInstallable(guest_profile->GetPrimaryOTRProfile())); EXPECT_FALSE(
AreWebAppsUserInstallable(guest_profile->GetPrimaryOTRProfile()));
}
Profile* system_profile = profile_manager.CreateSystemProfile(); Profile* system_profile = profile_manager.CreateSystemProfile();
EXPECT_FALSE(AreWebAppsUserInstallable(system_profile)); EXPECT_FALSE(AreWebAppsUserInstallable(system_profile));
...@@ -141,7 +160,7 @@ TEST_F(WebAppUtilsTest, AreWebAppsUserInstallable) { ...@@ -141,7 +160,7 @@ TEST_F(WebAppUtilsTest, AreWebAppsUserInstallable) {
#endif #endif
} }
TEST_F(WebAppUtilsTest, GetBrowserContextForWebApps) { TEST_P(WebAppUtilsTest, GetBrowserContextForWebApps) {
Profile* regular_profile = profile(); Profile* regular_profile = profile();
EXPECT_EQ(regular_profile, GetBrowserContextForWebApps(regular_profile)); EXPECT_EQ(regular_profile, GetBrowserContextForWebApps(regular_profile));
...@@ -156,8 +175,10 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebApps) { ...@@ -156,8 +175,10 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebApps) {
Profile* guest_profile = profile_manager.CreateGuestProfile(); Profile* guest_profile = profile_manager.CreateGuestProfile();
EXPECT_EQ(guest_profile, GetBrowserContextForWebApps(guest_profile)); EXPECT_EQ(guest_profile, GetBrowserContextForWebApps(guest_profile));
EXPECT_EQ(guest_profile, if (!is_ephemeral_guest()) {
GetBrowserContextForWebApps(guest_profile->GetPrimaryOTRProfile())); EXPECT_EQ(guest_profile, GetBrowserContextForWebApps(
guest_profile->GetPrimaryOTRProfile()));
}
Profile* system_profile = profile_manager.CreateSystemProfile(); Profile* system_profile = profile_manager.CreateSystemProfile();
EXPECT_EQ(nullptr, GetBrowserContextForWebApps(system_profile)); EXPECT_EQ(nullptr, GetBrowserContextForWebApps(system_profile));
...@@ -165,7 +186,7 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebApps) { ...@@ -165,7 +186,7 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebApps) {
system_profile->GetPrimaryOTRProfile())); system_profile->GetPrimaryOTRProfile()));
} }
TEST_F(WebAppUtilsTest, GetBrowserContextForWebAppMetrics) { TEST_P(WebAppUtilsTest, GetBrowserContextForWebAppMetrics) {
Profile* regular_profile = profile(); Profile* regular_profile = profile();
EXPECT_EQ(regular_profile, EXPECT_EQ(regular_profile,
...@@ -182,8 +203,10 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebAppMetrics) { ...@@ -182,8 +203,10 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebAppMetrics) {
Profile* guest_profile = profile_manager.CreateGuestProfile(); Profile* guest_profile = profile_manager.CreateGuestProfile();
EXPECT_EQ(nullptr, GetBrowserContextForWebAppMetrics(guest_profile)); EXPECT_EQ(nullptr, GetBrowserContextForWebAppMetrics(guest_profile));
EXPECT_EQ(nullptr, GetBrowserContextForWebAppMetrics( if (!is_ephemeral_guest()) {
guest_profile->GetPrimaryOTRProfile())); EXPECT_EQ(nullptr, GetBrowserContextForWebAppMetrics(
guest_profile->GetPrimaryOTRProfile()));
}
Profile* system_profile = profile_manager.CreateSystemProfile(); Profile* system_profile = profile_manager.CreateSystemProfile();
EXPECT_EQ(nullptr, GetBrowserContextForWebAppMetrics(system_profile)); EXPECT_EQ(nullptr, GetBrowserContextForWebAppMetrics(system_profile));
...@@ -191,4 +214,8 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebAppMetrics) { ...@@ -191,4 +214,8 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebAppMetrics) {
system_profile->GetPrimaryOTRProfile())); system_profile->GetPrimaryOTRProfile()));
} }
INSTANTIATE_TEST_SUITE_P(AllGuestTypes,
WebAppUtilsTest,
/*is_ephemeral_guest=*/testing::Bool());
} // namespace web_app } // namespace web_app
...@@ -997,8 +997,20 @@ TEST_F(WebAppInstallTaskTest, IntentToPlayStore) { ...@@ -997,8 +997,20 @@ TEST_F(WebAppInstallTaskTest, IntentToPlayStore) {
} }
#endif #endif
class GuestWebAppInstallTaskTest : public WebAppInstallTaskTest,
public ::testing::WithParamInterface<bool> {
public:
GuestWebAppInstallTaskTest() {
TestingProfile::SetScopedFeatureListForEphemeralGuestProfiles(
scoped_feature_list_, GetParam());
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
// Default apps should be installable for guest profiles. // Default apps should be installable for guest profiles.
TEST_F(WebAppInstallTaskTest, InstallWebAppWithParams_GuestProfile) { TEST_P(GuestWebAppInstallTaskTest, InstallWebAppWithParams_GuestProfile) {
SetInstallFinalizerForTesting(); SetInstallFinalizerForTesting();
TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal()); TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal());
...@@ -1025,6 +1037,10 @@ TEST_F(WebAppInstallTaskTest, InstallWebAppWithParams_GuestProfile) { ...@@ -1025,6 +1037,10 @@ TEST_F(WebAppInstallTaskTest, InstallWebAppWithParams_GuestProfile) {
run_loop.Run(); run_loop.Run();
} }
INSTANTIATE_TEST_SUITE_P(AllGuestTypes,
GuestWebAppInstallTaskTest,
/*is_ephemeral_guest=*/testing::Bool());
TEST_F(WebAppInstallTaskTest, InstallWebAppWithParams_DisplayMode) { TEST_F(WebAppInstallTaskTest, InstallWebAppWithParams_DisplayMode) {
{ {
CreateDataToRetrieve(GURL("https://example.com/"), CreateDataToRetrieve(GURL("https://example.com/"),
......
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