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

Side by Side Diff: components/invalidation/impl/invalidation_notifier_unittest.cc

Issue 2082333002: Remove calls to deprecated MessageLoop methods in components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/invalidation/impl/invalidation_notifier.h" 5 #include "components/invalidation/impl/invalidation_notifier.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/run_loop.h"
10 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
11 #include "components/invalidation/impl/fake_invalidation_handler.h" 12 #include "components/invalidation/impl/fake_invalidation_handler.h"
12 #include "components/invalidation/impl/fake_invalidation_state_tracker.h" 13 #include "components/invalidation/impl/fake_invalidation_state_tracker.h"
13 #include "components/invalidation/impl/invalidation_state_tracker.h" 14 #include "components/invalidation/impl/invalidation_state_tracker.h"
14 #include "components/invalidation/impl/invalidator_test_template.h" 15 #include "components/invalidation/impl/invalidator_test_template.h"
15 #include "components/invalidation/impl/push_client_channel.h" 16 #include "components/invalidation/impl/push_client_channel.h"
16 #include "jingle/notifier/base/fake_base_task.h" 17 #include "jingle/notifier/base/fake_base_task.h"
17 #include "jingle/notifier/base/notifier_options.h" 18 #include "jingle/notifier/base/notifier_options.h"
18 #include "jingle/notifier/listener/fake_push_client.h" 19 #include "jingle/notifier/listener/fake_push_client.h"
19 #include "net/url_request/url_request_test_util.h" 20 #include "net/url_request/url_request_test_util.h"
(...skipping 30 matching lines...) Expand all
50 Invalidator* GetInvalidator() { 51 Invalidator* GetInvalidator() {
51 return invalidator_.get(); 52 return invalidator_.get();
52 } 53 }
53 54
54 void DestroyInvalidator() { 55 void DestroyInvalidator() {
55 // Stopping the invalidation notifier stops its scheduler, which deletes 56 // Stopping the invalidation notifier stops its scheduler, which deletes
56 // any pending tasks without running them. Some tasks "run and delete" 57 // any pending tasks without running them. Some tasks "run and delete"
57 // another task, so they must be run in order to avoid leaking the inner 58 // another task, so they must be run in order to avoid leaking the inner
58 // task. Stopping does not schedule any tasks, so it's both necessary and 59 // task. Stopping does not schedule any tasks, so it's both necessary and
59 // sufficient to drain the task queue before stopping the notifier. 60 // sufficient to drain the task queue before stopping the notifier.
60 message_loop_.RunUntilIdle(); 61 base::RunLoop().RunUntilIdle();
61 invalidator_.reset(); 62 invalidator_.reset();
62 } 63 }
63 64
64 void WaitForInvalidator() { 65 void WaitForInvalidator() { base::RunLoop().RunUntilIdle(); }
65 message_loop_.RunUntilIdle();
66 }
67 66
68 void TriggerOnInvalidatorStateChange(InvalidatorState state) { 67 void TriggerOnInvalidatorStateChange(InvalidatorState state) {
69 invalidator_->OnInvalidatorStateChange(state); 68 invalidator_->OnInvalidatorStateChange(state);
70 } 69 }
71 70
72 void TriggerOnIncomingInvalidation( 71 void TriggerOnIncomingInvalidation(
73 const ObjectIdInvalidationMap& invalidation_map) { 72 const ObjectIdInvalidationMap& invalidation_map) {
74 invalidator_->OnInvalidate(invalidation_map); 73 invalidator_->OnInvalidate(invalidation_map);
75 } 74 }
76 75
77 private: 76 private:
78 base::MessageLoop message_loop_; 77 base::MessageLoop message_loop_;
79 std::unique_ptr<InvalidationNotifier> invalidator_; 78 std::unique_ptr<InvalidationNotifier> invalidator_;
80 }; 79 };
81 80
82 INSTANTIATE_TYPED_TEST_CASE_P( 81 INSTANTIATE_TYPED_TEST_CASE_P(
83 InvalidationNotifierTest, InvalidatorTest, 82 InvalidationNotifierTest, InvalidatorTest,
84 InvalidationNotifierTestDelegate); 83 InvalidationNotifierTestDelegate);
85 84
86 } // namespace 85 } // namespace
87 86
88 } // namespace syncer 87 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698