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

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

Issue 1182183003: Move EndsWith to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « google_apis/drive/test_util.cc ('k') | gpu/command_buffer/service/program_manager.cc » ('j') | 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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 } 587 }
588 588
589 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenWithCookies) { 589 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenWithCookies) {
590 MockGaiaConsumer consumer; 590 MockGaiaConsumer consumer;
591 net::TestURLFetcherFactory factory; 591 net::TestURLFetcherFactory factory;
592 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); 592 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext());
593 auth.StartCookieForOAuthLoginTokenExchange("0"); 593 auth.StartCookieForOAuthLoginTokenExchange("0");
594 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); 594 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
595 EXPECT_TRUE(NULL != fetcher); 595 EXPECT_TRUE(NULL != fetcher);
596 EXPECT_EQ(net::LOAD_NORMAL, fetcher->GetLoadFlags()); 596 EXPECT_EQ(net::LOAD_NORMAL, fetcher->GetLoadFlags());
597 EXPECT_FALSE(EndsWith(fetcher->upload_data(), "device_type=chrome", true)); 597 EXPECT_FALSE(base::EndsWith(fetcher->upload_data(), "device_type=chrome",
598 true));
598 } 599 }
599 600
600 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenWithCookies_DeviceId) { 601 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenWithCookies_DeviceId) {
601 MockGaiaConsumer consumer; 602 MockGaiaConsumer consumer;
602 net::TestURLFetcherFactory factory; 603 net::TestURLFetcherFactory factory;
603 std::string expected_device_id("ABCDE-12345"); 604 std::string expected_device_id("ABCDE-12345");
604 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); 605 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext());
605 auth.StartCookieForOAuthLoginTokenExchangeWithDeviceId("0", 606 auth.StartCookieForOAuthLoginTokenExchangeWithDeviceId("0",
606 expected_device_id); 607 expected_device_id);
607 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); 608 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
608 EXPECT_TRUE(NULL != fetcher); 609 EXPECT_TRUE(NULL != fetcher);
609 EXPECT_EQ(net::LOAD_NORMAL, fetcher->GetLoadFlags()); 610 EXPECT_EQ(net::LOAD_NORMAL, fetcher->GetLoadFlags());
610 EXPECT_TRUE(EndsWith(fetcher->upload_data(), "device_type=chrome", true)); 611 EXPECT_TRUE(base::EndsWith(fetcher->upload_data(), "device_type=chrome",
612 true));
611 net::HttpRequestHeaders extra_request_headers; 613 net::HttpRequestHeaders extra_request_headers;
612 fetcher->GetExtraRequestHeaders(&extra_request_headers); 614 fetcher->GetExtraRequestHeaders(&extra_request_headers);
613 std::string device_id; 615 std::string device_id;
614 EXPECT_TRUE(extra_request_headers.GetHeader("X-Device-ID", &device_id)); 616 EXPECT_TRUE(extra_request_headers.GetHeader("X-Device-ID", &device_id));
615 EXPECT_EQ(device_id, expected_device_id); 617 EXPECT_EQ(device_id, expected_device_id);
616 } 618 }
617 619
618 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenClientLoginToOAuth2Failure) { 620 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenClientLoginToOAuth2Failure) {
619 MockGaiaConsumer consumer; 621 MockGaiaConsumer consumer;
620 EXPECT_CALL(consumer, OnClientOAuthFailure(_)) 622 EXPECT_CALL(consumer, OnClientOAuthFailure(_))
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); 890 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext());
889 auth.StartGetTokenResponse(std::string(), std::string(), std::string()); 891 auth.StartGetTokenResponse(std::string(), std::string(), std::string());
890 892
891 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); 893 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
892 MockFetcher mock_fetcher( 894 MockFetcher mock_fetcher(
893 GaiaUrls::GetInstance()->oauth2_iframe_url(), 895 GaiaUrls::GetInstance()->oauth2_iframe_url(),
894 status, net::HTTP_OK, cookies_, kGetTokenPairValidResponse, 896 status, net::HTTP_OK, cookies_, kGetTokenPairValidResponse,
895 net::URLFetcher::GET, &auth); 897 net::URLFetcher::GET, &auth);
896 auth.OnURLFetchComplete(&mock_fetcher); 898 auth.OnURLFetchComplete(&mock_fetcher);
897 } 899 }
OLDNEW
« no previous file with comments | « google_apis/drive/test_util.cc ('k') | gpu/command_buffer/service/program_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698