Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1084)

Side by Side Diff: google_apis/gaia/gaia_auth_fetcher_unittest.cc

Issue 203033002: Fix "unreachable code" warnings (MSVC warning 4702) in google_apis/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « google_apis/gaia/gaia_auth_fetcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // A complete set of unit tests for GaiaAuthFetcher. 5 // A complete set of unit tests for GaiaAuthFetcher.
6 // Originally ported from GoogleAuthenticator tests. 6 // Originally ported from GoogleAuthenticator tests.
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 399 }
400 400
401 TEST_F(GaiaAuthFetcherTest, AccountDisabledError) { 401 TEST_F(GaiaAuthFetcherTest, AccountDisabledError) {
402 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); 402 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
403 std::string data = "Error=AccountDisabled\n"; 403 std::string data = "Error=AccountDisabled\n";
404 GoogleServiceAuthError error = 404 GoogleServiceAuthError error =
405 GaiaAuthFetcher::GenerateAuthError(data, status); 405 GaiaAuthFetcher::GenerateAuthError(data, status);
406 EXPECT_EQ(error.state(), GoogleServiceAuthError::ACCOUNT_DISABLED); 406 EXPECT_EQ(error.state(), GoogleServiceAuthError::ACCOUNT_DISABLED);
407 } 407 }
408 408
409 TEST_F(GaiaAuthFetcherTest,BadAuthenticationError) { 409 TEST_F(GaiaAuthFetcherTest, BadAuthenticationError) {
410 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); 410 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
411 std::string data = "Error=BadAuthentication\n"; 411 std::string data = "Error=BadAuthentication\n";
412 GoogleServiceAuthError error = 412 GoogleServiceAuthError error =
413 GaiaAuthFetcher::GenerateAuthError(data, status); 413 GaiaAuthFetcher::GenerateAuthError(data, status);
414 EXPECT_EQ(error.state(), GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 414 EXPECT_EQ(error.state(), GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
415 } 415 }
416 416
417 TEST_F(GaiaAuthFetcherTest,IncomprehensibleError) { 417 TEST_F(GaiaAuthFetcherTest, IncomprehensibleError) {
418 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); 418 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
419 std::string data = "Error=Gobbledygook\n"; 419 std::string data = "Error=Gobbledygook\n";
420 GoogleServiceAuthError error = 420 GoogleServiceAuthError error =
421 GaiaAuthFetcher::GenerateAuthError(data, status); 421 GaiaAuthFetcher::GenerateAuthError(data, status);
422 EXPECT_EQ(error.state(), GoogleServiceAuthError::SERVICE_UNAVAILABLE); 422 EXPECT_EQ(error.state(), GoogleServiceAuthError::SERVICE_UNAVAILABLE);
423 } 423 }
424 424
425 TEST_F(GaiaAuthFetcherTest,ServiceUnavailableError) { 425 TEST_F(GaiaAuthFetcherTest, ServiceUnavailableError) {
426 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); 426 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
427 std::string data = "Error=ServiceUnavailable\n"; 427 std::string data = "Error=ServiceUnavailable\n";
428 GoogleServiceAuthError error = 428 GoogleServiceAuthError error =
429 GaiaAuthFetcher::GenerateOAuthLoginError(data, status); 429 GaiaAuthFetcher::GenerateAuthError(data, status);
430 EXPECT_EQ(error.state(), GoogleServiceAuthError::SERVICE_UNAVAILABLE);
431 }
432
433 TEST_F(GaiaAuthFetcherTest, OAuthAccountDeletedError) {
434 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
435 std::string data = "Error=adel\n";
436 GoogleServiceAuthError error =
437 GaiaAuthFetcher::GenerateOAuthLoginError(data, status);
438 EXPECT_EQ(error.state(), GoogleServiceAuthError::ACCOUNT_DELETED);
439 }
440
441 TEST_F(GaiaAuthFetcherTest, OAuthAccountDisabledError) {
442 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
443 std::string data = "Error=adis\n";
444 GoogleServiceAuthError error =
445 GaiaAuthFetcher::GenerateOAuthLoginError(data, status);
446 EXPECT_EQ(error.state(), GoogleServiceAuthError::ACCOUNT_DISABLED);
447 }
448
449 TEST_F(GaiaAuthFetcherTest, OAuthBadAuthenticationError) {
450 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
451 std::string data = "Error=badauth\n";
452 GoogleServiceAuthError error =
453 GaiaAuthFetcher::GenerateOAuthLoginError(data, status);
454 EXPECT_EQ(error.state(), GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
455 }
456
457 TEST_F(GaiaAuthFetcherTest, OAuthServiceUnavailableError) {
458 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
459 std::string data = "Error=ire\n";
460 GoogleServiceAuthError error =
461 GaiaAuthFetcher::GenerateOAuthLoginError(data, status);
462 EXPECT_EQ(error.state(), GoogleServiceAuthError::SERVICE_UNAVAILABLE); 430 EXPECT_EQ(error.state(), GoogleServiceAuthError::SERVICE_UNAVAILABLE);
463 } 431 }
464 432
465 TEST_F(GaiaAuthFetcherTest, FullLogin) { 433 TEST_F(GaiaAuthFetcherTest, FullLogin) {
466 MockGaiaConsumer consumer; 434 MockGaiaConsumer consumer;
467 EXPECT_CALL(consumer, OnClientLoginSuccess(_)) 435 EXPECT_CALL(consumer, OnClientLoginSuccess(_))
468 .Times(1); 436 .Times(1);
469 437
470 MockURLFetcherFactory<MockFetcher> factory; 438 MockURLFetcherFactory<MockFetcher> factory;
471 439
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 "\"//googleusercontent.com/A/B/C/D/photo.jpg\", 1, 1, 0]]]"); 817 "\"//googleusercontent.com/A/B/C/D/photo.jpg\", 1, 1, 0]]]");
850 MockGaiaConsumer consumer; 818 MockGaiaConsumer consumer;
851 EXPECT_CALL(consumer, OnListAccountsSuccess(data)).Times(1); 819 EXPECT_CALL(consumer, OnListAccountsSuccess(data)).Times(1);
852 820
853 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); 821 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext());
854 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); 822 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
855 MockFetcher mock_fetcher(GaiaUrls::GetInstance()->list_accounts_url(), 823 MockFetcher mock_fetcher(GaiaUrls::GetInstance()->list_accounts_url(),
856 status, net::HTTP_OK, cookies_, data, net::URLFetcher::GET, &auth); 824 status, net::HTTP_OK, cookies_, data, net::URLFetcher::GET, &auth);
857 auth.OnURLFetchComplete(&mock_fetcher); 825 auth.OnURLFetchComplete(&mock_fetcher);
858 } 826 }
OLDNEW
« no previous file with comments | « google_apis/gaia/gaia_auth_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698