| 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" | |
| 6 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 7 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/path_service.h" | |
| 11 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 12 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 13 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/policy/browser_policy_connector.h" | 12 #include "chrome/browser/policy/browser_policy_connector.h" |
| 15 #include "chrome/browser/policy/cloud_policy_client.h" | 13 #include "chrome/browser/policy/cloud_policy_client.h" |
| 16 #include "chrome/browser/policy/cloud_policy_constants.h" | 14 #include "chrome/browser/policy/cloud_policy_constants.h" |
| 17 #include "chrome/browser/policy/policy_map.h" | 15 #include "chrome/browser/policy/policy_map.h" |
| 18 #include "chrome/browser/policy/policy_service.h" | 16 #include "chrome/browser/policy/policy_service.h" |
| 19 #include "chrome/browser/policy/proto/chrome_settings.pb.h" | 17 #include "chrome/browser/policy/proto/chrome_settings.pb.h" |
| 20 #include "chrome/browser/policy/proto/cloud_policy.pb.h" | 18 #include "chrome/browser/policy/proto/cloud_policy.pb.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 108 |
| 111 } // namespace | 109 } // namespace |
| 112 | 110 |
| 113 // Tests the cloud policy stack(s). | 111 // Tests the cloud policy stack(s). |
| 114 class CloudPolicyTest : public InProcessBrowserTest { | 112 class CloudPolicyTest : public InProcessBrowserTest { |
| 115 protected: | 113 protected: |
| 116 CloudPolicyTest() {} | 114 CloudPolicyTest() {} |
| 117 virtual ~CloudPolicyTest() {} | 115 virtual ~CloudPolicyTest() {} |
| 118 | 116 |
| 119 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 117 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 120 // The TestServer wants the docroot as a path relative to the source dir. | 118 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 121 FilePath source; | |
| 122 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &source)); | |
| 123 ASSERT_TRUE(temp_dir_.CreateUniqueTempDirUnderPath(source)); | |
| 124 ASSERT_NO_FATAL_FAILURE(SetServerPolicy(GetEmptyPolicy())); | 119 ASSERT_NO_FATAL_FAILURE(SetServerPolicy(GetEmptyPolicy())); |
| 125 | 120 |
| 126 test_server_.reset( | 121 test_server_.reset( |
| 127 new net::TestServer( | 122 new net::TestServer( |
| 128 net::TestServer::TYPE_HTTP, | 123 net::TestServer::TYPE_HTTP, |
| 129 net::TestServer::kLocalhost, | 124 net::TestServer::kLocalhost, |
| 130 temp_dir_.path().BaseName())); | 125 temp_dir_.path())); |
| 131 ASSERT_TRUE(test_server_->Start()); | 126 ASSERT_TRUE(test_server_->Start()); |
| 132 | 127 |
| 133 std::string url = test_server_->GetURL("device_management").spec(); | 128 std::string url = test_server_->GetURL("device_management").spec(); |
| 134 | 129 |
| 135 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 130 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 136 command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, url); | 131 command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, url); |
| 137 } | 132 } |
| 138 | 133 |
| 139 virtual void SetUpOnMainThread() OVERRIDE { | 134 virtual void SetUpOnMainThread() OVERRIDE { |
| 140 // Checks that no policies have been loaded by the other providers before | 135 // Checks that no policies have been loaded by the other providers before |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 274 |
| 280 // They should now serialize to the same bytes. | 275 // They should now serialize to the same bytes. |
| 281 std::string chrome_settings_serialized; | 276 std::string chrome_settings_serialized; |
| 282 std::string cloud_policy_serialized; | 277 std::string cloud_policy_serialized; |
| 283 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); | 278 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); |
| 284 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); | 279 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); |
| 285 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); | 280 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); |
| 286 } | 281 } |
| 287 | 282 |
| 288 } // namespace policy | 283 } // namespace policy |
| OLD | NEW |