| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 MakeRedirectError(redirect_server.server.host() + ":invalidport")); | 212 MakeRedirectError(redirect_server.server.host() + ":invalidport")); |
| 213 FireRedirect(redirect_error.get()); | 213 FireRedirect(redirect_error.get()); |
| 214 | 214 |
| 215 EXPECT_EQ(REDIRECTED, fake_delegate_.state()); | 215 EXPECT_EQ(REDIRECTED, fake_delegate_.state()); |
| 216 EXPECT_TRUE(fake_delegate_.redirect_server().Equals(redirect_server)); | 216 EXPECT_TRUE(fake_delegate_.redirect_server().Equals(redirect_server)); |
| 217 } | 217 } |
| 218 | 218 |
| 219 // Fire an empty redirect and make sure the delegate does not get a | 219 // Fire an empty redirect and make sure the delegate does not get a |
| 220 // redirect. | 220 // redirect. |
| 221 TEST_F(SingleLoginAttemptTest, RedirectEmpty) { | 221 TEST_F(SingleLoginAttemptTest, RedirectEmpty) { |
| 222 scoped_ptr<buzz::XmlElement> redirect_error(MakeRedirectError("")); | 222 scoped_ptr<buzz::XmlElement> redirect_error(MakeRedirectError(std::string())); |
| 223 FireRedirect(redirect_error.get()); | 223 FireRedirect(redirect_error.get()); |
| 224 EXPECT_EQ(IDLE, fake_delegate_.state()); | 224 EXPECT_EQ(IDLE, fake_delegate_.state()); |
| 225 } | 225 } |
| 226 | 226 |
| 227 // Fire a redirect with a missing text element and make sure the | 227 // Fire a redirect with a missing text element and make sure the |
| 228 // delegate does not get a redirect. | 228 // delegate does not get a redirect. |
| 229 TEST_F(SingleLoginAttemptTest, RedirectMissingText) { | 229 TEST_F(SingleLoginAttemptTest, RedirectMissingText) { |
| 230 scoped_ptr<buzz::XmlElement> redirect_error(MakeRedirectError("")); | 230 scoped_ptr<buzz::XmlElement> redirect_error(MakeRedirectError(std::string())); |
| 231 redirect_error->RemoveChildAfter(redirect_error->FirstChild()); | 231 redirect_error->RemoveChildAfter(redirect_error->FirstChild()); |
| 232 FireRedirect(redirect_error.get()); | 232 FireRedirect(redirect_error.get()); |
| 233 EXPECT_EQ(IDLE, fake_delegate_.state()); | 233 EXPECT_EQ(IDLE, fake_delegate_.state()); |
| 234 } | 234 } |
| 235 | 235 |
| 236 // Fire a redirect with a missing see-other-host element and make sure | 236 // Fire a redirect with a missing see-other-host element and make sure |
| 237 // the delegate does not get a redirect. | 237 // the delegate does not get a redirect. |
| 238 TEST_F(SingleLoginAttemptTest, RedirectMissingSeeOtherHost) { | 238 TEST_F(SingleLoginAttemptTest, RedirectMissingSeeOtherHost) { |
| 239 scoped_ptr<buzz::XmlElement> redirect_error(MakeRedirectError("")); | 239 scoped_ptr<buzz::XmlElement> redirect_error(MakeRedirectError(std::string())); |
| 240 redirect_error->RemoveChildAfter(NULL); | 240 redirect_error->RemoveChildAfter(NULL); |
| 241 FireRedirect(redirect_error.get()); | 241 FireRedirect(redirect_error.get()); |
| 242 EXPECT_EQ(IDLE, fake_delegate_.state()); | 242 EXPECT_EQ(IDLE, fake_delegate_.state()); |
| 243 } | 243 } |
| 244 | 244 |
| 245 // Fire 'Unauthorized' errors and make sure the delegate gets the | 245 // Fire 'Unauthorized' errors and make sure the delegate gets the |
| 246 // OnCredentialsRejected() event. | 246 // OnCredentialsRejected() event. |
| 247 TEST_F(SingleLoginAttemptTest, CredentialsRejected) { | 247 TEST_F(SingleLoginAttemptTest, CredentialsRejected) { |
| 248 attempt_.OnError(buzz::XmppEngine::ERROR_UNAUTHORIZED, 0, NULL); | 248 attempt_.OnError(buzz::XmppEngine::ERROR_UNAUTHORIZED, 0, NULL); |
| 249 EXPECT_EQ(CREDENTIALS_REJECTED, fake_delegate_.state()); | 249 EXPECT_EQ(CREDENTIALS_REJECTED, fake_delegate_.state()); |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace | 252 } // namespace |
| 253 | 253 |
| 254 } // namespace notifier | 254 } // namespace notifier |
| OLD | NEW |