| 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/base64url.h" | 7 #include "base/base64url.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 // And start with a signed-in user. | 132 // And start with a signed-in user. |
| 133 SignInAndRegister(); | 133 SignInAndRegister(); |
| 134 | 134 |
| 135 // The extension will receive an update event. | 135 // The extension will receive an update event. |
| 136 EXPECT_TRUE(event_listener_->WaitUntilSatisfied()); | 136 EXPECT_TRUE(event_listener_->WaitUntilSatisfied()); |
| 137 | 137 |
| 138 ExtensionBrowserTest::SetUpOnMainThread(); | 138 ExtensionBrowserTest::SetUpOnMainThread(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void TearDownOnMainThread() override { | |
| 142 event_listener_.reset(); | |
| 143 ExtensionBrowserTest::TearDownOnMainThread(); | |
| 144 } | |
| 145 | |
| 146 scoped_refptr<const extensions::Extension> LoadExtension( | 141 scoped_refptr<const extensions::Extension> LoadExtension( |
| 147 const base::FilePath::CharType* path) { | 142 const base::FilePath::CharType* path) { |
| 148 base::FilePath full_path; | 143 base::FilePath full_path; |
| 149 if (!PathService::Get(chrome::DIR_TEST_DATA, &full_path)) { | 144 if (!PathService::Get(chrome::DIR_TEST_DATA, &full_path)) { |
| 150 ADD_FAILURE(); | 145 ADD_FAILURE(); |
| 151 return NULL; | 146 return NULL; |
| 152 } | 147 } |
| 153 scoped_refptr<const extensions::Extension> extension( | 148 scoped_refptr<const extensions::Extension> extension( |
| 154 ExtensionBrowserTest::LoadExtension(full_path.Append(path))); | 149 ExtensionBrowserTest::LoadExtension(full_path.Append(path))); |
| 155 if (!extension.get()) { | 150 if (!extension.get()) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 ExtensionTestMessageListener policy_listener1("{}", true); | 249 ExtensionTestMessageListener policy_listener1("{}", true); |
| 255 event_listener_->Reply("get-policy-Name"); | 250 event_listener_->Reply("get-policy-Name"); |
| 256 EXPECT_TRUE(policy_listener1.WaitUntilSatisfied()); | 251 EXPECT_TRUE(policy_listener1.WaitUntilSatisfied()); |
| 257 | 252 |
| 258 ExtensionTestMessageListener policy_listener2(kTestPolicy2JSON, false); | 253 ExtensionTestMessageListener policy_listener2(kTestPolicy2JSON, false); |
| 259 policy_listener1.Reply("get-policy-Another"); | 254 policy_listener1.Reply("get-policy-Another"); |
| 260 EXPECT_TRUE(policy_listener2.WaitUntilSatisfied()); | 255 EXPECT_TRUE(policy_listener2.WaitUntilSatisfied()); |
| 261 } | 256 } |
| 262 | 257 |
| 263 IN_PROC_BROWSER_TEST_F(ComponentCloudPolicyTest, InstallNewExtension) { | 258 IN_PROC_BROWSER_TEST_F(ComponentCloudPolicyTest, InstallNewExtension) { |
| 264 event_listener_->Reply(std::string()); | |
| 265 event_listener_.reset(); | |
| 266 | |
| 267 EXPECT_TRUE(test_server_.UpdatePolicyData( | 259 EXPECT_TRUE(test_server_.UpdatePolicyData( |
| 268 dm_protocol::kChromeExtensionPolicyType, kTestExtension2, kTestPolicy2)); | 260 dm_protocol::kChromeExtensionPolicyType, kTestExtension2, kTestPolicy2)); |
| 269 // Installing a new extension doesn't trigger another policy fetch because | 261 // Installing a new extension doesn't trigger another policy fetch because |
| 270 // the server always sends down the list of all extensions that have policy. | 262 // the server always sends down the list of all extensions that have policy. |
| 271 // Fetch now that the configuration has been updated and before installing | 263 // Fetch now that the configuration has been updated and before installing |
| 272 // the extension. | 264 // the extension. |
| 273 RefreshPolicies(); | 265 RefreshPolicies(); |
| 274 | 266 |
| 275 ExtensionTestMessageListener result_listener("ok", false); | 267 ExtensionTestMessageListener result_listener("ok", false); |
| 276 result_listener.set_failure_message("fail"); | 268 result_listener.set_failure_message("fail"); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 ExtensionTestMessageListener signin_policy_listener(kTestPolicyJSON, false); | 331 ExtensionTestMessageListener signin_policy_listener(kTestPolicyJSON, false); |
| 340 event_listener2.Reply("get-policy-Name"); | 332 event_listener2.Reply("get-policy-Name"); |
| 341 EXPECT_TRUE(signin_policy_listener.WaitUntilSatisfied()); | 333 EXPECT_TRUE(signin_policy_listener.WaitUntilSatisfied()); |
| 342 | 334 |
| 343 // And the cache is back. | 335 // And the cache is back. |
| 344 EXPECT_TRUE(base::PathExists(cache_path)); | 336 EXPECT_TRUE(base::PathExists(cache_path)); |
| 345 } | 337 } |
| 346 #endif | 338 #endif |
| 347 | 339 |
| 348 } // namespace policy | 340 } // namespace policy |
| OLD | NEW |