Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3646)

Unified Diff: chrome/browser/chromeos/settings/shutdown_policy_handler_unittest.cc

Issue 2497123002: chromeos: Move device shutdown handling out of chrome into ash (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_);
}
« no previous file with comments | « chrome/browser/chromeos/settings/shutdown_policy_handler.cc ('k') | chrome/browser/chromeos/shutdown_policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698