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
3 // found in the LICENSE file.
5 #include "base/memory/scoped_ptr.h"
6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/browser_process_platform_part.h"
8 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
9 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "components/policy/core/common/cloud/cloud_policy_client.h"
12 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
13 #include "testing/gtest/include/gtest/gtest.h"
17 class DeviceCloudPolicyBrowserTest
: public InProcessBrowserTest
{
19 DeviceCloudPolicyBrowserTest() : mock_client_(new MockCloudPolicyClient
) {
22 MockCloudPolicyClient
* mock_client_
;
25 IN_PROC_BROWSER_TEST_F(DeviceCloudPolicyBrowserTest
, Initializer
) {
26 BrowserPolicyConnectorChromeOS
* connector
=
27 g_browser_process
->platform_part()->browser_policy_connector_chromeos();
28 // Initializer exists at first.
29 EXPECT_TRUE(connector
->GetDeviceCloudPolicyInitializer());
31 // Initializer is deleted when the manager connects.
32 connector
->GetDeviceCloudPolicyManager()->StartConnection(
33 make_scoped_ptr(mock_client_
),
34 connector
->GetInstallAttributes());
35 EXPECT_FALSE(connector
->GetDeviceCloudPolicyInitializer());
37 // Initializer is restarted when the manager disconnects.
38 connector
->GetDeviceCloudPolicyManager()->Disconnect();
39 EXPECT_TRUE(connector
->GetDeviceCloudPolicyInitializer());