| Index: chrome/browser/chromeos/settings/shutdown_policy_handler_unittest.cc
|
| diff --git a/chrome/browser/chromeos/settings/shutdown_policy_handler_unittest.cc b/chrome/browser/chromeos/settings/shutdown_policy_handler_unittest.cc
|
| index eadd410c3cbb810478e1c915e872d0a25932db95..243000ae4032e561cff8697d82fe585407562e85 100644
|
| --- a/chrome/browser/chromeos/settings/shutdown_policy_handler_unittest.cc
|
| +++ b/chrome/browser/chromeos/settings/shutdown_policy_handler_unittest.cc
|
| @@ -6,21 +6,16 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| -#include "base/command_line.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/run_loop.h"
|
| #include "base/values.h"
|
| -#include "chrome/browser/chromeos/settings/device_settings_service.h"
|
| -#include "chromeos/chromeos_switches.h"
|
| -#include "chromeos/dbus/dbus_thread_manager.h"
|
| +#include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
|
| #include "chromeos/settings/cros_settings_names.h"
|
| -#include "chromeos/settings/cros_settings_provider.h"
|
| -#include "content/public/test/test_browser_thread_bundle.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace chromeos {
|
|
|
| -class ShutdownPolicyHandlerTest : public testing::Test,
|
| +class ShutdownPolicyHandlerTest : public OwnerSettingsTestBase,
|
| public ShutdownPolicyHandler::Delegate {
|
| public:
|
| void ResultCallback(bool reboot_on_shutdown) {
|
| @@ -30,29 +25,12 @@ class ShutdownPolicyHandlerTest : public testing::Test,
|
|
|
| protected:
|
| ShutdownPolicyHandlerTest()
|
| - : cros_settings_(nullptr),
|
| - callback_called_(false),
|
| + : callback_called_(false),
|
| reboot_on_shutdown_(false),
|
| - delegate_invocations_count_(0) {
|
| - base::CommandLine::ForCurrentProcess()->AppendSwitch(
|
| - switches::kStubCrosSettings);
|
| - test_cros_settings_.reset(new ScopedTestCrosSettings);
|
| -}
|
| -
|
| - // testing::Test:
|
| -void SetUp() override {
|
| - testing::Test::SetUp();
|
| - cros_settings_ = CrosSettings::Get();
|
| - DBusThreadManager::Initialize();
|
| - }
|
| -
|
| - void TearDown() override { DBusThreadManager::Shutdown(); }
|
| + delegate_invocations_count_(0) {}
|
|
|
| void SetRebootOnShutdown(bool reboot_on_shutdown) {
|
| - const base::FundamentalValue reboot_on_shutdown_value(reboot_on_shutdown);
|
| - CrosSettings::Get()
|
| - ->GetProvider(kRebootOnShutdown)
|
| - ->Set(kRebootOnShutdown, reboot_on_shutdown_value);
|
| + owner_settings_service_->SetBoolean(kRebootOnShutdown, reboot_on_shutdown);
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| @@ -63,21 +41,14 @@ void SetUp() override {
|
| }
|
|
|
| protected:
|
| - content::TestBrowserThreadBundle thread_bundle_;
|
| -
|
| - CrosSettings* cros_settings_;
|
| - scoped_ptr<CrosSettingsProvider> device_settings_provider_;
|
| -
|
| - ScopedTestDeviceSettingsService test_device_settings_service_;
|
| - scoped_ptr<ScopedTestCrosSettings> test_cros_settings_;
|
| -
|
| bool callback_called_;
|
| bool reboot_on_shutdown_;
|
| int delegate_invocations_count_;
|
| };
|
|
|
| TEST_F(ShutdownPolicyHandlerTest, RetrieveTrustedDevicePolicies) {
|
| - ShutdownPolicyHandler shutdown_policy_observer(cros_settings_, this);
|
| + ReplaceProvider(kRebootOnShutdown);
|
| + ShutdownPolicyHandler shutdown_policy_observer(CrosSettings::Get(), this);
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_EQ(0, delegate_invocations_count_);
|
|
|
| @@ -100,7 +71,8 @@ TEST_F(ShutdownPolicyHandlerTest, RetrieveTrustedDevicePolicies) {
|
| }
|
|
|
| TEST_F(ShutdownPolicyHandlerTest, CheckIfRebootOnShutdown) {
|
| - ShutdownPolicyHandler shutdown_policy_observer(cros_settings_, this);
|
| + ReplaceProvider(kRebootOnShutdown);
|
| + ShutdownPolicyHandler shutdown_policy_observer(CrosSettings::Get(), this);
|
| base::RunLoop().RunUntilIdle();
|
|
|
| // Allow shutdown.
|
|
|