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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 enum DelegateState { | 30 enum DelegateState { |
31 IDLE, CONNECTED, REDIRECTED, CREDENTIALS_REJECTED, SETTINGS_EXHAUSTED | 31 IDLE, CONNECTED, REDIRECTED, CREDENTIALS_REJECTED, SETTINGS_EXHAUSTED |
32 }; | 32 }; |
33 | 33 |
34 class FakeDelegate : public SingleLoginAttempt::Delegate { | 34 class FakeDelegate : public SingleLoginAttempt::Delegate { |
35 public: | 35 public: |
36 FakeDelegate() : state_(IDLE) {} | 36 FakeDelegate() : state_(IDLE) {} |
37 | 37 |
38 virtual void OnConnect( | 38 virtual void OnConnect( |
39 base::WeakPtr<buzz::XmppTaskParentInterface> base_task) OVERRIDE { | 39 base::WeakPtr<buzz::XmppTaskParentInterface> base_task) override { |
40 state_ = CONNECTED; | 40 state_ = CONNECTED; |
41 base_task_ = base_task; | 41 base_task_ = base_task; |
42 } | 42 } |
43 | 43 |
44 virtual void OnRedirect(const ServerInformation& redirect_server) OVERRIDE { | 44 virtual void OnRedirect(const ServerInformation& redirect_server) override { |
45 state_ = REDIRECTED; | 45 state_ = REDIRECTED; |
46 redirect_server_ = redirect_server; | 46 redirect_server_ = redirect_server; |
47 } | 47 } |
48 | 48 |
49 virtual void OnCredentialsRejected() OVERRIDE { | 49 virtual void OnCredentialsRejected() override { |
50 state_ = CREDENTIALS_REJECTED; | 50 state_ = CREDENTIALS_REJECTED; |
51 } | 51 } |
52 | 52 |
53 virtual void OnSettingsExhausted() OVERRIDE { | 53 virtual void OnSettingsExhausted() override { |
54 state_ = SETTINGS_EXHAUSTED; | 54 state_ = SETTINGS_EXHAUSTED; |
55 } | 55 } |
56 | 56 |
57 DelegateState state() const { return state_; } | 57 DelegateState state() const { return state_; } |
58 | 58 |
59 base::WeakPtr<buzz::XmppTaskParentInterface> base_task() const { | 59 base::WeakPtr<buzz::XmppTaskParentInterface> base_task() const { |
60 return base_task_; | 60 return base_task_; |
61 } | 61 } |
62 | 62 |
63 const ServerInformation& redirect_server() const { | 63 const ServerInformation& redirect_server() const { |
(...skipping 26 matching lines...) Expand all Loading... |
90 scoped_ptr<net::TestURLRequestContext>( | 90 scoped_ptr<net::TestURLRequestContext>( |
91 new MyTestURLRequestContext())), | 91 new MyTestURLRequestContext())), |
92 ServerList( | 92 ServerList( |
93 1, | 93 1, |
94 ServerInformation( | 94 ServerInformation( |
95 net::HostPortPair("example.com", 100), SUPPORTS_SSLTCP)), | 95 net::HostPortPair("example.com", 100), SUPPORTS_SSLTCP)), |
96 false /* try_ssltcp_first */, | 96 false /* try_ssltcp_first */, |
97 "auth_mechanism"), | 97 "auth_mechanism"), |
98 attempt_(new SingleLoginAttempt(login_settings_, &fake_delegate_)) {} | 98 attempt_(new SingleLoginAttempt(login_settings_, &fake_delegate_)) {} |
99 | 99 |
100 virtual void TearDown() OVERRIDE { | 100 virtual void TearDown() override { |
101 message_loop_.RunUntilIdle(); | 101 message_loop_.RunUntilIdle(); |
102 } | 102 } |
103 | 103 |
104 void FireRedirect(buzz::XmlElement* redirect_error) { | 104 void FireRedirect(buzz::XmlElement* redirect_error) { |
105 attempt_->OnError(buzz::XmppEngine::ERROR_STREAM, 0, redirect_error); | 105 attempt_->OnError(buzz::XmppEngine::ERROR_STREAM, 0, redirect_error); |
106 } | 106 } |
107 | 107 |
108 virtual ~SingleLoginAttemptTest() { | 108 virtual ~SingleLoginAttemptTest() { |
109 attempt_.reset(); | 109 attempt_.reset(); |
110 message_loop_.RunUntilIdle(); | 110 message_loop_.RunUntilIdle(); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // Fire 'Unauthorized' errors and make sure the delegate gets the | 250 // Fire 'Unauthorized' errors and make sure the delegate gets the |
251 // OnCredentialsRejected() event. | 251 // OnCredentialsRejected() event. |
252 TEST_F(SingleLoginAttemptTest, CredentialsRejected) { | 252 TEST_F(SingleLoginAttemptTest, CredentialsRejected) { |
253 attempt_->OnError(buzz::XmppEngine::ERROR_UNAUTHORIZED, 0, NULL); | 253 attempt_->OnError(buzz::XmppEngine::ERROR_UNAUTHORIZED, 0, NULL); |
254 EXPECT_EQ(CREDENTIALS_REJECTED, fake_delegate_.state()); | 254 EXPECT_EQ(CREDENTIALS_REJECTED, fake_delegate_.state()); |
255 } | 255 } |
256 | 256 |
257 } // namespace | 257 } // namespace |
258 | 258 |
259 } // namespace notifier | 259 } // namespace notifier |
OLD | NEW |