Commit 2421449c authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Update OffTheRecord profile API in WebAppUtils test.

Profile API is being updated (issue 1033903) and the usage of
GetOffTheRecordProfile and HasOffTheRecordProfile without argument is
getting deprecated. Use cases of this call that ONLY refer to incognito
or guest mode can use [Get/Has]PrimaryOTRProfile() instead.

OffTheRecord profile API use in web_app_utils_unittest.cc are updated
and new test cases for non-primary OTRs are added.

Bug: 1060940
Change-Id: I4ae83207a1b971efa7aba5bf5e3bf351f2b107de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212121
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Auto-Submit: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771911}
parent 1bdf61d7
...@@ -30,30 +30,31 @@ TEST_F(WebAppUtilsTest, AreWebAppsEnabled) { ...@@ -30,30 +30,31 @@ TEST_F(WebAppUtilsTest, AreWebAppsEnabled) {
EXPECT_FALSE(AreWebAppsEnabled(nullptr)); EXPECT_FALSE(AreWebAppsEnabled(nullptr));
EXPECT_TRUE(AreWebAppsEnabled(regular_profile)); EXPECT_TRUE(AreWebAppsEnabled(regular_profile));
EXPECT_TRUE(AreWebAppsEnabled(regular_profile->GetOffTheRecordProfile())); EXPECT_TRUE(AreWebAppsEnabled(regular_profile->GetPrimaryOTRProfile()));
EXPECT_TRUE(AreWebAppsEnabled(regular_profile->GetOffTheRecordProfile(
Profile::OTRProfileID("Test::WebAppUtils"))));
TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal()); TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal());
ASSERT_TRUE(profile_manager.SetUp()); ASSERT_TRUE(profile_manager.SetUp());
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->GetOffTheRecordProfile())); 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));
EXPECT_FALSE(AreWebAppsEnabled(system_profile->GetOffTheRecordProfile())); EXPECT_FALSE(AreWebAppsEnabled(system_profile->GetPrimaryOTRProfile()));
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
Profile* signin_profile = Profile* signin_profile =
profile_manager.CreateTestingProfile(chrome::kInitialProfile); profile_manager.CreateTestingProfile(chrome::kInitialProfile);
EXPECT_FALSE(AreWebAppsEnabled(signin_profile)); EXPECT_FALSE(AreWebAppsEnabled(signin_profile));
EXPECT_FALSE(AreWebAppsEnabled(signin_profile->GetOffTheRecordProfile())); EXPECT_FALSE(AreWebAppsEnabled(signin_profile->GetPrimaryOTRProfile()));
Profile* lock_screen_profile = profile_manager.CreateTestingProfile( Profile* lock_screen_profile = profile_manager.CreateTestingProfile(
chromeos::ProfileHelper::GetLockScreenAppProfileName()); chromeos::ProfileHelper::GetLockScreenAppProfileName());
EXPECT_FALSE(AreWebAppsEnabled(lock_screen_profile)); EXPECT_FALSE(AreWebAppsEnabled(lock_screen_profile));
EXPECT_FALSE( EXPECT_FALSE(AreWebAppsEnabled(lock_screen_profile->GetPrimaryOTRProfile()));
AreWebAppsEnabled(lock_screen_profile->GetOffTheRecordProfile()));
using MockUserManager = testing::NiceMock<chromeos::MockUserManager>; using MockUserManager = testing::NiceMock<chromeos::MockUserManager>;
{ {
...@@ -84,7 +85,10 @@ TEST_F(WebAppUtilsTest, AreWebAppsUserInstallable) { ...@@ -84,7 +85,10 @@ TEST_F(WebAppUtilsTest, AreWebAppsUserInstallable) {
EXPECT_FALSE(AreWebAppsEnabled(nullptr)); EXPECT_FALSE(AreWebAppsEnabled(nullptr));
EXPECT_TRUE(AreWebAppsUserInstallable(regular_profile)); EXPECT_TRUE(AreWebAppsUserInstallable(regular_profile));
EXPECT_FALSE( EXPECT_FALSE(
AreWebAppsUserInstallable(regular_profile->GetOffTheRecordProfile())); AreWebAppsUserInstallable(regular_profile->GetPrimaryOTRProfile()));
EXPECT_FALSE(
AreWebAppsUserInstallable(regular_profile->GetOffTheRecordProfile(
Profile::OTRProfileID("Test::WebAppUtils"))));
TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal()); TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal());
ASSERT_TRUE(profile_manager.SetUp()); ASSERT_TRUE(profile_manager.SetUp());
...@@ -92,25 +96,25 @@ TEST_F(WebAppUtilsTest, AreWebAppsUserInstallable) { ...@@ -92,25 +96,25 @@ 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( EXPECT_FALSE(
AreWebAppsUserInstallable(guest_profile->GetOffTheRecordProfile())); 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));
EXPECT_FALSE( EXPECT_FALSE(
AreWebAppsUserInstallable(system_profile->GetOffTheRecordProfile())); AreWebAppsUserInstallable(system_profile->GetPrimaryOTRProfile()));
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
Profile* signin_profile = Profile* signin_profile =
profile_manager.CreateTestingProfile(chrome::kInitialProfile); profile_manager.CreateTestingProfile(chrome::kInitialProfile);
EXPECT_FALSE(AreWebAppsUserInstallable(signin_profile)); EXPECT_FALSE(AreWebAppsUserInstallable(signin_profile));
EXPECT_FALSE( EXPECT_FALSE(
AreWebAppsUserInstallable(signin_profile->GetOffTheRecordProfile())); AreWebAppsUserInstallable(signin_profile->GetPrimaryOTRProfile()));
Profile* lock_screen_profile = profile_manager.CreateTestingProfile( Profile* lock_screen_profile = profile_manager.CreateTestingProfile(
chromeos::ProfileHelper::GetLockScreenAppProfileName()); chromeos::ProfileHelper::GetLockScreenAppProfileName());
EXPECT_FALSE(AreWebAppsUserInstallable(lock_screen_profile)); EXPECT_FALSE(AreWebAppsUserInstallable(lock_screen_profile));
EXPECT_FALSE( EXPECT_FALSE(
AreWebAppsUserInstallable(lock_screen_profile->GetOffTheRecordProfile())); AreWebAppsUserInstallable(lock_screen_profile->GetPrimaryOTRProfile()));
#endif #endif
} }
...@@ -119,20 +123,23 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebApps) { ...@@ -119,20 +123,23 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebApps) {
EXPECT_EQ(regular_profile, GetBrowserContextForWebApps(regular_profile)); EXPECT_EQ(regular_profile, GetBrowserContextForWebApps(regular_profile));
EXPECT_EQ(regular_profile, GetBrowserContextForWebApps( EXPECT_EQ(regular_profile, GetBrowserContextForWebApps(
regular_profile->GetOffTheRecordProfile())); regular_profile->GetPrimaryOTRProfile()));
EXPECT_EQ(regular_profile,
GetBrowserContextForWebApps(regular_profile->GetOffTheRecordProfile(
Profile::OTRProfileID("Test::WebAppUtils"))));
TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal()); TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal());
ASSERT_TRUE(profile_manager.SetUp()); ASSERT_TRUE(profile_manager.SetUp());
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, GetBrowserContextForWebApps( EXPECT_EQ(guest_profile,
guest_profile->GetOffTheRecordProfile())); 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));
EXPECT_EQ(nullptr, GetBrowserContextForWebApps( EXPECT_EQ(nullptr, GetBrowserContextForWebApps(
system_profile->GetOffTheRecordProfile())); system_profile->GetPrimaryOTRProfile()));
} }
TEST_F(WebAppUtilsTest, GetBrowserContextForWebAppMetrics) { TEST_F(WebAppUtilsTest, GetBrowserContextForWebAppMetrics) {
...@@ -141,7 +148,11 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebAppMetrics) { ...@@ -141,7 +148,11 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebAppMetrics) {
EXPECT_EQ(regular_profile, EXPECT_EQ(regular_profile,
GetBrowserContextForWebAppMetrics(regular_profile)); GetBrowserContextForWebAppMetrics(regular_profile));
EXPECT_EQ(regular_profile, GetBrowserContextForWebAppMetrics( EXPECT_EQ(regular_profile, GetBrowserContextForWebAppMetrics(
regular_profile->GetOffTheRecordProfile())); regular_profile->GetPrimaryOTRProfile()));
EXPECT_EQ(
regular_profile,
GetBrowserContextForWebAppMetrics(regular_profile->GetOffTheRecordProfile(
Profile::OTRProfileID("Test::WebAppUtils"))));
TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal()); TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal());
ASSERT_TRUE(profile_manager.SetUp()); ASSERT_TRUE(profile_manager.SetUp());
...@@ -149,12 +160,12 @@ TEST_F(WebAppUtilsTest, GetBrowserContextForWebAppMetrics) { ...@@ -149,12 +160,12 @@ 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( EXPECT_EQ(nullptr, GetBrowserContextForWebAppMetrics(
guest_profile->GetOffTheRecordProfile())); 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));
EXPECT_EQ(nullptr, GetBrowserContextForWebAppMetrics( EXPECT_EQ(nullptr, GetBrowserContextForWebAppMetrics(
system_profile->GetOffTheRecordProfile())); system_profile->GetPrimaryOTRProfile()));
} }
} // 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