Chromium Code Reviews| 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..6361352c411f499b8e4f83ebcb4ea44ae3d70e58 100644 |
| --- a/chrome/browser/chromeos/settings/shutdown_policy_handler_unittest.cc |
| +++ b/chrome/browser/chromeos/settings/shutdown_policy_handler_unittest.cc |
| @@ -6,21 +6,19 @@ |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| -#include "base/command_line.h" |
| #include "base/memory/scoped_ptr.h" |
|
bartfab (slow)
2015/03/31 14:12:41
Nit: No longer used.
|
| #include "base/run_loop.h" |
| #include "base/values.h" |
|
bartfab (slow)
2015/03/31 14:12:41
Nit: No longer used.
|
| -#include "chrome/browser/chromeos/settings/device_settings_service.h" |
| -#include "chromeos/chromeos_switches.h" |
| +#include "chrome/browser/chromeos/settings/settings_provider_test_base.h" |
| #include "chromeos/dbus/dbus_thread_manager.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, |
| + public SettingsProviderTestBase, |
| public ShutdownPolicyHandler::Delegate { |
| public: |
| void ResultCallback(bool reboot_on_shutdown) { |
| @@ -30,29 +28,24 @@ 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); |
| -} |
| + delegate_invocations_count_(0) {} |
| // testing::Test: |
| -void SetUp() override { |
| + void SetUp() override { |
| testing::Test::SetUp(); |
| - cros_settings_ = CrosSettings::Get(); |
| DBusThreadManager::Initialize(); |
| + ReplaceProvider(kRebootOnShutdown); |
| } |
| - void TearDown() override { DBusThreadManager::Shutdown(); } |
| + void TearDown() override { |
| + DBusThreadManager::Shutdown(); |
| + RestoreProvider(); |
| + } |
| 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); |
| + stub_settings_provider_.SetBoolean(kRebootOnShutdown, reboot_on_shutdown); |
|
bartfab (slow)
2015/03/31 14:12:41
Nit: #include "chrome/browser/chromeos/settings/st
|
| base::RunLoop().RunUntilIdle(); |
| } |
| @@ -64,20 +57,13 @@ 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); |
| + ShutdownPolicyHandler shutdown_policy_observer(CrosSettings::Get(), this); |
| base::RunLoop().RunUntilIdle(); |
| EXPECT_EQ(0, delegate_invocations_count_); |
| @@ -100,7 +86,7 @@ TEST_F(ShutdownPolicyHandlerTest, RetrieveTrustedDevicePolicies) { |
| } |
| TEST_F(ShutdownPolicyHandlerTest, CheckIfRebootOnShutdown) { |
| - ShutdownPolicyHandler shutdown_policy_observer(cros_settings_, this); |
| + ShutdownPolicyHandler shutdown_policy_observer(CrosSettings::Get(), this); |
| base::RunLoop().RunUntilIdle(); |
| // Allow shutdown. |