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" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/time/time.h" |
15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/invalidation/fake_invalidation_service.h" | 18 #include "chrome/browser/invalidation/fake_invalidation_service.h" |
18 #include "chrome/browser/invalidation/invalidation_service_factory.h" | 19 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
19 #include "chrome/browser/policy/profile_policy_connector.h" | 20 #include "chrome/browser/policy/profile_policy_connector.h" |
20 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 21 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
21 #include "chrome/browser/policy/test/local_policy_test_server.h" | 22 #include "chrome/browser/policy/test/local_policy_test_server.h" |
22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 // Perform the initial fetch. | 306 // Perform the initial fetch. |
306 ASSERT_NO_FATAL_FAILURE(SetServerPolicy(GetTestPolicy("google.com", 0))); | 307 ASSERT_NO_FATAL_FAILURE(SetServerPolicy(GetTestPolicy("google.com", 0))); |
307 { | 308 { |
308 base::RunLoop run_loop; | 309 base::RunLoop run_loop; |
309 policy_service->RefreshPolicies(run_loop.QuitClosure()); | 310 policy_service->RefreshPolicies(run_loop.QuitClosure()); |
310 run_loop.Run(); | 311 run_loop.Run(); |
311 } | 312 } |
312 | 313 |
313 // Update the homepage in the policy and trigger an invalidation. | 314 // Update the homepage in the policy and trigger an invalidation. |
314 ASSERT_NO_FATAL_FAILURE(SetServerPolicy(GetTestPolicy("youtube.com", 0))); | 315 ASSERT_NO_FATAL_FAILURE(SetServerPolicy(GetTestPolicy("youtube.com", 0))); |
| 316 base::TimeDelta now = |
| 317 base::Time::NowFromSystemTime() - base::Time::UnixEpoch(); |
315 GetInvalidationService()->EmitInvalidationForTest( | 318 GetInvalidationService()->EmitInvalidationForTest( |
316 syncer::Invalidation::Init( | 319 syncer::Invalidation::Init( |
317 invalidation::ObjectId(16, "test_policy"), | 320 invalidation::ObjectId(16, "test_policy"), |
318 1 /* version */, | 321 now.InMicroseconds() /* version */, |
319 "payload")); | 322 "payload")); |
320 { | 323 { |
321 base::RunLoop run_loop; | 324 base::RunLoop run_loop; |
322 on_policy_updated_ = run_loop.QuitClosure(); | 325 on_policy_updated_ = run_loop.QuitClosure(); |
323 run_loop.Run(); | 326 run_loop.Run(); |
324 } | 327 } |
325 | 328 |
326 // Check that the updated policy was fetched. | 329 // Check that the updated policy was fetched. |
327 PolicyMap expected; | 330 PolicyMap expected; |
328 GetExpectedTestPolicy(&expected, "youtube.com"); | 331 GetExpectedTestPolicy(&expected, "youtube.com"); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 | 428 |
426 // They should now serialize to the same bytes. | 429 // They should now serialize to the same bytes. |
427 std::string chrome_settings_serialized; | 430 std::string chrome_settings_serialized; |
428 std::string cloud_policy_serialized; | 431 std::string cloud_policy_serialized; |
429 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); | 432 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); |
430 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); | 433 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); |
431 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); | 434 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); |
432 } | 435 } |
433 | 436 |
434 } // namespace policy | 437 } // namespace policy |
OLD | NEW |