OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/callback.h" | 5 #include "base/callback.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
33 #include "chrome/test/base/in_process_browser_test.h" | 33 #include "chrome/test/base/in_process_browser_test.h" |
34 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
35 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
36 #include "content/public/browser/notification_source.h" | 36 #include "content/public/browser/notification_source.h" |
37 #include "content/public/test/test_utils.h" | 37 #include "content/public/test/test_utils.h" |
38 #include "net/url_request/url_request_context_getter.h" | 38 #include "net/url_request/url_request_context_getter.h" |
39 #include "policy/policy_constants.h" | 39 #include "policy/policy_constants.h" |
40 #include "policy/proto/chrome_settings.pb.h" | 40 #include "policy/proto/chrome_settings.pb.h" |
41 #include "policy/proto/cloud_policy.pb.h" | 41 #include "policy/proto/cloud_policy.pb.h" |
| 42 #include "sync/internal_api/public/base/invalidation.h" |
42 #include "testing/gmock/include/gmock/gmock.h" | 43 #include "testing/gmock/include/gmock/gmock.h" |
43 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
44 #include "url/gurl.h" | 45 #include "url/gurl.h" |
45 | 46 |
46 #if defined(OS_CHROMEOS) | 47 #if defined(OS_CHROMEOS) |
47 #include "chrome/browser/chromeos/login/user_manager.h" | 48 #include "chrome/browser/chromeos/login/user_manager.h" |
48 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 49 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
49 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 50 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
50 #include "chromeos/chromeos_paths.h" | 51 #include "chromeos/chromeos_paths.h" |
51 #include "chromeos/dbus/cryptohome_client.h" | 52 #include "chromeos/dbus/cryptohome_client.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 ASSERT_NO_FATAL_FAILURE(SetServerPolicy(GetTestPolicy("google.com", 0))); | 303 ASSERT_NO_FATAL_FAILURE(SetServerPolicy(GetTestPolicy("google.com", 0))); |
303 { | 304 { |
304 base::RunLoop run_loop; | 305 base::RunLoop run_loop; |
305 policy_service->RefreshPolicies(run_loop.QuitClosure()); | 306 policy_service->RefreshPolicies(run_loop.QuitClosure()); |
306 run_loop.Run(); | 307 run_loop.Run(); |
307 } | 308 } |
308 | 309 |
309 // Update the homepage in the policy and trigger an invalidation. | 310 // Update the homepage in the policy and trigger an invalidation. |
310 ASSERT_NO_FATAL_FAILURE(SetServerPolicy(GetTestPolicy("youtube.com", 0))); | 311 ASSERT_NO_FATAL_FAILURE(SetServerPolicy(GetTestPolicy("youtube.com", 0))); |
311 GetInvalidationService()->EmitInvalidationForTest( | 312 GetInvalidationService()->EmitInvalidationForTest( |
312 invalidation::ObjectId(16, "test_policy"), | 313 syncer::Invalidation::Init( |
313 1 /* version */, | 314 invalidation::ObjectId(16, "test_policy"), |
314 "payload"); | 315 1 /* version */, |
| 316 "payload")); |
315 { | 317 { |
316 base::RunLoop run_loop; | 318 base::RunLoop run_loop; |
317 on_policy_updated_ = run_loop.QuitClosure(); | 319 on_policy_updated_ = run_loop.QuitClosure(); |
318 run_loop.Run(); | 320 run_loop.Run(); |
319 } | 321 } |
320 | 322 |
321 // Check that the updated policy was fetched. | 323 // Check that the updated policy was fetched. |
322 PolicyMap expected; | 324 PolicyMap expected; |
323 GetExpectedTestPolicy(&expected, "youtube.com"); | 325 GetExpectedTestPolicy(&expected, "youtube.com"); |
324 EXPECT_TRUE(expected.Equals(policy_service->GetPolicies( | 326 EXPECT_TRUE(expected.Equals(policy_service->GetPolicies( |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 422 |
421 // They should now serialize to the same bytes. | 423 // They should now serialize to the same bytes. |
422 std::string chrome_settings_serialized; | 424 std::string chrome_settings_serialized; |
423 std::string cloud_policy_serialized; | 425 std::string cloud_policy_serialized; |
424 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); | 426 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); |
425 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); | 427 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); |
426 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); | 428 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); |
427 } | 429 } |
428 | 430 |
429 } // namespace policy | 431 } // namespace policy |
OLD | NEW |