| 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 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/thread_task_runner_handle.h" |
| 12 #include "jingle/notifier/base/const_communicator.h" | 13 #include "jingle/notifier/base/const_communicator.h" |
| 13 #include "jingle/notifier/base/fake_base_task.h" | 14 #include "jingle/notifier/base/fake_base_task.h" |
| 14 #include "jingle/notifier/communicator/login_settings.h" | 15 #include "jingle/notifier/communicator/login_settings.h" |
| 15 #include "net/dns/mock_host_resolver.h" | 16 #include "net/dns/mock_host_resolver.h" |
| 16 #include "net/url_request/url_request_test_util.h" | 17 #include "net/url_request/url_request_test_util.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 19 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| 19 #include "webrtc/libjingle/xmpp/constants.h" | 20 #include "webrtc/libjingle/xmpp/constants.h" |
| 20 #include "webrtc/libjingle/xmpp/xmppengine.h" | 21 #include "webrtc/libjingle/xmpp/xmppengine.h" |
| 21 | 22 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 76 } |
| 76 ~MyTestURLRequestContext() override {} | 77 ~MyTestURLRequestContext() override {} |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 class SingleLoginAttemptTest : public ::testing::Test { | 80 class SingleLoginAttemptTest : public ::testing::Test { |
| 80 protected: | 81 protected: |
| 81 SingleLoginAttemptTest() | 82 SingleLoginAttemptTest() |
| 82 : login_settings_( | 83 : login_settings_( |
| 83 buzz::XmppClientSettings(), | 84 buzz::XmppClientSettings(), |
| 84 new net::TestURLRequestContextGetter( | 85 new net::TestURLRequestContextGetter( |
| 85 base::MessageLoopProxy::current(), | 86 base::ThreadTaskRunnerHandle::Get(), |
| 86 scoped_ptr<net::TestURLRequestContext>( | 87 scoped_ptr<net::TestURLRequestContext>( |
| 87 new MyTestURLRequestContext())), | 88 new MyTestURLRequestContext())), |
| 88 ServerList( | 89 ServerList( |
| 89 1, | 90 1, |
| 90 ServerInformation( | 91 ServerInformation( |
| 91 net::HostPortPair("example.com", 100), SUPPORTS_SSLTCP)), | 92 net::HostPortPair("example.com", 100), 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 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 // Fire 'Unauthorized' errors and make sure the delegate gets the | 245 // Fire 'Unauthorized' errors and make sure the delegate gets the |
| 245 // OnCredentialsRejected() event. | 246 // OnCredentialsRejected() event. |
| 246 TEST_F(SingleLoginAttemptTest, CredentialsRejected) { | 247 TEST_F(SingleLoginAttemptTest, CredentialsRejected) { |
| 247 attempt_->OnError(buzz::XmppEngine::ERROR_UNAUTHORIZED, 0, NULL); | 248 attempt_->OnError(buzz::XmppEngine::ERROR_UNAUTHORIZED, 0, NULL); |
| 248 EXPECT_EQ(CREDENTIALS_REJECTED, fake_delegate_.state()); | 249 EXPECT_EQ(CREDENTIALS_REJECTED, fake_delegate_.state()); |
| 249 } | 250 } |
| 250 | 251 |
| 251 } // namespace | 252 } // namespace |
| 252 | 253 |
| 253 } // namespace notifier | 254 } // namespace notifier |
| OLD | NEW |