| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/synchronization/waitable_event.h" | 5 #include "base/synchronization/waitable_event.h" |
| 6 #include "base/test/test_timeouts.h" | 6 #include "base/test/test_timeouts.h" |
| 7 #include "chrome/browser/sync/engine/mock_model_safe_workers.h" | 7 #include "chrome/browser/sync/engine/mock_model_safe_workers.h" |
| 8 #include "chrome/browser/sync/engine/syncer.h" | 8 #include "chrome/browser/sync/engine/syncer.h" |
| 9 #include "chrome/browser/sync/engine/syncer_thread2.h" | 9 #include "chrome/browser/sync/engine/syncer_thread2.h" |
| 10 #include "chrome/browser/sync/sessions/test_util.h" | 10 #include "chrome/browser/sync/sessions/test_util.h" |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 // TODO(tim): Implement this test and then the functionality! | 736 // TODO(tim): Implement this test and then the functionality! |
| 737 TEST_F(SyncerThread2Test, DISABLED_NoConfigDuringNormal) { | 737 TEST_F(SyncerThread2Test, DISABLED_NoConfigDuringNormal) { |
| 738 } | 738 } |
| 739 | 739 |
| 740 // Test that starting the syncer thread without a valid connection doesn't | 740 // Test that starting the syncer thread without a valid connection doesn't |
| 741 // break things when a connection is detected. | 741 // break things when a connection is detected. |
| 742 TEST_F(SyncerThread2Test, StartWhenNotConnected) { | 742 TEST_F(SyncerThread2Test, StartWhenNotConnected) { |
| 743 base::WaitableEvent done(false, false); | 743 base::WaitableEvent done(false, false); |
| 744 MessageLoop cur; | 744 MessageLoop cur; |
| 745 connection()->SetServerNotReachable(); | 745 connection()->SetServerNotReachable(); |
| 746 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).WillOnce(SignalEvent(&done)); |
| 746 syncer_thread()->Start(SyncerThread::NORMAL_MODE, NULL); | 747 syncer_thread()->Start(SyncerThread::NORMAL_MODE, NULL); |
| 747 syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), | 748 syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), |
| 748 FROM_HERE); | 749 FROM_HERE); |
| 749 FlushLastTask(&done); | 750 FlushLastTask(&done); |
| 750 | 751 |
| 751 connection()->SetServerReachable(); | 752 connection()->SetServerReachable(); |
| 752 cur.PostTask(FROM_HERE, NewRunnableFunction( | 753 cur.PostTask(FROM_HERE, NewRunnableFunction( |
| 753 &SyncerThread2Test::QuitMessageLoop)); | 754 &SyncerThread2Test::QuitMessageLoop)); |
| 754 cur.Run(); | 755 cur.Run(); |
| 755 | 756 |
| 756 // By now, the server connection event should have been posted to the | 757 // By now, the server connection event should have been posted to the |
| 757 // SyncerThread. | 758 // SyncerThread. |
| 758 FlushLastTask(&done); | 759 FlushLastTask(&done); |
| 759 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).WillOnce(SignalEvent(&done)); | |
| 760 syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), | |
| 761 FROM_HERE); | |
| 762 done.TimedWait(timeout()); | 760 done.TimedWait(timeout()); |
| 763 } | 761 } |
| 764 | 762 |
| 765 TEST_F(SyncerThread2Test, SetsPreviousRoutingInfo) { | 763 TEST_F(SyncerThread2Test, SetsPreviousRoutingInfo) { |
| 766 base::WaitableEvent done(false, false); | 764 base::WaitableEvent done(false, false); |
| 767 ModelSafeRoutingInfo info; | 765 ModelSafeRoutingInfo info; |
| 768 EXPECT_TRUE(info == context()->previous_session_routing_info()); | 766 EXPECT_TRUE(info == context()->previous_session_routing_info()); |
| 769 ModelSafeRoutingInfo expected; | 767 ModelSafeRoutingInfo expected; |
| 770 context()->registrar()->GetModelSafeRoutingInfo(&expected); | 768 context()->registrar()->GetModelSafeRoutingInfo(&expected); |
| 771 ASSERT_FALSE(expected.empty()); | 769 ASSERT_FALSE(expected.empty()); |
| 772 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(1); | 770 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(1); |
| 773 | 771 |
| 774 syncer_thread()->Start(SyncerThread::NORMAL_MODE, NULL); | 772 syncer_thread()->Start(SyncerThread::NORMAL_MODE, NULL); |
| 775 syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), | 773 syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), |
| 776 FROM_HERE); | 774 FROM_HERE); |
| 777 FlushLastTask(&done); | 775 FlushLastTask(&done); |
| 778 syncer_thread()->Stop(); | 776 syncer_thread()->Stop(); |
| 779 | 777 |
| 780 EXPECT_TRUE(expected == context()->previous_session_routing_info()); | 778 EXPECT_TRUE(expected == context()->previous_session_routing_info()); |
| 781 } | 779 } |
| 782 | 780 |
| 783 } // namespace s3 | 781 } // namespace s3 |
| 784 } // namespace browser_sync | 782 } // namespace browser_sync |
| 785 | 783 |
| 786 // SyncerThread won't outlive the test! | 784 // SyncerThread won't outlive the test! |
| 787 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser_sync::s3::SyncerThread2Test); | 785 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser_sync::s3::SyncerThread2Test); |
| OLD | NEW |