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/communicator/single_login_attempt.h" | 5 #include "jingle/notifier/communicator/single_login_attempt.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
13 #include "jingle/notifier/base/const_communicator.h" | 14 #include "jingle/notifier/base/const_communicator.h" |
14 #include "jingle/notifier/base/fake_base_task.h" | 15 #include "jingle/notifier/base/fake_base_task.h" |
15 #include "jingle/notifier/communicator/login_settings.h" | 16 #include "jingle/notifier/communicator/login_settings.h" |
16 #include "net/dns/mock_host_resolver.h" | 17 #include "net/dns/mock_host_resolver.h" |
17 #include "net/url_request/url_request_test_util.h" | 18 #include "net/url_request/url_request_test_util.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 20 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
20 #include "webrtc/libjingle/xmpp/constants.h" | 21 #include "webrtc/libjingle/xmpp/constants.h" |
21 #include "webrtc/libjingle/xmpp/xmppengine.h" | 22 #include "webrtc/libjingle/xmpp/xmppengine.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 base::ThreadTaskRunnerHandle::Get(), | 87 base::ThreadTaskRunnerHandle::Get(), |
87 std::unique_ptr<net::TestURLRequestContext>( | 88 std::unique_ptr<net::TestURLRequestContext>( |
88 new MyTestURLRequestContext())), | 89 new MyTestURLRequestContext())), |
89 ServerList(1, | 90 ServerList(1, |
90 ServerInformation(net::HostPortPair("example.com", 100), | 91 ServerInformation(net::HostPortPair("example.com", 100), |
91 SUPPORTS_SSLTCP)), | 92 SUPPORTS_SSLTCP)), |
92 false /* try_ssltcp_first */, | 93 false /* try_ssltcp_first */, |
93 "auth_mechanism"), | 94 "auth_mechanism"), |
94 attempt_(new SingleLoginAttempt(login_settings_, &fake_delegate_)) {} | 95 attempt_(new SingleLoginAttempt(login_settings_, &fake_delegate_)) {} |
95 | 96 |
96 void TearDown() override { message_loop_.RunUntilIdle(); } | 97 void TearDown() override { base::RunLoop().RunUntilIdle(); } |
97 | 98 |
98 void FireRedirect(buzz::XmlElement* redirect_error) { | 99 void FireRedirect(buzz::XmlElement* redirect_error) { |
99 attempt_->OnError(buzz::XmppEngine::ERROR_STREAM, 0, redirect_error); | 100 attempt_->OnError(buzz::XmppEngine::ERROR_STREAM, 0, redirect_error); |
100 } | 101 } |
101 | 102 |
102 ~SingleLoginAttemptTest() override { | 103 ~SingleLoginAttemptTest() override { |
103 attempt_.reset(); | 104 attempt_.reset(); |
104 message_loop_.RunUntilIdle(); | 105 base::RunLoop().RunUntilIdle(); |
105 } | 106 } |
106 | 107 |
107 private: | 108 private: |
108 base::MessageLoop message_loop_; | 109 base::MessageLoop message_loop_; |
109 const LoginSettings login_settings_; | 110 const LoginSettings login_settings_; |
110 | 111 |
111 protected: | 112 protected: |
112 std::unique_ptr<SingleLoginAttempt> attempt_; | 113 std::unique_ptr<SingleLoginAttempt> attempt_; |
113 FakeDelegate fake_delegate_; | 114 FakeDelegate fake_delegate_; |
114 FakeBaseTask fake_base_task_; | 115 FakeBaseTask fake_base_task_; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // Fire 'Unauthorized' errors and make sure the delegate gets the | 248 // Fire 'Unauthorized' errors and make sure the delegate gets the |
248 // OnCredentialsRejected() event. | 249 // OnCredentialsRejected() event. |
249 TEST_F(SingleLoginAttemptTest, CredentialsRejected) { | 250 TEST_F(SingleLoginAttemptTest, CredentialsRejected) { |
250 attempt_->OnError(buzz::XmppEngine::ERROR_UNAUTHORIZED, 0, NULL); | 251 attempt_->OnError(buzz::XmppEngine::ERROR_UNAUTHORIZED, 0, NULL); |
251 EXPECT_EQ(CREDENTIALS_REJECTED, fake_delegate_.state()); | 252 EXPECT_EQ(CREDENTIALS_REJECTED, fake_delegate_.state()); |
252 } | 253 } |
253 | 254 |
254 } // namespace | 255 } // namespace |
255 | 256 |
256 } // namespace notifier | 257 } // namespace notifier |
OLD | NEW |