| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/policy/cloud/test_request_interceptor.h" | 11 #include "chrome/browser/policy/cloud/test_request_interceptor.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "components/policy/core/browser/browser_policy_connector.h" | 15 #include "components/policy/core/browser/browser_policy_connector.h" |
| 16 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 16 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 17 #include "components/policy/core/common/cloud/device_management_service.h" |
| 17 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" | 18 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" |
| 18 #include "components/policy/core/common/policy_switches.h" | 19 #include "components/policy/core/common/policy_switches.h" |
| 19 #include "components/policy/core/common/policy_test_utils.h" | 20 #include "components/policy/core/common/policy_test_utils.h" |
| 20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 21 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 22 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
| 23 #include "policy/proto/device_management_backend.pb.h" | 24 #include "policy/proto/device_management_backend.pb.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 27 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 // to intercept requests and produce canned responses. | 49 // to intercept requests and produce canned responses. |
| 49 class CloudPolicyManagerTest : public InProcessBrowserTest { | 50 class CloudPolicyManagerTest : public InProcessBrowserTest { |
| 50 protected: | 51 protected: |
| 51 CloudPolicyManagerTest() {} | 52 CloudPolicyManagerTest() {} |
| 52 ~CloudPolicyManagerTest() override {} | 53 ~CloudPolicyManagerTest() override {} |
| 53 | 54 |
| 54 void SetUpInProcessBrowserTestFixture() override { | 55 void SetUpInProcessBrowserTestFixture() override { |
| 55 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 56 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 56 command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, | 57 command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, |
| 57 "http://localhost"); | 58 "http://localhost"); |
| 59 |
| 60 // Set retry delay to prevent timeouts. |
| 61 policy::DeviceManagementService::SetRetryDelayForTesting(0); |
| 58 } | 62 } |
| 59 | 63 |
| 60 void SetUpOnMainThread() override { | 64 void SetUpOnMainThread() override { |
| 61 ASSERT_TRUE(PolicyServiceIsEmpty(g_browser_process->policy_service())) | 65 ASSERT_TRUE(PolicyServiceIsEmpty(g_browser_process->policy_service())) |
| 62 << "Pre-existing policies in this machine will make this test fail."; | 66 << "Pre-existing policies in this machine will make this test fail."; |
| 63 | 67 |
| 64 interceptor_.reset(new TestRequestInterceptor( | 68 interceptor_.reset(new TestRequestInterceptor( |
| 65 "localhost", | 69 "localhost", |
| 66 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 70 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
| 67 | 71 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 const bool expect_reregister = true; | 198 const bool expect_reregister = true; |
| 195 interceptor_->PushJobCallback( | 199 interceptor_->PushJobCallback( |
| 196 TestRequestInterceptor::RegisterJob(expected_type, expect_reregister)); | 200 TestRequestInterceptor::RegisterJob(expected_type, expect_reregister)); |
| 197 | 201 |
| 198 EXPECT_FALSE(policy_manager()->core()->client()->is_registered()); | 202 EXPECT_FALSE(policy_manager()->core()->client()->is_registered()); |
| 199 ASSERT_NO_FATAL_FAILURE(Register()); | 203 ASSERT_NO_FATAL_FAILURE(Register()); |
| 200 EXPECT_TRUE(policy_manager()->core()->client()->is_registered()); | 204 EXPECT_TRUE(policy_manager()->core()->client()->is_registered()); |
| 201 } | 205 } |
| 202 | 206 |
| 203 } // namespace policy | 207 } // namespace policy |
| OLD | NEW |