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 "components/sync/engine_impl/js_sync_manager_observer.h" | 5 #include "components/sync/engine_impl/js_sync_manager_observer.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/test/scoped_task_environment.h" |
11 #include "base/values.h" | 12 #include "base/values.h" |
12 #include "components/sync/base/model_type.h" | 13 #include "components/sync/base/model_type.h" |
13 #include "components/sync/engine/connection_status.h" | 14 #include "components/sync/engine/connection_status.h" |
14 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" | 15 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" |
15 #include "components/sync/engine/sync_string_conversions.h" | 16 #include "components/sync/engine/sync_string_conversions.h" |
16 #include "components/sync/js/js_event_details.h" | 17 #include "components/sync/js/js_event_details.h" |
17 #include "components/sync/js/js_test_util.h" | 18 #include "components/sync/js/js_test_util.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 | 20 |
20 namespace syncer { | 21 namespace syncer { |
21 namespace { | 22 namespace { |
22 | 23 |
23 using ::testing::InSequence; | 24 using ::testing::InSequence; |
24 using ::testing::StrictMock; | 25 using ::testing::StrictMock; |
25 | 26 |
26 class JsSyncManagerObserverTest : public testing::Test { | 27 class JsSyncManagerObserverTest : public testing::Test { |
27 protected: | 28 protected: |
28 JsSyncManagerObserverTest() { | 29 JsSyncManagerObserverTest() { |
29 js_sync_manager_observer_.SetJsEventHandler( | 30 js_sync_manager_observer_.SetJsEventHandler( |
30 mock_js_event_handler_.AsWeakHandle()); | 31 mock_js_event_handler_.AsWeakHandle()); |
31 } | 32 } |
32 | 33 |
33 private: | 34 private: |
34 // This must be destroyed after the member variables below in order | 35 // This must be destroyed after the member variables below in order |
35 // for WeakHandles to be destroyed properly. | 36 // for WeakHandles to be destroyed properly. |
36 base::MessageLoop message_loop_; | 37 base::test::ScopedTaskEnvironment scoped_task_environment_; |
37 | 38 |
38 protected: | 39 protected: |
39 StrictMock<MockJsEventHandler> mock_js_event_handler_; | 40 StrictMock<MockJsEventHandler> mock_js_event_handler_; |
40 JsSyncManagerObserver js_sync_manager_observer_; | 41 JsSyncManagerObserver js_sync_manager_observer_; |
41 | 42 |
42 void PumpLoop() { base::RunLoop().RunUntilIdle(); } | 43 void PumpLoop() { base::RunLoop().RunUntilIdle(); } |
43 }; | 44 }; |
44 | 45 |
45 TEST_F(JsSyncManagerObserverTest, OnInitializationComplete) { | 46 TEST_F(JsSyncManagerObserverTest, OnInitializationComplete) { |
46 base::DictionaryValue expected_details; | 47 base::DictionaryValue expected_details; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 EXPECT_CALL(mock_js_event_handler_, | 101 EXPECT_CALL(mock_js_event_handler_, |
101 HandleJsEvent("onConnectionStatusChange", | 102 HandleJsEvent("onConnectionStatusChange", |
102 HasDetailsAsDictionary(expected_details))); | 103 HasDetailsAsDictionary(expected_details))); |
103 | 104 |
104 js_sync_manager_observer_.OnConnectionStatusChange(kStatus); | 105 js_sync_manager_observer_.OnConnectionStatusChange(kStatus); |
105 PumpLoop(); | 106 PumpLoop(); |
106 } | 107 } |
107 | 108 |
108 } // namespace | 109 } // namespace |
109 } // namespace syncer | 110 } // namespace syncer |
OLD | NEW |