| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } | 114 } |
| 115 | 115 |
| 116 virtual void SetUpOnMainThread() OVERRIDE { | 116 virtual void SetUpOnMainThread() OVERRIDE { |
| 117 ASSERT_TRUE(PolicyServiceIsEmpty(g_browser_process->policy_service())) | 117 ASSERT_TRUE(PolicyServiceIsEmpty(g_browser_process->policy_service())) |
| 118 << "Pre-existing policies in this machine will make this test fail."; | 118 << "Pre-existing policies in this machine will make this test fail."; |
| 119 | 119 |
| 120 // Install the initial extension. | 120 // Install the initial extension. |
| 121 ExtensionTestMessageListener ready_listener("ready", true); | 121 ExtensionTestMessageListener ready_listener("ready", true); |
| 122 event_listener_.reset(new ExtensionTestMessageListener("event", true)); | 122 event_listener_.reset(new ExtensionTestMessageListener("event", true)); |
| 123 extension_ = LoadExtension(kTestExtensionPath); | 123 extension_ = LoadExtension(kTestExtensionPath); |
| 124 ASSERT_TRUE(extension_); | 124 ASSERT_TRUE(extension_.get()); |
| 125 ASSERT_EQ(kTestExtension, extension_->id()); | 125 ASSERT_EQ(kTestExtension, extension_->id()); |
| 126 EXPECT_TRUE(ready_listener.WaitUntilSatisfied()); | 126 EXPECT_TRUE(ready_listener.WaitUntilSatisfied()); |
| 127 | 127 |
| 128 BrowserPolicyConnector* connector = | 128 BrowserPolicyConnector* connector = |
| 129 g_browser_process->browser_policy_connector(); | 129 g_browser_process->browser_policy_connector(); |
| 130 connector->ScheduleServiceInitialization(0); | 130 connector->ScheduleServiceInitialization(0); |
| 131 | 131 |
| 132 #if defined(OS_CHROMEOS) | 132 #if defined(OS_CHROMEOS) |
| 133 UserCloudPolicyManagerChromeOS* policy_manager = | 133 UserCloudPolicyManagerChromeOS* policy_manager = |
| 134 UserCloudPolicyManagerFactoryChromeOS::GetForProfile( | 134 UserCloudPolicyManagerFactoryChromeOS::GetForProfile( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 scoped_refptr<const extensions::Extension> LoadExtension( | 171 scoped_refptr<const extensions::Extension> LoadExtension( |
| 172 const base::FilePath::CharType* path) { | 172 const base::FilePath::CharType* path) { |
| 173 base::FilePath full_path; | 173 base::FilePath full_path; |
| 174 if (!PathService::Get(chrome::DIR_TEST_DATA, &full_path)) { | 174 if (!PathService::Get(chrome::DIR_TEST_DATA, &full_path)) { |
| 175 ADD_FAILURE(); | 175 ADD_FAILURE(); |
| 176 return NULL; | 176 return NULL; |
| 177 } | 177 } |
| 178 scoped_refptr<const extensions::Extension> extension( | 178 scoped_refptr<const extensions::Extension> extension( |
| 179 ExtensionBrowserTest::LoadExtension(full_path.Append(path))); | 179 ExtensionBrowserTest::LoadExtension(full_path.Append(path))); |
| 180 if (!extension) { | 180 if (!extension.get()) { |
| 181 ADD_FAILURE(); | 181 ADD_FAILURE(); |
| 182 return NULL; | 182 return NULL; |
| 183 } | 183 } |
| 184 return extension; | 184 return extension; |
| 185 } | 185 } |
| 186 | 186 |
| 187 void RefreshPolicies() { | 187 void RefreshPolicies() { |
| 188 ProfilePolicyConnector* profile_connector = | 188 ProfilePolicyConnector* profile_connector = |
| 189 ProfilePolicyConnectorFactory::GetForProfile(browser()->profile()); | 189 ProfilePolicyConnectorFactory::GetForProfile(browser()->profile()); |
| 190 PolicyService* policy_service = profile_connector->policy_service(); | 190 PolicyService* policy_service = profile_connector->policy_service(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 ASSERT_EQ(kTestExtension2, extension2->id()); | 247 ASSERT_EQ(kTestExtension2, extension2->id()); |
| 248 | 248 |
| 249 // This extension only sends the 'policy' signal once it receives the policy, | 249 // This extension only sends the 'policy' signal once it receives the policy, |
| 250 // and after verifying it has the expected value. Otherwise it sends 'fail'. | 250 // and after verifying it has the expected value. Otherwise it sends 'fail'. |
| 251 EXPECT_TRUE(result_listener.WaitUntilSatisfied()); | 251 EXPECT_TRUE(result_listener.WaitUntilSatisfied()); |
| 252 } | 252 } |
| 253 | 253 |
| 254 #endif // OS_CHROMEOS | 254 #endif // OS_CHROMEOS |
| 255 | 255 |
| 256 } // namespace policy | 256 } // namespace policy |
| OLD | NEW |