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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 TEST_F(ProfileSyncServiceTest, DisableSyncFlag) { | 652 TEST_F(ProfileSyncServiceTest, DisableSyncFlag) { |
653 base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync); | 653 base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync); |
654 EXPECT_FALSE(ProfileSyncService::IsSyncEnabled()); | 654 EXPECT_FALSE(ProfileSyncService::IsSyncEnabled()); |
655 } | 655 } |
656 | 656 |
657 // Verify that no disable sync flag enables sync. | 657 // Verify that no disable sync flag enables sync. |
658 TEST_F(ProfileSyncServiceTest, NoDisableSyncFlag) { | 658 TEST_F(ProfileSyncServiceTest, NoDisableSyncFlag) { |
659 EXPECT_TRUE(ProfileSyncService::IsSyncEnabled()); | 659 EXPECT_TRUE(ProfileSyncService::IsSyncEnabled()); |
660 } | 660 } |
661 | 661 |
| 662 // Test Sync will stop after receive memory pressure |
| 663 TEST_F(ProfileSyncServiceTest, MemoryPressureRecording) { |
| 664 CreateService(browser_sync::AUTO_START); |
| 665 IssueTestTokens(); |
| 666 ExpectDataTypeManagerCreation(1); |
| 667 ExpectSyncBackendHostCreation(1); |
| 668 InitializeForNthSync(); |
| 669 |
| 670 EXPECT_TRUE(service()->SyncActive()); |
| 671 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 672 sync_driver::prefs::kSyncSuppressStart)); |
| 673 |
| 674 testing::Mock::VerifyAndClearExpectations(components_factory()); |
| 675 |
| 676 sync_driver::SyncPrefs sync_prefs(service()->profile()->GetPrefs()); |
| 677 |
| 678 EXPECT_EQ(profile()->GetPrefs()->GetInteger( |
| 679 sync_driver::prefs::kSyncMemoryPressureWarningCount), |
| 680 0); |
| 681 EXPECT_FALSE(sync_prefs.DidSyncShutdownCleanly()); |
| 682 |
| 683 // Simulate memory pressure notification. |
| 684 base::MemoryPressureListener::NotifyMemoryPressure( |
| 685 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); |
| 686 base::RunLoop().RunUntilIdle(); |
| 687 |
| 688 // Verify memory pressure recorded. |
| 689 EXPECT_EQ(profile()->GetPrefs()->GetInteger( |
| 690 sync_driver::prefs::kSyncMemoryPressureWarningCount), |
| 691 1); |
| 692 EXPECT_FALSE(sync_prefs.DidSyncShutdownCleanly()); |
| 693 |
| 694 // Simulate memory pressure notification. |
| 695 base::MemoryPressureListener::NotifyMemoryPressure( |
| 696 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); |
| 697 base::RunLoop().RunUntilIdle(); |
| 698 ShutdownAndDeleteService(); |
| 699 |
| 700 // Verify memory pressure and shutdown recorded. |
| 701 EXPECT_EQ(profile()->GetPrefs()->GetInteger( |
| 702 sync_driver::prefs::kSyncMemoryPressureWarningCount), |
| 703 2); |
| 704 EXPECT_TRUE(sync_prefs.DidSyncShutdownCleanly()); |
| 705 } |
| 706 |
662 } // namespace | 707 } // namespace |
663 } // namespace browser_sync | 708 } // namespace browser_sync |
OLD | NEW |