| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/settings/shutdown_policy_handler.h" | 5 #include "chrome/browser/chromeos/settings/shutdown_policy_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 : cros_settings_(nullptr), | 33 : cros_settings_(nullptr), |
| 34 callback_called_(false), | 34 callback_called_(false), |
| 35 reboot_on_shutdown_(false), | 35 reboot_on_shutdown_(false), |
| 36 delegate_invocations_count_(0) { | 36 delegate_invocations_count_(0) { |
| 37 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 37 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 38 switches::kStubCrosSettings); | 38 switches::kStubCrosSettings); |
| 39 test_cros_settings_.reset(new ScopedTestCrosSettings); | 39 test_cros_settings_.reset(new ScopedTestCrosSettings); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // testing::Test: | 42 // testing::Test: |
| 43 virtual void SetUp() override { | 43 void SetUp() override { |
| 44 testing::Test::SetUp(); | 44 testing::Test::SetUp(); |
| 45 cros_settings_ = CrosSettings::Get(); | 45 cros_settings_ = CrosSettings::Get(); |
| 46 DBusThreadManager::Initialize(); | 46 DBusThreadManager::Initialize(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual void TearDown() override { | 49 void TearDown() override { DBusThreadManager::Shutdown(); } |
| 50 DBusThreadManager::Shutdown(); | |
| 51 } | |
| 52 | 50 |
| 53 void SetRebootOnShutdown(bool reboot_on_shutdown) { | 51 void SetRebootOnShutdown(bool reboot_on_shutdown) { |
| 54 const base::FundamentalValue reboot_on_shutdown_value(reboot_on_shutdown); | 52 const base::FundamentalValue reboot_on_shutdown_value(reboot_on_shutdown); |
| 55 CrosSettings::Get() | 53 CrosSettings::Get() |
| 56 ->GetProvider(kRebootOnShutdown) | 54 ->GetProvider(kRebootOnShutdown) |
| 57 ->Set(kRebootOnShutdown, reboot_on_shutdown_value); | 55 ->Set(kRebootOnShutdown, reboot_on_shutdown_value); |
| 58 base::RunLoop().RunUntilIdle(); | 56 base::RunLoop().RunUntilIdle(); |
| 59 } | 57 } |
| 60 | 58 |
| 61 // ShutdownPolicyHandler::Delegate: | 59 // ShutdownPolicyHandler::Delegate: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 callback_called_ = false; | 117 callback_called_ = false; |
| 120 shutdown_policy_observer.CheckIfRebootOnShutdown( | 118 shutdown_policy_observer.CheckIfRebootOnShutdown( |
| 121 base::Bind(&ShutdownPolicyHandlerTest::ResultCallback, | 119 base::Bind(&ShutdownPolicyHandlerTest::ResultCallback, |
| 122 base::Unretained(this))); | 120 base::Unretained(this))); |
| 123 base::RunLoop().RunUntilIdle(); | 121 base::RunLoop().RunUntilIdle(); |
| 124 EXPECT_TRUE(callback_called_); | 122 EXPECT_TRUE(callback_called_); |
| 125 EXPECT_EQ(false, reboot_on_shutdown_); | 123 EXPECT_EQ(false, reboot_on_shutdown_); |
| 126 } | 124 } |
| 127 | 125 |
| 128 } // namespace chromeos | 126 } // namespace chromeos |
| OLD | NEW |