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 "jingle/notifier/listener/xmpp_push_client.h" | 5 #include "jingle/notifier/listener/xmpp_push_client.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" |
11 #include "jingle/notifier/base/fake_base_task.h" | 12 #include "jingle/notifier/base/fake_base_task.h" |
12 #include "jingle/notifier/base/notifier_options.h" | 13 #include "jingle/notifier/base/notifier_options.h" |
13 #include "jingle/notifier/listener/push_client_observer.h" | 14 #include "jingle/notifier/listener/push_client_observer.h" |
14 #include "net/url_request/url_request_test_util.h" | 15 #include "net/url_request/url_request_test_util.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 namespace notifier { | 19 namespace notifier { |
19 | 20 |
20 namespace { | 21 namespace { |
(...skipping 20 matching lines...) Expand all Loading... |
41 | 42 |
42 ~XmppPushClientTest() override {} | 43 ~XmppPushClientTest() override {} |
43 | 44 |
44 void SetUp() override { | 45 void SetUp() override { |
45 xmpp_push_client_.reset(new XmppPushClient(notifier_options_)); | 46 xmpp_push_client_.reset(new XmppPushClient(notifier_options_)); |
46 xmpp_push_client_->AddObserver(&mock_observer_); | 47 xmpp_push_client_->AddObserver(&mock_observer_); |
47 } | 48 } |
48 | 49 |
49 void TearDown() override { | 50 void TearDown() override { |
50 // Clear out any messages posted by XmppPushClient. | 51 // Clear out any messages posted by XmppPushClient. |
51 message_loop_.RunUntilIdle(); | 52 base::RunLoop().RunUntilIdle(); |
52 xmpp_push_client_->RemoveObserver(&mock_observer_); | 53 xmpp_push_client_->RemoveObserver(&mock_observer_); |
53 xmpp_push_client_.reset(); | 54 xmpp_push_client_.reset(); |
54 } | 55 } |
55 | 56 |
56 // The sockets created by the XMPP code expect an IO loop. | 57 // The sockets created by the XMPP code expect an IO loop. |
57 base::MessageLoopForIO message_loop_; | 58 base::MessageLoopForIO message_loop_; |
58 NotifierOptions notifier_options_; | 59 NotifierOptions notifier_options_; |
59 StrictMock<MockObserver> mock_observer_; | 60 StrictMock<MockObserver> mock_observer_; |
60 std::unique_ptr<XmppPushClient> xmpp_push_client_; | 61 std::unique_ptr<XmppPushClient> xmpp_push_client_; |
61 FakeBaseTask fake_base_task_; | 62 FakeBaseTask fake_base_task_; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 137 |
137 EXPECT_CALL(mock_observer_, OnNotificationsEnabled()); | 138 EXPECT_CALL(mock_observer_, OnNotificationsEnabled()); |
138 | 139 |
139 xmpp_push_client_->OnConnect(fake_base_task_.AsWeakPtr()); | 140 xmpp_push_client_->OnConnect(fake_base_task_.AsWeakPtr()); |
140 xmpp_push_client_->OnSubscribed(); | 141 xmpp_push_client_->OnSubscribed(); |
141 } | 142 } |
142 | 143 |
143 } // namespace | 144 } // namespace |
144 | 145 |
145 } // namespace notifier | 146 } // namespace notifier |
OLD | NEW |