| 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 8b9669f95fec6d5c44602f3dd308b088ed05e8a6..f85c27d20bce77bd6dbe78643399866e0e2e5746 100644
|
| --- a/chrome/browser/chromeos/settings/shutdown_policy_handler_unittest.cc
|
| +++ b/chrome/browser/chromeos/settings/shutdown_policy_handler_unittest.cc
|
| @@ -18,16 +18,8 @@ namespace chromeos {
|
| class ShutdownPolicyHandlerTest : public testing::Test,
|
| public ShutdownPolicyHandler::Delegate {
|
| public:
|
| - void ResultCallback(bool reboot_on_shutdown) {
|
| - reboot_on_shutdown_ = reboot_on_shutdown;
|
| - callback_called_ = true;
|
| - }
|
| -
|
| - protected:
|
| ShutdownPolicyHandlerTest()
|
| - : callback_called_(false),
|
| - reboot_on_shutdown_(false),
|
| - delegate_invocations_count_(0) {}
|
| + : reboot_on_shutdown_(false), delegate_invocations_count_(0) {}
|
|
|
| // testing::Test:
|
| void SetUp() override {
|
| @@ -52,13 +44,12 @@ class ShutdownPolicyHandlerTest : public testing::Test,
|
| protected:
|
| content::TestBrowserThreadBundle thread_bundle_;
|
| ScopedCrosSettingsTestHelper settings_helper_;
|
| - bool callback_called_;
|
| bool reboot_on_shutdown_;
|
| int delegate_invocations_count_;
|
| };
|
|
|
| TEST_F(ShutdownPolicyHandlerTest, RetrieveTrustedDevicePolicies) {
|
| - ShutdownPolicyHandler shutdown_policy_observer(CrosSettings::Get(), this);
|
| + ShutdownPolicyHandler shutdown_policy_handler(CrosSettings::Get(), this);
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_EQ(0, delegate_invocations_count_);
|
|
|
| @@ -71,36 +62,28 @@ TEST_F(ShutdownPolicyHandlerTest, RetrieveTrustedDevicePolicies) {
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_EQ(2, delegate_invocations_count_);
|
| EXPECT_FALSE(reboot_on_shutdown_);
|
| -
|
| - shutdown_policy_observer.Shutdown();
|
| -
|
| - SetRebootOnShutdown(true);
|
| - base::RunLoop().RunUntilIdle();
|
| - EXPECT_EQ(2, delegate_invocations_count_);
|
| - EXPECT_FALSE(reboot_on_shutdown_);
|
| }
|
|
|
| -TEST_F(ShutdownPolicyHandlerTest, CheckIfRebootOnShutdown) {
|
| - ShutdownPolicyHandler shutdown_policy_observer(CrosSettings::Get(), this);
|
| +TEST_F(ShutdownPolicyHandlerTest, NotifyDelegateWithShutdownPolicy) {
|
| + ShutdownPolicyHandler shutdown_policy_handler(CrosSettings::Get(), this);
|
| base::RunLoop().RunUntilIdle();
|
|
|
| // Allow shutdown.
|
| SetRebootOnShutdown(true);
|
| - callback_called_ = false;
|
| - shutdown_policy_observer.CheckIfRebootOnShutdown(
|
| - base::Bind(&ShutdownPolicyHandlerTest::ResultCallback,
|
| - base::Unretained(this)));
|
| + delegate_invocations_count_ = 0;
|
| + // Request a manual update.
|
| + shutdown_policy_handler.NotifyDelegateWithShutdownPolicy();
|
| base::RunLoop().RunUntilIdle();
|
| - EXPECT_TRUE(callback_called_);
|
| + EXPECT_EQ(1, delegate_invocations_count_);
|
| EXPECT_TRUE(reboot_on_shutdown_);
|
| +
|
| // Forbid shutdown.
|
| SetRebootOnShutdown(false);
|
| - callback_called_ = false;
|
| - shutdown_policy_observer.CheckIfRebootOnShutdown(
|
| - base::Bind(&ShutdownPolicyHandlerTest::ResultCallback,
|
| - base::Unretained(this)));
|
| + delegate_invocations_count_ = 0;
|
| + // Request a manual update.
|
| + shutdown_policy_handler.NotifyDelegateWithShutdownPolicy();
|
| base::RunLoop().RunUntilIdle();
|
| - EXPECT_TRUE(callback_called_);
|
| + EXPECT_EQ(1, delegate_invocations_count_);
|
| EXPECT_FALSE(reboot_on_shutdown_);
|
| }
|
|
|
|
|