Skip to content

Commit

Permalink
Remove SetLacrosPrimaryBrowserForTest and SetLacrosEnabledForTest.
Browse files Browse the repository at this point in the history
They are no longer used. So remove them.

BUG=1448575
TEST=Tryjob.

Change-Id: I1ddc42ad44fdb8701c2b86b38279a84d5a60312d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4566013
Reviewed-by: Andrea Orru <andreaorru@chromium.org>
Commit-Queue: Hidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1149594}
  • Loading branch information
Hidehiko Abe authored and Chromium LUCI CQ committed May 26, 2023
1 parent 00d1885 commit 1a2a7ad
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 87 deletions.
39 changes: 0 additions & 39 deletions chrome/browser/ash/crosapi/browser_util.cc
Expand Up @@ -25,7 +25,6 @@
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h"
#include "chromeos/ash/components/standalone_browser/browser_support.h"
#include "chromeos/ash/components/standalone_browser/lacros_availability.h"
#include "chromeos/crosapi/cpp/crosapi_constants.h"
#include "chromeos/crosapi/mojom/crosapi.mojom.h"
Expand All @@ -42,7 +41,6 @@
#include "components/version_info/version_info.h"
#include "google_apis/gaia/gaia_auth_util.h"

using ash::standalone_browser::BrowserSupport;
using ash::standalone_browser::IsGoogleInternal;
using ash::standalone_browser::LacrosAvailability;
using user_manager::User;
Expand All @@ -54,8 +52,6 @@ namespace {

bool g_profile_migration_completed_for_test = false;

absl::optional<bool> g_lacros_primary_browser_for_test;

// At session start the value for LacrosAvailability logic is applied and the
// result is stored in this variable which is used after that as a cache.
absl::optional<LacrosAvailability> g_lacros_availability_cache;
Expand Down Expand Up @@ -165,10 +161,6 @@ LacrosAvailability GetLacrosAvailability(const user_manager::User* user,
bool IsLacrosAllowedToBeEnabledWithUser(
const User* user,
LacrosAvailability launch_availability) {
if (BrowserSupport::GetLacrosEnabledForTest()) {
return true;
}

if (!IsUserTypeAllowed(user)) {
return false;
}
Expand Down Expand Up @@ -345,12 +337,6 @@ base::FilePath GetUserDataDir() {
}

bool IsLacrosAllowedToBeEnabled() {
// Allows tests to avoid enabling the flag, constructing a fake user manager,
// creating g_browser_process->local_state(), etc.
if (BrowserSupport::GetLacrosEnabledForTest()) {
return true;
}

// TODO(crbug.com/1185813): TaskManagerImplTest is not ready to run with
// Lacros enabled.
// UserManager is not initialized for unit tests by default, unless a fake
Expand All @@ -370,12 +356,6 @@ bool IsLacrosAllowedToBeEnabled() {
}

bool IsLacrosEnabled() {
// Allows tests to avoid enabling the flag, constructing a fake user manager,
// creating g_browser_process->local_state(), etc.
if (BrowserSupport::GetLacrosEnabledForTest()) {
return true;
}

if (!IsLacrosAllowedToBeEnabled())
return false;

Expand Down Expand Up @@ -409,10 +389,6 @@ bool IsLacrosEnabled() {

bool IsLacrosEnabledForMigration(const User* user,
PolicyInitState policy_init_state) {
if (BrowserSupport::GetLacrosEnabledForTest()) {
return true;
}

LacrosAvailability lacros_availability =
GetLacrosAvailability(user, policy_init_state);

Expand Down Expand Up @@ -540,11 +516,6 @@ bool IsAshWebBrowserEnabledForMigration(const user_manager::User* user,
}

bool IsLacrosPrimaryBrowser() {
// Note that if you are updating this function, please also update the
// *ForMigration variant to keep the logics consistent.
if (g_lacros_primary_browser_for_test.has_value())
return g_lacros_primary_browser_for_test.value();

if (!IsLacrosEnabled())
return false;

Expand Down Expand Up @@ -576,9 +547,6 @@ bool IsLacrosPrimaryBrowser() {

bool IsLacrosPrimaryBrowserForMigration(const user_manager::User* user,
PolicyInitState policy_init_state) {
if (g_lacros_primary_browser_for_test.has_value())
return g_lacros_primary_browser_for_test.value();

if (!IsLacrosEnabledForMigration(user, policy_init_state))
return false;

Expand Down Expand Up @@ -1233,11 +1201,4 @@ bool ShouldEnforceAshExtensionKeepList() {
ash::features::kEnforceAshExtensionKeeplist);
}

base::AutoReset<absl::optional<bool>>
SetLacrosPrimaryBrowserForTest( // IN-TEST
absl::optional<bool> value) {
return base::AutoReset<absl::optional<bool>>(
&g_lacros_primary_browser_for_test, value);
}

} // namespace crosapi::browser_util
5 changes: 0 additions & 5 deletions chrome/browser/ash/crosapi/browser_util.h
Expand Up @@ -528,11 +528,6 @@ bool WasGotoFilesClicked(PrefService* local_state,
// Returns true if ash 1st party extension keep list should be enforced.
bool ShouldEnforceAshExtensionKeepList();

// Forces IsLacrosPrimaryBrowser() to return true or false for testing.
// Reset upon destruction of returned |base::AutoReset| object.
base::AutoReset<absl::optional<bool>> SetLacrosPrimaryBrowserForTest(
absl::optional<bool> value);

} // namespace crosapi::browser_util

#endif // CHROME_BROWSER_ASH_CROSAPI_BROWSER_UTIL_H_
21 changes: 0 additions & 21 deletions chrome/browser/ash/crosapi/browser_util_unittest.cc
Expand Up @@ -24,7 +24,6 @@
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/ash/components/standalone_browser/browser_support.h"
#include "chromeos/ash/components/standalone_browser/lacros_availability.h"
#include "chromeos/ash/components/system/fake_statistics_provider.h"
#include "chromeos/crosapi/mojom/crosapi.mojom.h"
Expand All @@ -35,7 +34,6 @@
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"

using ash::standalone_browser::BrowserSupport;
using ash::standalone_browser::LacrosAvailability;
using crosapi::browser_util::LacrosLaunchSwitchSource;
using crosapi::browser_util::LacrosSelection;
Expand Down Expand Up @@ -919,13 +917,6 @@ TEST_F(BrowserUtilTest, IsAshBrowserSyncEnabled) {
EXPECT_TRUE(browser_util::IsAshBrowserSyncEnabled());
}

{
auto scoped_enabled = BrowserSupport::SetLacrosEnabledForTest(true);
EXPECT_TRUE(browser_util::IsLacrosEnabled());
EXPECT_TRUE(browser_util::IsAshWebBrowserEnabled());
EXPECT_TRUE(browser_util::IsAshBrowserSyncEnabled());
}

{
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures(
Expand All @@ -936,18 +927,6 @@ TEST_F(BrowserUtilTest, IsAshBrowserSyncEnabled) {
EXPECT_TRUE(browser_util::IsAshWebBrowserEnabled());
EXPECT_TRUE(browser_util::IsAshBrowserSyncEnabled());
}

{
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures(
{ash::features::kLacrosOnly, ash::features::kLacrosPrimary,
ash::features::kLacrosSupport},
{});
auto scoped_enabled = BrowserSupport::SetLacrosEnabledForTest(true);
EXPECT_TRUE(browser_util::IsLacrosEnabled());
EXPECT_FALSE(browser_util::IsAshWebBrowserEnabled());
EXPECT_FALSE(browser_util::IsAshBrowserSyncEnabled());
}
}

TEST_F(BrowserUtilTest, GetLacrosLaunchSwitchSourceNonGoogle) {
Expand Down
14 changes: 0 additions & 14 deletions chromeos/ash/components/standalone_browser/browser_support.cc
Expand Up @@ -66,18 +66,4 @@ BrowserSupport* BrowserSupport::Get() {
return g_instance;
}

// static
base::AutoReset<bool> BrowserSupport::SetLacrosEnabledForTest(
bool force_enabled) {
return base::AutoReset<bool>(&lacros_enabled_for_test_, force_enabled);
}

// static
bool BrowserSupport::GetLacrosEnabledForTest() {
return lacros_enabled_for_test_;
}

// static
bool BrowserSupport::lacros_enabled_for_test_ = false;

} // namespace ash::standalone_browser
8 changes: 0 additions & 8 deletions chromeos/ash/components/standalone_browser/browser_support.h
Expand Up @@ -22,17 +22,9 @@ class COMPONENT_EXPORT(CHROMEOS_ASH_COMPONENTS_STANDALONE_BROWSER)
// Returns the global instance of BrowserSupport.
static BrowserSupport* Get();

// Forces IsLacrosEnabled() to return true or false for testing. Reset upon
// destruction of returned |base::AutoReset| object.
// TODO(andreaorru): remove these methods once the refactoring in complete.
static base::AutoReset<bool> SetLacrosEnabledForTest(bool force_enabled);
static bool GetLacrosEnabledForTest();

private:
BrowserSupport();
~BrowserSupport();

static bool lacros_enabled_for_test_;
};

} // namespace ash::standalone_browser
Expand Down

0 comments on commit 1a2a7ad

Please sign in to comment.