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

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
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 710
715 EXPECT_EQ(static_cast<unsigned int>(1), 711 EXPECT_EQ(static_cast<unsigned int>(1),
716 interceptor.times_sync_occured().size()); 712 interceptor.times_sync_occured().size());
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 syncer_thread()->RequestPause();
721 syncer_thread()->NudgeSyncerWithDataTypes(5, 718 syncer_thread()->NudgeSyncerWithDataTypes(5,
722 SyncerThread::kUnknown, 719 SyncerThread::kUnknown,
723 model_types); 720 model_types);
724 EXPECT_EQ(model_types, syncer_thread()->vault_.pending_nudge_types_); 721 EXPECT_EQ(model_types, syncer_thread()->vault_.pending_nudge_types_);
722 syncer_thread()->RequestResume();
725 interceptor.WaitForSyncShare(1, TimeDelta::FromSeconds(1)); 723 interceptor.WaitForSyncShare(1, TimeDelta::FromSeconds(1));
726 EXPECT_EQ(static_cast<unsigned int>(2), 724 EXPECT_EQ(static_cast<unsigned int>(2),
727 interceptor.times_sync_occured().size()); 725 interceptor.times_sync_occured().size());
728 726
729 // SyncerThread should be waiting again. Signal it to stop. 727 // SyncerThread should be waiting again. Signal it to stop.
730 EXPECT_TRUE(syncer_thread()->Stop(2000)); 728 EXPECT_TRUE(syncer_thread()->Stop(2000));
731 EXPECT_TRUE(syncer_thread()->vault_.pending_nudge_types_.none()); 729 EXPECT_TRUE(syncer_thread()->vault_.pending_nudge_types_.none());
732 } 730 }
733 731
734 TEST_F(SyncerThreadWithSyncerTest, Throttling) { 732 TEST_F(SyncerThreadWithSyncerTest, Throttling) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 HttpResponse::SERVER_CONNECTION_OK, 837 HttpResponse::SERVER_CONNECTION_OK,
840 true}; 838 true};
841 connection()->channel()->NotifyListeners(e); 839 connection()->channel()->NotifyListeners(e);
842 840
843 interceptor.WaitForSyncShare(1, TimeDelta::FromSeconds(10)); 841 interceptor.WaitForSyncShare(1, TimeDelta::FromSeconds(10));
844 EXPECT_FALSE(interceptor.times_sync_occured().empty()); 842 EXPECT_FALSE(interceptor.times_sync_occured().empty());
845 843
846 EXPECT_TRUE(syncer_thread()->Stop(2000)); 844 EXPECT_TRUE(syncer_thread()->Stop(2000));
847 } 845 }
848 846
849 // TODO(skrul): The "Pause" and "PauseWhenNotConnected" tests are 847 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); 848 WaitableEvent sync_cycle_ended_event(false, false);
855 WaitableEvent paused_event(false, false); 849 WaitableEvent paused_event(false, false);
856 WaitableEvent resumed_event(false, false); 850 WaitableEvent resumed_event(false, false);
857 PreventThreadFromPolling(); 851 PreventThreadFromPolling();
858 852
859 ListenerMock listener; 853 ListenerMock listener;
860 TestScopedSessionEventListener reg(context_, &listener); 854 TestScopedSessionEventListener reg(context_, &listener);
861 EXPECT_CALL(listener, OnSyncEngineEvent( 855 EXPECT_CALL(listener, OnSyncEngineEvent(
862 Field(&SyncEngineEvent::what_happened, 856 Field(&SyncEngineEvent::what_happened,
863 SyncEngineEvent::STATUS_CHANGED))). 857 SyncEngineEvent::STATUS_CHANGED))).
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 EXPECT_CALL(listener, OnSyncEngineEvent( 942 EXPECT_CALL(listener, OnSyncEngineEvent(
949 Field(&SyncEngineEvent::what_happened, 943 Field(&SyncEngineEvent::what_happened,
950 SyncEngineEvent::SYNC_CYCLE_ENDED))). 944 SyncEngineEvent::SYNC_CYCLE_ENDED))).
951 WillOnce(SignalEvent(&sync_cycle_ended_event)); 945 WillOnce(SignalEvent(&sync_cycle_ended_event));
952 syncer_thread()->NudgeSyncer(0, SyncerThread::kUnknown); 946 syncer_thread()->NudgeSyncer(0, SyncerThread::kUnknown);
953 ASSERT_TRUE(sync_cycle_ended_event.TimedWait(max_wait_time_)); 947 ASSERT_TRUE(sync_cycle_ended_event.TimedWait(max_wait_time_));
954 948
955 EXPECT_TRUE(syncer_thread()->Stop(2000)); 949 EXPECT_TRUE(syncer_thread()->Stop(2000));
956 } 950 }
957 951
958 // TODO(skrul): See TODO comment on the "Pause" test above for an 952 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); 953 WaitableEvent sync_cycle_ended_event(false, false);
963 WaitableEvent event(false, false); 954 WaitableEvent event(false, false);
964 ListenerMock listener; 955 ListenerMock listener;
965 TestScopedSessionEventListener reg(context_, &listener); 956 TestScopedSessionEventListener reg(context_, &listener);
966 PreventThreadFromPolling(); 957 PreventThreadFromPolling();
967 958
968 EXPECT_CALL(listener, OnSyncEngineEvent( 959 EXPECT_CALL(listener, OnSyncEngineEvent(
969 Field(&SyncEngineEvent::what_happened, 960 Field(&SyncEngineEvent::what_happened,
970 SyncEngineEvent::STATUS_CHANGED))). 961 SyncEngineEvent::STATUS_CHANGED))).
971 Times(AnyNumber()); 962 Times(AnyNumber());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 EXPECT_CALL(listener, OnSyncEngineEvent( 1062 EXPECT_CALL(listener, OnSyncEngineEvent(
1072 Field(&SyncEngineEvent::what_happened, 1063 Field(&SyncEngineEvent::what_happened,
1073 SyncEngineEvent::SYNCER_THREAD_EXITING))); 1064 SyncEngineEvent::SYNCER_THREAD_EXITING)));
1074 1065
1075 ASSERT_TRUE(Resume(&listener)); 1066 ASSERT_TRUE(Resume(&listener));
1076 ASSERT_TRUE(sync_cycle_ended_event.TimedWait(max_wait_time_)); 1067 ASSERT_TRUE(sync_cycle_ended_event.TimedWait(max_wait_time_));
1077 EXPECT_TRUE(syncer_thread()->Stop(2000)); 1068 EXPECT_TRUE(syncer_thread()->Stop(2000));
1078 } 1069 }
1079 1070
1080 } // namespace browser_sync 1071 } // namespace browser_sync
OLDNEW
« chrome/browser/sync/engine/syncer_thread.cc ('K') | « 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