| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/base_paths.h" | 5 #include "base/base_paths.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/policy/browser_policy_connector.h" | 15 #include "chrome/browser/policy/browser_policy_connector.h" |
| 16 #include "chrome/browser/policy/cloud_policy_client.h" | 16 #include "chrome/browser/policy/cloud_policy_client.h" |
| 17 #include "chrome/browser/policy/cloud_policy_constants.h" | 17 #include "chrome/browser/policy/cloud_policy_constants.h" |
| 18 #include "chrome/browser/policy/policy_map.h" | 18 #include "chrome/browser/policy/policy_map.h" |
| 19 #include "chrome/browser/policy/policy_service.h" | 19 #include "chrome/browser/policy/policy_service.h" |
| 20 #include "chrome/browser/policy/proto/chrome_settings.pb.h" | 20 #include "chrome/browser/policy/proto/chrome_settings.pb.h" |
| 21 #include "chrome/browser/policy/proto/cloud_policy.pb.h" | 21 #include "chrome/browser/policy/proto/cloud_policy.pb.h" |
| 22 #include "chrome/browser/policy/test_utils.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/test/base/in_process_browser_test.h" | 27 #include "chrome/test/base/in_process_browser_test.h" |
| 27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
| 30 #include "content/public/test/test_utils.h" | 31 #include "content/public/test/test_utils.h" |
| 31 #include "googleurl/src/gurl.h" | 32 #include "googleurl/src/gurl.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 temp_dir_.path().BaseName())); | 131 temp_dir_.path().BaseName())); |
| 131 ASSERT_TRUE(test_server_->Start()); | 132 ASSERT_TRUE(test_server_->Start()); |
| 132 | 133 |
| 133 std::string url = test_server_->GetURL("device_management").spec(); | 134 std::string url = test_server_->GetURL("device_management").spec(); |
| 134 | 135 |
| 135 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 136 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 136 command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, url); | 137 command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, url); |
| 137 } | 138 } |
| 138 | 139 |
| 139 virtual void SetUpOnMainThread() OVERRIDE { | 140 virtual void SetUpOnMainThread() OVERRIDE { |
| 140 // Checks that no policies have been loaded by the other providers before | 141 ASSERT_TRUE(PolicyServiceIsEmpty(g_browser_process->policy_service())) |
| 141 // setting up the cloud connection. Other policies configured in the test | 142 << "Pre-existing policies in this machine will make this test fail."; |
| 142 // machine will interfere with these tests. | |
| 143 const PolicyMap& map = g_browser_process->policy_service()->GetPolicies( | |
| 144 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); | |
| 145 if (!map.empty()) { | |
| 146 base::DictionaryValue dict; | |
| 147 for (PolicyMap::const_iterator it = map.begin(); it != map.end(); ++it) | |
| 148 dict.SetWithoutPathExpansion(it->first, it->second.value->DeepCopy()); | |
| 149 ADD_FAILURE() | |
| 150 << "There are pre-existing policies in this machine that will " | |
| 151 << "interfere with these tests. Policies found: " << dict; | |
| 152 } | |
| 153 | 143 |
| 154 BrowserPolicyConnector* connector = | 144 BrowserPolicyConnector* connector = |
| 155 g_browser_process->browser_policy_connector(); | 145 g_browser_process->browser_policy_connector(); |
| 156 connector->ScheduleServiceInitialization(0); | 146 connector->ScheduleServiceInitialization(0); |
| 157 | 147 |
| 158 #if defined(OS_CHROMEOS) | 148 #if defined(OS_CHROMEOS) |
| 159 UserCloudPolicyManagerChromeOS* policy_manager = | 149 UserCloudPolicyManagerChromeOS* policy_manager = |
| 160 connector->GetUserCloudPolicyManager(); | 150 connector->GetUserCloudPolicyManager(); |
| 161 ASSERT_TRUE(policy_manager); | 151 ASSERT_TRUE(policy_manager); |
| 162 #else | 152 #else |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 270 |
| 281 // They should now serialize to the same bytes. | 271 // They should now serialize to the same bytes. |
| 282 std::string chrome_settings_serialized; | 272 std::string chrome_settings_serialized; |
| 283 std::string cloud_policy_serialized; | 273 std::string cloud_policy_serialized; |
| 284 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); | 274 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); |
| 285 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); | 275 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); |
| 286 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); | 276 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); |
| 287 } | 277 } |
| 288 | 278 |
| 289 } // namespace policy | 279 } // namespace policy |
| OLD | NEW |