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

Side by Side Diff: components/sync/engine_impl/js_mutation_event_observer_unittest.cc

Issue 2798963003: Use ScopedTaskEnvironment instead of MessageLoop in components unit tests. (Closed)
Patch Set: Created 3 years, 8 months 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
OLDNEW
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_mutation_event_observer.h" 5 #include "components/sync/engine_impl/js_mutation_event_observer.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/base/model_type.h" 10 #include "components/sync/base/model_type.h"
10 #include "components/sync/js/js_event_details.h" 11 #include "components/sync/js/js_event_details.h"
11 #include "components/sync/js/js_test_util.h" 12 #include "components/sync/js/js_test_util.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::InSequence; 18 using ::testing::InSequence;
18 using ::testing::StrictMock; 19 using ::testing::StrictMock;
19 20
20 class JsMutationEventObserverTest : public testing::Test { 21 class JsMutationEventObserverTest : public testing::Test {
21 protected: 22 protected:
22 JsMutationEventObserverTest() { 23 JsMutationEventObserverTest() {
23 js_mutation_event_observer_.SetJsEventHandler( 24 js_mutation_event_observer_.SetJsEventHandler(
24 mock_js_event_handler_.AsWeakHandle()); 25 mock_js_event_handler_.AsWeakHandle());
25 } 26 }
26 27
27 private: 28 private:
28 // This must be destroyed after the member variables below in order 29 // This must be destroyed after the member variables below in order
29 // for WeakHandles to be destroyed properly. 30 // for WeakHandles to be destroyed properly.
30 base::MessageLoop message_loop_; 31 base::test::ScopedTaskEnvironment scoped_task_environment_;
31 32
32 protected: 33 protected:
33 StrictMock<MockJsEventHandler> mock_js_event_handler_; 34 StrictMock<MockJsEventHandler> mock_js_event_handler_;
34 JsMutationEventObserver js_mutation_event_observer_; 35 JsMutationEventObserver js_mutation_event_observer_;
35 36
36 void PumpLoop() { base::RunLoop().RunUntilIdle(); } 37 void PumpLoop() { base::RunLoop().RunUntilIdle(); }
37 }; 38 };
38 39
39 TEST_F(JsMutationEventObserverTest, OnChangesApplied) { 40 TEST_F(JsMutationEventObserverTest, OnChangesApplied) {
40 InSequence dummy; 41 InSequence dummy;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 102 }
102 103
103 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { 104 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
104 js_mutation_event_observer_.OnChangesComplete(ModelTypeFromInt(i)); 105 js_mutation_event_observer_.OnChangesComplete(ModelTypeFromInt(i));
105 } 106 }
106 PumpLoop(); 107 PumpLoop();
107 } 108 }
108 109
109 } // namespace 110 } // namespace
110 } // namespace syncer 111 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698