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. 4 5#include "base/compiler_specific.h" 6#include "base/logging.h" 7#include "base/macros.h" 8#include "base/message_loop/message_loop.h" 9#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 10#include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" 11#include "chrome/test/base/testing_browser_process.h" 12#include "testing/gtest/include/gtest/gtest.h" 13 14namespace policy { 15namespace { 16 17// A test fixture simulating a browser that is already managed. 18class DeviceCloudPolicyManagedBrowserTest : public DevicePolicyCrosBrowserTest { 19 protected: 20 DeviceCloudPolicyManagedBrowserTest() {} 21 22 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 23 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); 24 InstallOwnerKey(); 25 MarkAsEnterpriseOwned(); 26 RefreshDevicePolicy(); 27 } 28 29 private: 30 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagedBrowserTest); 31}; 32 33IN_PROC_BROWSER_TEST_F(DeviceCloudPolicyManagedBrowserTest, NoInitializer) { 34 BrowserPolicyConnectorChromeOS* connector = 35 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 36 EXPECT_FALSE(connector->GetDeviceCloudPolicyInitializer()); 37} 38 39// A test fixture simulating a browser that is still unmanaged. 40class DeviceCloudPolicyUnmanagedBrowserTest 41 : public DevicePolicyCrosBrowserTest { 42 protected: 43 DeviceCloudPolicyUnmanagedBrowserTest() {} 44 45 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 46 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); 47 } 48 49 private: 50 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyUnmanagedBrowserTest); 51}; 52 53IN_PROC_BROWSER_TEST_F(DeviceCloudPolicyUnmanagedBrowserTest, 54 StillHasInitializer) { 55 BrowserPolicyConnectorChromeOS* connector = 56 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 57 EXPECT_TRUE(connector->GetDeviceCloudPolicyInitializer()); 58} 59 60} // namespace 61} // namespace policy 62