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 "chrome/browser/sync/js_sync_manager_observer.h" | 5 #include "chrome/browser/sync/js_sync_manager_observer.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 using ::testing::InSequence; | 26 using ::testing::InSequence; |
27 using ::testing::StrictMock; | 27 using ::testing::StrictMock; |
28 | 28 |
29 class JsSyncManagerObserverTest : public testing::Test { | 29 class JsSyncManagerObserverTest : public testing::Test { |
30 protected: | 30 protected: |
31 JsSyncManagerObserverTest() { | 31 JsSyncManagerObserverTest() { |
32 js_sync_manager_observer_.SetJsEventHandler( | 32 js_sync_manager_observer_.SetJsEventHandler( |
33 mock_js_event_handler_.AsWeakHandle()); | 33 mock_js_event_handler_.AsWeakHandle()); |
34 } | 34 } |
35 | 35 |
| 36 private: |
| 37 // This must be destroyed after the member variables below in order |
| 38 // for WeakHandles to be destroyed properly. |
| 39 MessageLoop message_loop_; |
| 40 |
| 41 protected: |
36 StrictMock<MockJsEventHandler> mock_js_event_handler_; | 42 StrictMock<MockJsEventHandler> mock_js_event_handler_; |
37 JsSyncManagerObserver js_sync_manager_observer_; | 43 JsSyncManagerObserver js_sync_manager_observer_; |
38 | 44 |
39 void PumpLoop() { | 45 void PumpLoop() { |
40 message_loop_.RunAllPending(); | 46 message_loop_.RunAllPending(); |
41 } | 47 } |
42 | |
43 private: | |
44 MessageLoop message_loop_; | |
45 }; | 48 }; |
46 | 49 |
47 TEST_F(JsSyncManagerObserverTest, NoArgNotifiations) { | 50 TEST_F(JsSyncManagerObserverTest, NoArgNotifiations) { |
48 InSequence dummy; | 51 InSequence dummy; |
49 | 52 |
50 EXPECT_CALL(mock_js_event_handler_, | 53 EXPECT_CALL(mock_js_event_handler_, |
51 HandleJsEvent("onInitializationComplete", | 54 HandleJsEvent("onInitializationComplete", |
52 HasDetails(JsEventDetails()))); | 55 HasDetails(JsEventDetails()))); |
53 EXPECT_CALL(mock_js_event_handler_, | 56 EXPECT_CALL(mock_js_event_handler_, |
54 HandleJsEvent("onStopSyncingPermanently", | 57 HandleJsEvent("onStopSyncingPermanently", |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 &trans, &changes[i], | 325 &trans, &changes[i], |
323 syncable::MODEL_TYPE_COUNT - i); | 326 syncable::MODEL_TYPE_COUNT - i); |
324 } | 327 } |
325 | 328 |
326 test_user_share.TearDown(); | 329 test_user_share.TearDown(); |
327 PumpLoop(); | 330 PumpLoop(); |
328 } | 331 } |
329 | 332 |
330 } // namespace | 333 } // namespace |
331 } // namespace browser_sync | 334 } // namespace browser_sync |
OLD | NEW |