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

Unified Diff: chrome/browser/ui/webui/chromeos/login/shutdown_policy_observer_unittest.cc

Issue 811033002: Add device policy to disallow shutdown - ash UI modifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reduced scope of CL (ash only now, removed webui changes) Created 5 years, 11 months 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/ui/webui/chromeos/login/shutdown_policy_observer_unittest.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/shutdown_policy_observer_unittest.cc b/chrome/browser/ui/webui/chromeos/login/shutdown_policy_observer_unittest.cc
deleted file mode 100644
index 4136f994f68276b88b44640de398e3b37412f45a..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/webui/chromeos/login/shutdown_policy_observer_unittest.cc
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/chromeos/login/shutdown_policy_observer.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/command_line.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/run_loop.h"
-#include "base/values.h"
-#include "chrome/browser/chromeos/settings/device_settings_service.h"
-#include "chromeos/chromeos_switches.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 ShutdownPolicyObserverTest : public testing::Test,
- public ShutdownPolicyObserver::Delegate {
- public:
- void ResultCallback(bool reboot_on_shutdown) {
- reboot_on_shutdown_ = reboot_on_shutdown;
- callback_called_ = true;
- }
-
- protected:
- ShutdownPolicyObserverTest()
- : cros_settings_(nullptr),
- callback_called_(false),
- reboot_on_shutdown_(false),
- delegate_invocations_count_(0) {
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kStubCrosSettings);
- test_cros_settings_.reset(new ScopedTestCrosSettings);
-}
-
- // testing::Test:
- virtual void SetUp() override {
- testing::Test::SetUp();
- cros_settings_ = CrosSettings::Get();
- DBusThreadManager::Initialize();
- }
-
- virtual void TearDown() override {
- DBusThreadManager::Shutdown();
- }
-
- 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);
- base::RunLoop().RunUntilIdle();
- }
-
- // ShutdownPolicyObserver::Delegate:
- void OnShutdownPolicyChanged(bool reboot_on_shutdown) override {
- reboot_on_shutdown_ = reboot_on_shutdown;
- delegate_invocations_count_++;
- }
-
- 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(ShutdownPolicyObserverTest, RetrieveTrustedDevicePolicies) {
- ShutdownPolicyObserver shutdown_policy_observer(cros_settings_, this);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, delegate_invocations_count_);
-
- SetRebootOnShutdown(true);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(1, delegate_invocations_count_);
- EXPECT_TRUE(reboot_on_shutdown_);
-
- 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(ShutdownPolicyObserverTest, CheckIfRebootOnShutdown) {
- ShutdownPolicyObserver shutdown_policy_observer(cros_settings_, this);
- base::RunLoop().RunUntilIdle();
-
- // Allow shutdown.
- SetRebootOnShutdown(true);
- callback_called_ = false;
- shutdown_policy_observer.CheckIfRebootOnShutdown(
- base::Bind(&ShutdownPolicyObserverTest::ResultCallback,
- base::Unretained(this)));
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(callback_called_);
- EXPECT_EQ(true, reboot_on_shutdown_);
- // Forbid shutdown.
- SetRebootOnShutdown(false);
- callback_called_ = false;
- shutdown_policy_observer.CheckIfRebootOnShutdown(
- base::Bind(&ShutdownPolicyObserverTest::ResultCallback,
- base::Unretained(this)));
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(callback_called_);
- EXPECT_EQ(false, reboot_on_shutdown_);
-}
-
-} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698