Chromium Code Reviews| 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/compiler_specific.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/logging.h" | 6 #include "chrome/browser/browser_process.h" |
| 7 #include "base/macros.h" | 7 #include "chrome/browser/browser_process_platform_part.h" |
| 8 #include "base/message_loop/message_loop.h" | |
| 9 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 8 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 10 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
| 11 #include "chrome/test/base/testing_browser_process.h" | 10 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 11 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace policy { | 14 namespace policy { |
| 15 namespace { | |
| 16 | 15 |
| 17 // A test fixture simulating a browser that is already managed. | 16 class DeviceCloudPolicyBrowserTest : public InProcessBrowserTest { |
| 18 class DeviceCloudPolicyManagedBrowserTest : public DevicePolicyCrosBrowserTest { | 17 public: |
| 19 protected: | 18 DeviceCloudPolicyBrowserTest() : mock_client_(new MockCloudPolicyClient) { |
| 20 DeviceCloudPolicyManagedBrowserTest() {} | |
| 21 | |
| 22 virtual void SetUpInProcessBrowserTestFixture() override { | |
| 23 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); | |
| 24 | |
| 25 InstallOwnerKey(); | |
| 26 MarkAsEnterpriseOwned(); | |
| 27 RefreshDevicePolicy(); | |
| 28 } | 19 } |
| 29 | 20 |
| 30 private: | 21 MockCloudPolicyClient* mock_client_; |
| 31 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagedBrowserTest); | |
| 32 }; | 22 }; |
| 33 | 23 |
| 34 IN_PROC_BROWSER_TEST_F(DeviceCloudPolicyManagedBrowserTest, NoInitializer) { | 24 IN_PROC_BROWSER_TEST_F(DeviceCloudPolicyBrowserTest, Initializer) { |
| 35 BrowserPolicyConnectorChromeOS* connector = | 25 BrowserPolicyConnectorChromeOS* connector = |
| 36 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 26 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 27 // Initializer exists at first. | |
| 28 EXPECT_TRUE(connector->GetDeviceCloudPolicyInitializer()); | |
| 29 | |
| 30 // Initializer is deleted after the manager is connected. | |
|
bartfab (slow)
2014/11/28 13:25:18
Nit: s/after the manager is connected/when the man
davidyu
2014/12/01 17:05:22
Done.
| |
| 31 connector->GetDeviceCloudPolicyManager()->StartConnection( | |
|
bartfab (slow)
2014/11/28 13:25:18
Nit: #include "chrome/browser/chromeos/policy/devi
davidyu
2014/12/01 17:05:22
Done.
| |
| 32 make_scoped_ptr(mock_client_), | |
| 33 scoped_ptr<CloudPolicyClient::StatusProvider>()); | |
| 37 EXPECT_FALSE(connector->GetDeviceCloudPolicyInitializer()); | 34 EXPECT_FALSE(connector->GetDeviceCloudPolicyInitializer()); |
| 38 } | |
| 39 | 35 |
| 40 // A test fixture simulating a browser that is still unmanaged. | 36 // Initializer is restarted after the manager is disconnected. |
|
bartfab (slow)
2014/11/28 13:25:18
Nit: s/after the manager is disconnected/when the
davidyu
2014/12/01 17:05:22
Done.
| |
| 41 class DeviceCloudPolicyUnmanagedBrowserTest | 37 connector->GetDeviceCloudPolicyManager()->Disconnect(); |
| 42 : public DevicePolicyCrosBrowserTest { | |
| 43 protected: | |
| 44 DeviceCloudPolicyUnmanagedBrowserTest() {} | |
| 45 | |
| 46 virtual void SetUpInProcessBrowserTestFixture() override { | |
| 47 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); | |
| 48 } | |
| 49 | |
| 50 private: | |
| 51 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyUnmanagedBrowserTest); | |
| 52 }; | |
| 53 | |
| 54 IN_PROC_BROWSER_TEST_F(DeviceCloudPolicyUnmanagedBrowserTest, | |
| 55 StillHasInitializer) { | |
| 56 BrowserPolicyConnectorChromeOS* connector = | |
| 57 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
| 58 EXPECT_TRUE(connector->GetDeviceCloudPolicyInitializer()); | 38 EXPECT_TRUE(connector->GetDeviceCloudPolicyInitializer()); |
| 59 } | 39 } |
| 60 | 40 |
| 61 } // namespace | |
| 62 } // namespace policy | 41 } // namespace policy |
| OLD | NEW |