OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/memory/scoped_ptr.h" | 5 #include <memory> |
| 6 |
| 7 #include "base/memory/ptr_util.h" |
6 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
7 #include "chrome/browser/browser_process_platform_part.h" | 9 #include "chrome/browser/browser_process_platform_part.h" |
8 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 10 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
9 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 11 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
10 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
11 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 13 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
12 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" | 14 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
14 | 16 |
15 namespace policy { | 17 namespace policy { |
16 | 18 |
17 class DeviceCloudPolicyBrowserTest : public InProcessBrowserTest { | 19 class DeviceCloudPolicyBrowserTest : public InProcessBrowserTest { |
18 public: | 20 public: |
19 DeviceCloudPolicyBrowserTest() : mock_client_(new MockCloudPolicyClient) { | 21 DeviceCloudPolicyBrowserTest() : mock_client_(new MockCloudPolicyClient) { |
20 } | 22 } |
21 | 23 |
22 MockCloudPolicyClient* mock_client_; | 24 MockCloudPolicyClient* mock_client_; |
23 }; | 25 }; |
24 | 26 |
25 IN_PROC_BROWSER_TEST_F(DeviceCloudPolicyBrowserTest, Initializer) { | 27 IN_PROC_BROWSER_TEST_F(DeviceCloudPolicyBrowserTest, Initializer) { |
26 BrowserPolicyConnectorChromeOS* connector = | 28 BrowserPolicyConnectorChromeOS* connector = |
27 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 29 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
28 // Initializer exists at first. | 30 // Initializer exists at first. |
29 EXPECT_TRUE(connector->GetDeviceCloudPolicyInitializer()); | 31 EXPECT_TRUE(connector->GetDeviceCloudPolicyInitializer()); |
30 | 32 |
31 // Initializer is deleted when the manager connects. | 33 // Initializer is deleted when the manager connects. |
32 connector->GetDeviceCloudPolicyManager()->StartConnection( | 34 connector->GetDeviceCloudPolicyManager()->StartConnection( |
33 make_scoped_ptr(mock_client_), | 35 base::WrapUnique(mock_client_), connector->GetInstallAttributes()); |
34 connector->GetInstallAttributes()); | |
35 EXPECT_FALSE(connector->GetDeviceCloudPolicyInitializer()); | 36 EXPECT_FALSE(connector->GetDeviceCloudPolicyInitializer()); |
36 | 37 |
37 // Initializer is restarted when the manager disconnects. | 38 // Initializer is restarted when the manager disconnects. |
38 connector->GetDeviceCloudPolicyManager()->Disconnect(); | 39 connector->GetDeviceCloudPolicyManager()->Disconnect(); |
39 EXPECT_TRUE(connector->GetDeviceCloudPolicyInitializer()); | 40 EXPECT_TRUE(connector->GetDeviceCloudPolicyInitializer()); |
40 } | 41 } |
41 | 42 |
42 } // namespace policy | 43 } // namespace policy |
OLD | NEW |