| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/chromeos/login/users/user_manager.h" | 20 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 21 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 21 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
| 22 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 22 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 23 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 23 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 24 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 24 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 25 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 25 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
| 26 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 26 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 27 #include "chrome/browser/extensions/api/power/power_api_manager.h" | |
| 28 #include "chrome/browser/lifetime/application_lifetime.h" | 27 #include "chrome/browser/lifetime/application_lifetime.h" |
| 29 #include "chrome/browser/policy/profile_policy_connector.h" | 28 #include "chrome/browser/policy/profile_policy_connector.h" |
| 30 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 29 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 31 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 32 #include "chrome/browser/profiles/profile_manager.h" | 31 #include "chrome/browser/profiles/profile_manager.h" |
| 33 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
| 34 #include "chrome/common/extensions/api/power.h" | |
| 35 #include "chrome/test/base/testing_profile.h" | 33 #include "chrome/test/base/testing_profile.h" |
| 36 #include "chromeos/chromeos_paths.h" | 34 #include "chromeos/chromeos_paths.h" |
| 37 #include "chromeos/chromeos_switches.h" | 35 #include "chromeos/chromeos_switches.h" |
| 38 #include "chromeos/dbus/cryptohome_client.h" | 36 #include "chromeos/dbus/cryptohome_client.h" |
| 39 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 37 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
| 40 #include "chromeos/dbus/fake_power_manager_client.h" | 38 #include "chromeos/dbus/fake_power_manager_client.h" |
| 41 #include "chromeos/dbus/fake_session_manager_client.h" | 39 #include "chromeos/dbus/fake_session_manager_client.h" |
| 42 #include "chromeos/dbus/power_manager/policy.pb.h" | 40 #include "chromeos/dbus/power_manager/policy.pb.h" |
| 43 #include "chromeos/dbus/power_policy_controller.h" | 41 #include "chromeos/dbus/power_policy_controller.h" |
| 44 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 42 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 45 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 43 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 46 #include "components/policy/core/common/cloud/policy_builder.h" | 44 #include "components/policy/core/common/cloud/policy_builder.h" |
| 47 #include "components/policy/core/common/external_data_fetcher.h" | 45 #include "components/policy/core/common/external_data_fetcher.h" |
| 48 #include "components/policy/core/common/mock_policy_service.h" | 46 #include "components/policy/core/common/mock_policy_service.h" |
| 49 #include "components/policy/core/common/policy_service.h" | 47 #include "components/policy/core/common/policy_service.h" |
| 50 #include "content/public/browser/notification_details.h" | 48 #include "content/public/browser/notification_details.h" |
| 51 #include "content/public/browser/notification_service.h" | 49 #include "content/public/browser/notification_service.h" |
| 52 #include "content/public/browser/notification_source.h" | 50 #include "content/public/browser/notification_source.h" |
| 53 #include "content/public/test/test_utils.h" | 51 #include "content/public/test/test_utils.h" |
| 52 #include "extensions/browser/api/power/power_api_manager.h" |
| 53 #include "extensions/common/api/power.h" |
| 54 #include "policy/proto/device_management_backend.pb.h" | 54 #include "policy/proto/device_management_backend.pb.h" |
| 55 #include "testing/gmock/include/gmock/gmock.h" | 55 #include "testing/gmock/include/gmock/gmock.h" |
| 56 #include "testing/gtest/include/gtest/gtest.h" | 56 #include "testing/gtest/include/gtest/gtest.h" |
| 57 | 57 |
| 58 namespace em = enterprise_management; | 58 namespace em = enterprise_management; |
| 59 namespace pm = power_manager; | 59 namespace pm = power_manager; |
| 60 | 60 |
| 61 using ::testing::AnyNumber; | 61 using ::testing::AnyNumber; |
| 62 using ::testing::InvokeWithoutArgs; | 62 using ::testing::InvokeWithoutArgs; |
| 63 using ::testing::_; | 63 using ::testing::_; |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 // Default settings should have delays. | 474 // Default settings should have delays. |
| 475 pm::PowerManagementPolicy power_management_policy = baseline_policy; | 475 pm::PowerManagementPolicy power_management_policy = baseline_policy; |
| 476 EXPECT_NE(0, baseline_policy.ac_delays().screen_dim_ms()); | 476 EXPECT_NE(0, baseline_policy.ac_delays().screen_dim_ms()); |
| 477 EXPECT_NE(0, baseline_policy.ac_delays().screen_off_ms()); | 477 EXPECT_NE(0, baseline_policy.ac_delays().screen_off_ms()); |
| 478 EXPECT_NE(0, baseline_policy.battery_delays().screen_dim_ms()); | 478 EXPECT_NE(0, baseline_policy.battery_delays().screen_dim_ms()); |
| 479 EXPECT_NE(0, baseline_policy.battery_delays().screen_off_ms()); | 479 EXPECT_NE(0, baseline_policy.battery_delays().screen_off_ms()); |
| 480 | 480 |
| 481 // Pretend an extension grabs a screen wake lock. | 481 // Pretend an extension grabs a screen wake lock. |
| 482 const char kExtensionId[] = "abcdefghijklmnopabcdefghijlkmnop"; | 482 const char kExtensionId[] = "abcdefghijklmnopabcdefghijlkmnop"; |
| 483 extensions::PowerApiManager::Get(browser()->profile())->AddRequest( | 483 extensions::PowerApiManager::Get(browser()->profile())->AddRequest( |
| 484 kExtensionId, extensions::api::power::LEVEL_DISPLAY); | 484 kExtensionId, extensions::core_api::power::LEVEL_DISPLAY); |
| 485 base::RunLoop().RunUntilIdle(); | 485 base::RunLoop().RunUntilIdle(); |
| 486 | 486 |
| 487 // Check that the lock is in effect (ignoring ac_idle_action, | 487 // Check that the lock is in effect (ignoring ac_idle_action, |
| 488 // battery_idle_action and reason). | 488 // battery_idle_action and reason). |
| 489 pm::PowerManagementPolicy policy = baseline_policy; | 489 pm::PowerManagementPolicy policy = baseline_policy; |
| 490 policy.mutable_ac_delays()->set_screen_dim_ms(0); | 490 policy.mutable_ac_delays()->set_screen_dim_ms(0); |
| 491 policy.mutable_ac_delays()->set_screen_off_ms(0); | 491 policy.mutable_ac_delays()->set_screen_off_ms(0); |
| 492 policy.mutable_battery_delays()->set_screen_dim_ms(0); | 492 policy.mutable_battery_delays()->set_screen_dim_ms(0); |
| 493 policy.mutable_battery_delays()->set_screen_off_ms(0); | 493 policy.mutable_battery_delays()->set_screen_off_ms(0); |
| 494 policy.set_ac_idle_action( | 494 policy.set_ac_idle_action( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 505 policy = baseline_policy; | 505 policy = baseline_policy; |
| 506 policy.set_ac_idle_action(power_manager_client_->policy().ac_idle_action()); | 506 policy.set_ac_idle_action(power_manager_client_->policy().ac_idle_action()); |
| 507 policy.set_battery_idle_action( | 507 policy.set_battery_idle_action( |
| 508 power_manager_client_->policy().battery_idle_action()); | 508 power_manager_client_->policy().battery_idle_action()); |
| 509 policy.set_reason(power_manager_client_->policy().reason()); | 509 policy.set_reason(power_manager_client_->policy().reason()); |
| 510 EXPECT_EQ(GetDebugString(policy), | 510 EXPECT_EQ(GetDebugString(policy), |
| 511 GetDebugString(power_manager_client_->policy())); | 511 GetDebugString(power_manager_client_->policy())); |
| 512 } | 512 } |
| 513 | 513 |
| 514 } // namespace policy | 514 } // namespace policy |
| OLD | NEW |