Commit ecb6eb41 authored by A Olsen's avatar A Olsen Committed by Commit Bot

Remove all instances of kStubCrosSettings switch

Use ScopedTestingCrosSettings instead.
See bug for more details.

Bug: 909635
Change-Id: I37daf492df8fe0be9f2b67ac634a2e68ed886b6f
Reviewed-on: https://chromium-review.googlesource.com/c/1394308Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: A Olsen <olsen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#620000}
parent 82848abb
......@@ -9,7 +9,8 @@
#include "base/strings/stringprintf.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
#include "chrome/browser/chromeos/settings/scoped_testing_cros_settings.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
#include "chrome/browser/chromeos/ui/echo_dialog_view.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_function_test_utils.h"
......@@ -39,14 +40,6 @@ class ExtensionEchoPrivateApiTest : public extensions::ExtensionApiTest {
~ExtensionEchoPrivateApiTest() override {}
void SetUpCommandLine(base::CommandLine* command_line) override {
extensions::ExtensionApiTest::SetUpCommandLine(command_line);
// Force usage of stub cros settings provider instead of device settings
// provider.
command_line->AppendSwitch(switches::kStubCrosSettings);
}
void RunDefaultGetUserFunctionAndExpectResultEquals(int tab_id,
bool expected_result) {
scoped_refptr<EchoPrivateGetUserConsentFunction> function(
......@@ -130,8 +123,7 @@ class ExtensionEchoPrivateApiTest : public extensions::ExtensionApiTest {
protected:
int expected_dialog_buttons_;
DialogTestAction dialog_action_;
chromeos::ScopedCrosSettingsTestHelper settings_helper_{
/* create_settings_service= */ false};
ScopedTestingCrosSettings scoped_testing_cros_settings_;
private:
int dialog_invocation_count_;
......@@ -242,8 +234,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionEchoPrivateApiTest,
IN_PROC_BROWSER_TEST_F(ExtensionEchoPrivateApiTest,
GetUserConsent_AllowRedeemPrefTrue) {
const int tab_id = OpenAndActivateTab();
settings_helper_.SetBoolean(chromeos::kAllowRedeemChromeOsRegistrationOffers,
true);
scoped_testing_cros_settings_.device_settings()->Set(
kAllowRedeemChromeOsRegistrationOffers, base::Value(true));
expected_dialog_buttons_ = ui::DIALOG_BUTTON_CANCEL | ui::DIALOG_BUTTON_OK;
dialog_action_ = DIALOG_TEST_ACTION_ACCEPT;
......@@ -256,8 +248,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionEchoPrivateApiTest,
IN_PROC_BROWSER_TEST_F(ExtensionEchoPrivateApiTest,
GetUserConsent_ConsentDenied) {
const int tab_id = OpenAndActivateTab();
settings_helper_.SetBoolean(chromeos::kAllowRedeemChromeOsRegistrationOffers,
true);
scoped_testing_cros_settings_.device_settings()->Set(
kAllowRedeemChromeOsRegistrationOffers, base::Value(true));
expected_dialog_buttons_ = ui::DIALOG_BUTTON_CANCEL | ui::DIALOG_BUTTON_OK;
dialog_action_ = DIALOG_TEST_ACTION_CANCEL;
......@@ -270,8 +262,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionEchoPrivateApiTest,
IN_PROC_BROWSER_TEST_F(ExtensionEchoPrivateApiTest,
GetUserConsent_AllowRedeemPrefFalse) {
const int tab_id = OpenAndActivateTab();
settings_helper_.SetBoolean(chromeos::kAllowRedeemChromeOsRegistrationOffers,
false);
scoped_testing_cros_settings_.device_settings()->Set(
kAllowRedeemChromeOsRegistrationOffers, base::Value(false));
expected_dialog_buttons_ = ui::DIALOG_BUTTON_CANCEL;
dialog_action_ = DIALOG_TEST_ACTION_CANCEL;
......
......@@ -14,7 +14,8 @@
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
#include "chrome/browser/chromeos/settings/scoped_testing_cros_settings.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#include "chrome/common/pref_names.h"
#include "chromeos/constants/chromeos_switches.h"
......@@ -184,13 +185,6 @@ class LoginUIKeyboardTestWithUsersAndOwner : public chromeos::LoginManagerTest {
: LoginManagerTest(false, true /* should_initialize_webui */) {}
~LoginUIKeyboardTestWithUsersAndOwner() override {}
void SetUpCommandLine(base::CommandLine* command_line) override {
LoginManagerTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kStubCrosSettings);
LoginManagerTest::SetUpCommandLine(command_line);
}
void SetUpOnMainThread() override {
user_input_methods.push_back("xkb:fr::fra");
user_input_methods.push_back("xkb:de::ger");
......@@ -199,7 +193,8 @@ class LoginUIKeyboardTestWithUsersAndOwner : public chromeos::LoginManagerTest {
chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods(
&user_input_methods);
settings_helper_.SetString(kDeviceOwner, kTestUser3);
scoped_testing_cros_settings_.device_settings()->Set(
kDeviceOwner, base::Value(kTestUser3));
LoginManagerTest::SetUpOnMainThread();
}
......@@ -224,8 +219,7 @@ class LoginUIKeyboardTestWithUsersAndOwner : public chromeos::LoginManagerTest {
protected:
std::vector<std::string> user_input_methods;
ScopedCrosSettingsTestHelper settings_helper_{
/* create_settings_service= */ false};
ScopedTestingCrosSettings scoped_testing_cros_settings_;
};
void LoginUIKeyboardTestWithUsersAndOwner::CheckGaiaKeyboard() {
......
......@@ -11,7 +11,7 @@
#include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chromeos/constants/chromeos_switches.h"
#include "chrome/browser/chromeos/settings/scoped_testing_cros_settings.h"
#include "components/account_id/account_id.h"
#include "components/user_manager/scoped_user_manager.h"
#include "components/user_manager/user_manager.h"
......@@ -53,13 +53,9 @@ class UserManagerHideSupervisedUsersBrowserTest : public LoginManagerTest {
scoped_user_manager_.reset();
}
void SetUpCommandLine(base::CommandLine* command_line) override {
LoginManagerTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(chromeos::switches::kStubCrosSettings);
}
protected:
std::vector<AccountId> test_users_;
ScopedTestingCrosSettings scoped_testing_cros_settings_;
private:
void InitializeTestUsers() {
......
......@@ -23,7 +23,8 @@
#include "chrome/browser/chromeos/policy/device_policy_builder.h"
#include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
#include "chrome/browser/chromeos/settings/scoped_testing_cros_settings.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
#include "chrome/browser/policy/test/local_policy_test_server.h"
#include "chrome/browser/ui/login/login_handler.h"
#include "chrome/browser/ui/webui/signin/signin_utils.h"
......@@ -166,7 +167,6 @@ class WebviewLoginTest : public OobeBaseTest {
void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitch(switches::kOobeSkipPostLogin);
command_line->AppendSwitch(::switches::kUseFakeDeviceForMediaStream);
command_line->AppendSwitch(switches::kStubCrosSettings);
OobeBaseTest::SetUpCommandLine(command_line);
}
......@@ -230,8 +230,7 @@ class WebviewLoginTest : public OobeBaseTest {
}
protected:
ScopedCrosSettingsTestHelper settings_helper_{
/* create_settings_service= */ false};
chromeos::ScopedTestingCrosSettings scoped_testing_cros_settings_;
private:
DISALLOW_COPY_AND_ASSIGN(WebviewLoginTest);
......@@ -303,8 +302,10 @@ IN_PROC_BROWSER_TEST_F(WebviewLoginTest, AllowNewUser) {
test::OobeJS().ExpectTrue(frame_url + ".search('flow=nosignup') == -1");
// Disallow new users - we also need to set a whitelist due to weird logic.
settings_helper_.Set(kAccountsPrefUsers, base::ListValue());
settings_helper_.SetBoolean(kAccountsPrefAllowNewUser, false);
scoped_testing_cros_settings_.device_settings()->Set(kAccountsPrefUsers,
base::ListValue());
scoped_testing_cros_settings_.device_settings()->Set(
kAccountsPrefAllowNewUser, base::Value(false));
WaitForGaiaPageReload();
// flow=nosignup indicates that user creation is not allowed.
......
......@@ -15,11 +15,10 @@
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
#include "chrome/browser/chromeos/settings/scoped_testing_cros_settings.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
#include "chrome/browser/chromeos/system/fake_input_device_settings.h"
#include "chrome/common/pref_names.h"
#include "chromeos/constants/chromeos_switches.h"
#include "components/feedback/tracing_manager.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
......@@ -45,11 +44,9 @@ class PreferencesTest : public LoginManagerTest {
test_users_.push_back(AccountId::FromUserEmailGaiaId(
kTestUsers[i].email, kTestUsers[i].gaia_id));
}
}
void SetUpCommandLine(base::CommandLine* command_line) override {
LoginManagerTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kStubCrosSettings);
scoped_testing_cros_settings_.device_settings()->Set(
kDeviceOwner, base::Value(test_users_[0].GetUserEmail()));
}
void SetUpOnMainThread() override {
......@@ -60,7 +57,6 @@ class PreferencesTest : public LoginManagerTest {
static_cast<input_method::InputMethodManagerImpl*>(
input_method::InputMethodManager::Get())
->SetImeKeyboardForTesting(keyboard_);
settings_helper_.SetString(kDeviceOwner, test_users_[0].GetUserEmail());
}
// Sets set of preferences in given |prefs|. Value of prefernece depends of
......@@ -120,8 +116,7 @@ class PreferencesTest : public LoginManagerTest {
}
std::vector<AccountId> test_users_;
ScopedCrosSettingsTestHelper settings_helper_{
/* create_settings_service= */ false};
ScopedTestingCrosSettings scoped_testing_cros_settings_;
private:
system::InputDeviceSettings::FakeInterface* input_settings_;
......@@ -148,7 +143,7 @@ class PreferencesTestForceWebUiLogin : public PreferencesTest {
IN_PROC_BROWSER_TEST_F(PreferencesTestForceWebUiLogin, PRE_MultiProfiles) {
RegisterUser(test_users_[0]);
RegisterUser(test_users_[1]);
chromeos::StartupUtils::MarkOobeCompleted();
StartupUtils::MarkOobeCompleted();
}
IN_PROC_BROWSER_TEST_F(PreferencesTestForceWebUiLogin, MultiProfiles) {
......
......@@ -27,7 +27,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_CHROMEOS)
#include "chromeos/constants/chromeos_switches.h"
#include "chrome/browser/chromeos/settings/scoped_testing_cros_settings.h"
#endif
using testing::Mock;
......@@ -43,13 +43,6 @@ class SettingsPrivateApiTest : public ExtensionApiTest {
SettingsPrivateApiTest() {}
~SettingsPrivateApiTest() override {}
void SetUpCommandLine(base::CommandLine* command_line) override {
ExtensionApiTest::SetUpCommandLine(command_line);
#if defined(OS_CHROMEOS)
command_line->AppendSwitch(chromeos::switches::kStubCrosSettings);
#endif
}
void SetUpInProcessBrowserTestFixture() override {
EXPECT_CALL(provider_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
......@@ -77,6 +70,10 @@ class SettingsPrivateApiTest : public ExtensionApiTest {
private:
policy::MockConfigurationPolicyProvider provider_;
#if defined(OS_CHROMEOS)
chromeos::ScopedTestingCrosSettings scoped_testing_cros_settings_;
#endif
DISALLOW_COPY_AND_ASSIGN(SettingsPrivateApiTest);
};
......
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