Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(734)

Side by Side Diff: chrome/browser/sync/engine/syncer_thread_unittest.cc

Issue 5047002: Sync: Fix RequestResume in SyncerThread, and re-enable the various unit tests... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/engine/syncer_thread.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <list> 5 #include <list>
6 #include <map> 6 #include <map>
7 7
8 #include "base/lock.h" 8 #include "base/lock.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 // immediately (5ms). 690 // immediately (5ms).
691 syncer_thread()->NudgeSyncer(5, SyncerThread::kUnknown); 691 syncer_thread()->NudgeSyncer(5, SyncerThread::kUnknown);
692 interceptor.WaitForSyncShare(1, TimeDelta::FromSeconds(1)); 692 interceptor.WaitForSyncShare(1, TimeDelta::FromSeconds(1));
693 EXPECT_EQ(static_cast<unsigned int>(2), 693 EXPECT_EQ(static_cast<unsigned int>(2),
694 interceptor.times_sync_occured().size()); 694 interceptor.times_sync_occured().size());
695 695
696 // SyncerThread should be waiting again. Signal it to stop. 696 // SyncerThread should be waiting again. Signal it to stop.
697 EXPECT_TRUE(syncer_thread()->Stop(2000)); 697 EXPECT_TRUE(syncer_thread()->Stop(2000));
698 } 698 }
699 699
700 700 TEST_F(SyncerThreadWithSyncerTest, NudgeWithDataTypes) {
701
702 // Disabled (Bug 62880).
703 // TODO(zea): Fix RequestPause/RequestResume and get this working.
704 TEST_F(SyncerThreadWithSyncerTest, DISABLED_NudgeWithDataTypes) {
705 SyncShareIntercept interceptor; 701 SyncShareIntercept interceptor;
706 connection()->SetMidCommitObserver(&interceptor); 702 connection()->SetMidCommitObserver(&interceptor);
707 // We don't want a poll to happen during this test (except the first one). 703 // We don't want a poll to happen during this test (except the first one).
708 PreventThreadFromPolling(); 704 PreventThreadFromPolling();
709 EXPECT_TRUE(syncer_thread()->Start()); 705 EXPECT_TRUE(syncer_thread()->Start());
710 metadb()->Open(); 706 metadb()->Open();
711 syncer_thread()->CreateSyncer(metadb()->name()); 707 syncer_thread()->CreateSyncer(metadb()->name());
712 const TimeDelta poll_interval = TimeDelta::FromMinutes(5); 708 const TimeDelta poll_interval = TimeDelta::FromMinutes(5);
713 interceptor.WaitForSyncShare(1, poll_interval + poll_interval); 709 interceptor.WaitForSyncShare(1, poll_interval + poll_interval);
714
715 EXPECT_EQ(static_cast<unsigned int>(1), 710 EXPECT_EQ(static_cast<unsigned int>(1),
716 interceptor.times_sync_occured().size()); 711 interceptor.times_sync_occured().size());
712
717 // The SyncerThread should be waiting for the poll now. Nudge it to sync 713 // The SyncerThread should be waiting for the poll now. Nudge it to sync
718 // immediately (5ms). 714 // immediately (5ms).
719 syncable::ModelTypeBitSet model_types; 715 syncable::ModelTypeBitSet model_types;
720 model_types[syncable::BOOKMARKS] = true; 716 model_types[syncable::BOOKMARKS] = true;
717
718 // Paused so we can verify the nudge types safely.
719 syncer_thread()->RequestPause();
721 syncer_thread()->NudgeSyncerWithDataTypes(5, 720 syncer_thread()->NudgeSyncerWithDataTypes(5,
722 SyncerThread::kUnknown, 721 SyncerThread::kUnknown,
723 model_types); 722 model_types);
724 EXPECT_EQ(model_types, syncer_thread()->vault_.pending_nudge_types_); 723 EXPECT_EQ(model_types, syncer_thread()->vault_.pending_nudge_types_);
724 syncer_thread()->RequestResume();
725
725 interceptor.WaitForSyncShare(1, TimeDelta::FromSeconds(1)); 726 interceptor.WaitForSyncShare(1, TimeDelta::FromSeconds(1));
726 EXPECT_EQ(static_cast<unsigned int>(2), 727 EXPECT_EQ(static_cast<unsigned int>(2),
727 interceptor.times_sync_occured().size()); 728 interceptor.times_sync_occured().size());
728 729
729 // SyncerThread should be waiting again. Signal it to stop. 730 // SyncerThread should be waiting again. Signal it to stop.
730 EXPECT_TRUE(syncer_thread()->Stop(2000)); 731 EXPECT_TRUE(syncer_thread()->Stop(2000));
731 EXPECT_TRUE(syncer_thread()->vault_.pending_nudge_types_.none()); 732 EXPECT_TRUE(syncer_thread()->vault_.pending_nudge_types_.none());
732 } 733 }
733 734
734 TEST_F(SyncerThreadWithSyncerTest, Throttling) { 735 TEST_F(SyncerThreadWithSyncerTest, Throttling) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 HttpResponse::SERVER_CONNECTION_OK, 840 HttpResponse::SERVER_CONNECTION_OK,
840 true}; 841 true};
841 connection()->channel()->NotifyListeners(e); 842 connection()->channel()->NotifyListeners(e);
842 843
843 interceptor.WaitForSyncShare(1, TimeDelta::FromSeconds(10)); 844 interceptor.WaitForSyncShare(1, TimeDelta::FromSeconds(10));
844 EXPECT_FALSE(interceptor.times_sync_occured().empty()); 845 EXPECT_FALSE(interceptor.times_sync_occured().empty());
845 846
846 EXPECT_TRUE(syncer_thread()->Stop(2000)); 847 EXPECT_TRUE(syncer_thread()->Stop(2000));
847 } 848 }
848 849
849 // TODO(skrul): The "Pause" and "PauseWhenNotConnected" tests are 850 TEST_F(SyncerThreadWithSyncerTest, Pause) {
850 // marked DISABLED because they sometimes fail on the Windows buildbots.
851 // I have been unable to reproduce this hang after extensive testing
852 // on a local Windows machine.
853 TEST_F(SyncerThreadWithSyncerTest, DISABLED_Pause) {
854 WaitableEvent sync_cycle_ended_event(false, false); 851 WaitableEvent sync_cycle_ended_event(false, false);
855 WaitableEvent paused_event(false, false); 852 WaitableEvent paused_event(false, false);
856 WaitableEvent resumed_event(false, false); 853 WaitableEvent resumed_event(false, false);
857 PreventThreadFromPolling(); 854 PreventThreadFromPolling();
858 855
859 ListenerMock listener; 856 ListenerMock listener;
860 TestScopedSessionEventListener reg(context_, &listener); 857 TestScopedSessionEventListener reg(context_, &listener);
861 EXPECT_CALL(listener, OnSyncEngineEvent( 858 EXPECT_CALL(listener, OnSyncEngineEvent(
862 Field(&SyncEngineEvent::what_happened, 859 Field(&SyncEngineEvent::what_happened,
863 SyncEngineEvent::STATUS_CHANGED))). 860 SyncEngineEvent::STATUS_CHANGED))).
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 EXPECT_CALL(listener, OnSyncEngineEvent( 945 EXPECT_CALL(listener, OnSyncEngineEvent(
949 Field(&SyncEngineEvent::what_happened, 946 Field(&SyncEngineEvent::what_happened,
950 SyncEngineEvent::SYNC_CYCLE_ENDED))). 947 SyncEngineEvent::SYNC_CYCLE_ENDED))).
951 WillOnce(SignalEvent(&sync_cycle_ended_event)); 948 WillOnce(SignalEvent(&sync_cycle_ended_event));
952 syncer_thread()->NudgeSyncer(0, SyncerThread::kUnknown); 949 syncer_thread()->NudgeSyncer(0, SyncerThread::kUnknown);
953 ASSERT_TRUE(sync_cycle_ended_event.TimedWait(max_wait_time_)); 950 ASSERT_TRUE(sync_cycle_ended_event.TimedWait(max_wait_time_));
954 951
955 EXPECT_TRUE(syncer_thread()->Stop(2000)); 952 EXPECT_TRUE(syncer_thread()->Stop(2000));
956 } 953 }
957 954
958 // TODO(skrul): See TODO comment on the "Pause" test above for an 955 TEST_F(SyncerThreadWithSyncerTest, PauseWhenNotConnected) {
959 // explanation of the usage of DISABLED here.
960 // TODO(pinkerton): disabled due to hanging on test bots http://crbug.com/39070
961 TEST_F(SyncerThreadWithSyncerTest, DISABLED_PauseWhenNotConnected) {
962 WaitableEvent sync_cycle_ended_event(false, false); 956 WaitableEvent sync_cycle_ended_event(false, false);
963 WaitableEvent event(false, false); 957 WaitableEvent event(false, false);
964 ListenerMock listener; 958 ListenerMock listener;
965 TestScopedSessionEventListener reg(context_, &listener); 959 TestScopedSessionEventListener reg(context_, &listener);
966 PreventThreadFromPolling(); 960 PreventThreadFromPolling();
967 961
968 EXPECT_CALL(listener, OnSyncEngineEvent( 962 EXPECT_CALL(listener, OnSyncEngineEvent(
969 Field(&SyncEngineEvent::what_happened, 963 Field(&SyncEngineEvent::what_happened,
970 SyncEngineEvent::STATUS_CHANGED))). 964 SyncEngineEvent::STATUS_CHANGED))).
971 Times(AnyNumber()); 965 Times(AnyNumber());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 EXPECT_CALL(listener, OnSyncEngineEvent( 1065 EXPECT_CALL(listener, OnSyncEngineEvent(
1072 Field(&SyncEngineEvent::what_happened, 1066 Field(&SyncEngineEvent::what_happened,
1073 SyncEngineEvent::SYNCER_THREAD_EXITING))); 1067 SyncEngineEvent::SYNCER_THREAD_EXITING)));
1074 1068
1075 ASSERT_TRUE(Resume(&listener)); 1069 ASSERT_TRUE(Resume(&listener));
1076 ASSERT_TRUE(sync_cycle_ended_event.TimedWait(max_wait_time_)); 1070 ASSERT_TRUE(sync_cycle_ended_event.TimedWait(max_wait_time_));
1077 EXPECT_TRUE(syncer_thread()->Stop(2000)); 1071 EXPECT_TRUE(syncer_thread()->Stop(2000));
1078 } 1072 }
1079 1073
1080 } // namespace browser_sync 1074 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer_thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698