| 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 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/extensions/extension_browsertest.h" | 16 #include "chrome/browser/extensions/extension_browsertest.h" |
| 17 #include "chrome/browser/extensions/extension_test_message_listener.h" | 17 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 18 #include "chrome/browser/policy/profile_policy_connector.h" | 18 #include "chrome/browser/policy/profile_policy_connector.h" |
| 19 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 19 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 20 #include "chrome/browser/policy/test/local_policy_test_server.h" | 20 #include "chrome/browser/policy/test/local_policy_test_server.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 24 #include "chrome/common/chrome_switches.h" | |
| 25 #include "components/policy/core/browser/browser_policy_connector.h" | 24 #include "components/policy/core/browser/browser_policy_connector.h" |
| 26 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 25 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 27 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" | 26 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" |
| 28 #include "components/policy/core/common/policy_service.h" | 27 #include "components/policy/core/common/policy_service.h" |
| 29 #include "components/policy/core/common/policy_switches.h" | 28 #include "components/policy/core/common/policy_switches.h" |
| 30 #include "components/policy/core/common/policy_test_utils.h" | 29 #include "components/policy/core/common/policy_test_utils.h" |
| 31 #include "extensions/common/extension.h" | 30 #include "extensions/common/extension.h" |
| 32 #include "net/url_request/url_request_context_getter.h" | 31 #include "net/url_request/url_request_context_getter.h" |
| 33 #include "policy/proto/chrome_extension_policy.pb.h" | 32 #include "policy/proto/chrome_extension_policy.pb.h" |
| 34 #include "policy/proto/cloud_policy.pb.h" | 33 #include "policy/proto/cloud_policy.pb.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 111 } |
| 113 | 112 |
| 114 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 113 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 115 test_server_.RegisterClient(kDMToken, kDeviceID); | 114 test_server_.RegisterClient(kDMToken, kDeviceID); |
| 116 EXPECT_TRUE(test_server_.UpdatePolicyData( | 115 EXPECT_TRUE(test_server_.UpdatePolicyData( |
| 117 dm_protocol::kChromeExtensionPolicyType, kTestExtension, kTestPolicy)); | 116 dm_protocol::kChromeExtensionPolicyType, kTestExtension, kTestPolicy)); |
| 118 ASSERT_TRUE(test_server_.Start()); | 117 ASSERT_TRUE(test_server_.Start()); |
| 119 | 118 |
| 120 std::string url = test_server_.GetServiceURL().spec(); | 119 std::string url = test_server_.GetServiceURL().spec(); |
| 121 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 120 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 122 command_line->AppendSwitchASCII(::switches::kDeviceManagementUrl, url); | 121 command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, url); |
| 123 command_line->AppendSwitch(switches::kEnableComponentCloudPolicy); | 122 command_line->AppendSwitch(switches::kEnableComponentCloudPolicy); |
| 124 | 123 |
| 125 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); | 124 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 126 } | 125 } |
| 127 | 126 |
| 128 virtual void SetUpOnMainThread() OVERRIDE { | 127 virtual void SetUpOnMainThread() OVERRIDE { |
| 129 ASSERT_TRUE(PolicyServiceIsEmpty(g_browser_process->policy_service())) | 128 ASSERT_TRUE(PolicyServiceIsEmpty(g_browser_process->policy_service())) |
| 130 << "Pre-existing policies in this machine will make this test fail."; | 129 << "Pre-existing policies in this machine will make this test fail."; |
| 131 | 130 |
| 132 // Install the initial extension. | 131 // Install the initial extension. |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 ExtensionTestMessageListener signin_policy_listener(kTestPolicyJSON, true); | 328 ExtensionTestMessageListener signin_policy_listener(kTestPolicyJSON, true); |
| 330 event_listener2.Reply("get-policy-Name"); | 329 event_listener2.Reply("get-policy-Name"); |
| 331 EXPECT_TRUE(signin_policy_listener.WaitUntilSatisfied()); | 330 EXPECT_TRUE(signin_policy_listener.WaitUntilSatisfied()); |
| 332 | 331 |
| 333 // And the cache is back. | 332 // And the cache is back. |
| 334 EXPECT_TRUE(base::PathExists(cache_path)); | 333 EXPECT_TRUE(base::PathExists(cache_path)); |
| 335 } | 334 } |
| 336 #endif | 335 #endif |
| 337 | 336 |
| 338 } // namespace policy | 337 } // namespace policy |
| OLD | NEW |