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/js/sync_js_controller.h" | 5 #include "components/sync/js/sync_js_controller.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/test/scoped_task_environment.h" |
8 #include "base/values.h" | 9 #include "base/values.h" |
9 #include "components/sync/js/js_event_details.h" | 10 #include "components/sync/js/js_event_details.h" |
10 #include "components/sync/js/js_test_util.h" | 11 #include "components/sync/js/js_test_util.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace syncer { | 15 namespace syncer { |
15 namespace { | 16 namespace { |
16 | 17 |
17 using ::testing::_; | 18 using ::testing::_; |
18 using ::testing::InSequence; | 19 using ::testing::InSequence; |
19 using ::testing::Mock; | 20 using ::testing::Mock; |
20 using ::testing::StrictMock; | 21 using ::testing::StrictMock; |
21 | 22 |
22 class SyncJsControllerTest : public testing::Test { | 23 class SyncJsControllerTest : public testing::Test { |
23 protected: | 24 protected: |
24 void PumpLoop() { base::RunLoop().RunUntilIdle(); } | 25 void PumpLoop() { base::RunLoop().RunUntilIdle(); } |
25 | 26 |
26 private: | 27 private: |
27 base::MessageLoop message_loop_; | 28 base::test::ScopedTaskEnvironment scoped_task_environment_; |
28 }; | 29 }; |
29 | 30 |
30 TEST_F(SyncJsControllerTest, Events) { | 31 TEST_F(SyncJsControllerTest, Events) { |
31 InSequence dummy; | 32 InSequence dummy; |
32 SyncJsController sync_js_controller; | 33 SyncJsController sync_js_controller; |
33 | 34 |
34 base::DictionaryValue details_dict1, details_dict2; | 35 base::DictionaryValue details_dict1, details_dict2; |
35 details_dict1.SetString("foo", "bar"); | 36 details_dict1.SetString("foo", "bar"); |
36 details_dict2.SetInteger("baz", 5); | 37 details_dict2.SetInteger("baz", 5); |
37 JsEventDetails details1(&details_dict1), details2(&details_dict2); | 38 JsEventDetails details1(&details_dict1), details2(&details_dict2); |
(...skipping 12 matching lines...) Expand all Loading... |
50 sync_js_controller.HandleJsEvent("anotherevent", details2); | 51 sync_js_controller.HandleJsEvent("anotherevent", details2); |
51 sync_js_controller.RemoveJsEventHandler(&event_handler1); | 52 sync_js_controller.RemoveJsEventHandler(&event_handler1); |
52 sync_js_controller.RemoveJsEventHandler(&event_handler2); | 53 sync_js_controller.RemoveJsEventHandler(&event_handler2); |
53 sync_js_controller.HandleJsEvent("droppedevent", details2); | 54 sync_js_controller.HandleJsEvent("droppedevent", details2); |
54 | 55 |
55 PumpLoop(); | 56 PumpLoop(); |
56 } | 57 } |
57 | 58 |
58 } // namespace | 59 } // namespace |
59 } // namespace syncer | 60 } // namespace syncer |
OLD | NEW |