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..5d030dde4a5948c5531810971aab300827b2e8e2 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,7 +44,6 @@ class ShutdownPolicyHandlerTest : public testing::Test, |
protected: |
content::TestBrowserThreadBundle thread_bundle_; |
ScopedCrosSettingsTestHelper settings_helper_; |
- bool callback_called_; |
bool reboot_on_shutdown_; |
int delegate_invocations_count_; |
}; |
@@ -62,45 +53,41 @@ TEST_F(ShutdownPolicyHandlerTest, RetrieveTrustedDevicePolicies) { |
base::RunLoop().RunUntilIdle(); |
EXPECT_EQ(0, delegate_invocations_count_); |
+ // Changing the setting to true notifies the delegate. |
SetRebootOnShutdown(true); |
base::RunLoop().RunUntilIdle(); |
EXPECT_EQ(1, delegate_invocations_count_); |
EXPECT_TRUE(reboot_on_shutdown_); |
+ // Changing the setting to false notifies the delegate. |
SetRebootOnShutdown(false); |
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); |
base::RunLoop().RunUntilIdle(); |
+ EXPECT_EQ(0, delegate_invocations_count_); |
+ EXPECT_FALSE(reboot_on_shutdown_); |
// Allow shutdown. |
SetRebootOnShutdown(true); |
- callback_called_ = false; |
- shutdown_policy_observer.CheckIfRebootOnShutdown( |
- base::Bind(&ShutdownPolicyHandlerTest::ResultCallback, |
- base::Unretained(this))); |
+ delegate_invocations_count_ = 0; |
+ // Request an explicit check. |
+ shutdown_policy_observer.CheckIfRebootOnShutdown(); |
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 an explicit check. |
+ shutdown_policy_observer.CheckIfRebootOnShutdown(); |
base::RunLoop().RunUntilIdle(); |
- EXPECT_TRUE(callback_called_); |
+ EXPECT_EQ(1, delegate_invocations_count_); |
EXPECT_FALSE(reboot_on_shutdown_); |
} |