| 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" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 const ServerInformation& redirect_server() const { | 63 const ServerInformation& redirect_server() const { |
| 64 return redirect_server_; | 64 return redirect_server_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 DelegateState state_; | 68 DelegateState state_; |
| 69 base::WeakPtr<buzz::XmppTaskParentInterface> base_task_; | 69 base::WeakPtr<buzz::XmppTaskParentInterface> base_task_; |
| 70 ServerInformation redirect_server_; | 70 ServerInformation redirect_server_; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 class MyTestURLRequestContext : public net::TestURLRequestContext { | 73 class MyTestURLRequestContext : public TestURLRequestContext { |
| 74 public: | 74 public: |
| 75 MyTestURLRequestContext() : TestURLRequestContext(true) { | 75 MyTestURLRequestContext() : TestURLRequestContext(true) { |
| 76 context_storage_.set_host_resolver( | 76 context_storage_.set_host_resolver( |
| 77 scoped_ptr<net::HostResolver>(new net::HangingHostResolver())); | 77 scoped_ptr<net::HostResolver>(new net::HangingHostResolver())); |
| 78 Init(); | 78 Init(); |
| 79 } | 79 } |
| 80 virtual ~MyTestURLRequestContext() {} | 80 virtual ~MyTestURLRequestContext() {} |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 class SingleLoginAttemptTest : public ::testing::Test { | 83 class SingleLoginAttemptTest : public ::testing::Test { |
| 84 protected: | 84 protected: |
| 85 SingleLoginAttemptTest() | 85 SingleLoginAttemptTest() |
| 86 : login_settings_( | 86 : login_settings_( |
| 87 buzz::XmppClientSettings(), | 87 buzz::XmppClientSettings(), |
| 88 new net::TestURLRequestContextGetter( | 88 new TestURLRequestContextGetter( |
| 89 base::MessageLoopProxy::current(), | 89 base::MessageLoopProxy::current(), |
| 90 scoped_ptr<net::TestURLRequestContext>( | 90 scoped_ptr<TestURLRequestContext>(new MyTestURLRequestContext())), |
| 91 new MyTestURLRequestContext())), | |
| 92 ServerList( | 91 ServerList( |
| 93 1, | 92 1, |
| 94 ServerInformation( | 93 ServerInformation( |
| 95 net::HostPortPair("example.com", 100), SUPPORTS_SSLTCP)), | 94 net::HostPortPair("example.com", 100), SUPPORTS_SSLTCP)), |
| 96 false /* try_ssltcp_first */, | 95 false /* try_ssltcp_first */, |
| 97 "auth_mechanism"), | 96 "auth_mechanism"), |
| 98 attempt_(login_settings_, &fake_delegate_) {} | 97 attempt_(login_settings_, &fake_delegate_) {} |
| 99 | 98 |
| 100 virtual void TearDown() OVERRIDE { | 99 virtual void TearDown() OVERRIDE { |
| 101 message_loop_.RunAllPending(); | 100 message_loop_.RunAllPending(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 // Fire 'Unauthorized' errors and make sure the delegate gets the | 244 // Fire 'Unauthorized' errors and make sure the delegate gets the |
| 246 // OnCredentialsRejected() event. | 245 // OnCredentialsRejected() event. |
| 247 TEST_F(SingleLoginAttemptTest, CredentialsRejected) { | 246 TEST_F(SingleLoginAttemptTest, CredentialsRejected) { |
| 248 attempt_.OnError(buzz::XmppEngine::ERROR_UNAUTHORIZED, 0, NULL); | 247 attempt_.OnError(buzz::XmppEngine::ERROR_UNAUTHORIZED, 0, NULL); |
| 249 EXPECT_EQ(CREDENTIALS_REJECTED, fake_delegate_.state()); | 248 EXPECT_EQ(CREDENTIALS_REJECTED, fake_delegate_.state()); |
| 250 } | 249 } |
| 251 | 250 |
| 252 } // namespace | 251 } // namespace |
| 253 | 252 |
| 254 } // namespace notifier | 253 } // namespace notifier |
| OLD | NEW |