OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chromeos/dbus/power_policy_controller.h" | 5 #include "chromeos/dbus/power_policy_controller.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "chromeos/dbus/fake_power_manager_client.h" | 10 #include "chromeos/dbus/fake_power_manager_client.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 policy_controller_->NotifyChromeIsExiting(); | 368 policy_controller_->NotifyChromeIsExiting(); |
369 | 369 |
370 expected_policy.set_lid_closed_action( | 370 expected_policy.set_lid_closed_action( |
371 power_manager::PowerManagementPolicy_Action_DO_NOTHING); | 371 power_manager::PowerManagementPolicy_Action_DO_NOTHING); |
372 // Lid-closed action successfully changed to "do nothing". | 372 // Lid-closed action successfully changed to "do nothing". |
373 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy), | 373 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy), |
374 PowerPolicyController::GetPolicyDebugString( | 374 PowerPolicyController::GetPolicyDebugString( |
375 fake_power_client_->policy())); | 375 fake_power_client_->policy())); |
376 } | 376 } |
377 | 377 |
| 378 TEST_F(PowerPolicyControllerTest, SuspendOnLidClosedWhileSignedOut) { |
| 379 PowerPolicyController::PrefValues prefs; |
| 380 policy_controller_->ApplyPrefs(prefs); |
| 381 const power_manager::PowerManagementPolicy kDefaultPolicy = |
| 382 fake_power_client_->policy(); |
| 383 |
| 384 prefs.lid_closed_action = PowerPolicyController::ACTION_SHUT_DOWN; |
| 385 policy_controller_->ApplyPrefs(prefs); |
| 386 |
| 387 power_manager::PowerManagementPolicy expected_policy; |
| 388 expected_policy = kDefaultPolicy; |
| 389 expected_policy.set_lid_closed_action( |
| 390 power_manager::PowerManagementPolicy_Action_SHUT_DOWN); |
| 391 // Sanity check |
| 392 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy), |
| 393 PowerPolicyController::GetPolicyDebugString( |
| 394 fake_power_client_->policy())); |
| 395 |
| 396 policy_controller_->SetEncryptionMigrationActive(true); |
| 397 expected_policy.set_lid_closed_action( |
| 398 power_manager::PowerManagementPolicy_Action_SUSPEND); |
| 399 expected_policy.set_reason("Prefs, encryption migration"); |
| 400 // Lid-closed action successfully changed to "suspend". |
| 401 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy), |
| 402 PowerPolicyController::GetPolicyDebugString( |
| 403 fake_power_client_->policy())); |
| 404 } |
| 405 |
378 } // namespace chromeos | 406 } // namespace chromeos |
OLD | NEW |