checkin_request_unittest.cc revision 46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd
15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <string> 6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include <vector> 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "google_apis/gcm/engine/checkin_request.h" 946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "google_apis/gcm/protocol/checkin.pb.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "net/base/backoff_entry.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "net/url_request/test_url_fetcher_factory.h" 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "net/url_request/url_request_test_util.h" 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h" 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace gcm { 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace { 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const net::BackoffEntry::Policy kDefaultBackoffPolicy = { 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Number of initial errors (in sequence) to ignore before applying 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // exponential back-off rules. 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Explicitly set to 1 to skip the delay of the first Retry, as we are not 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // trying to test the backoff itself, but rather the fact that retry happens. 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1, 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Initial delay for exponential back-off in ms. 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 15000, // 15 seconds. 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Factor by which the waiting time will be multiplied. 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2, 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Fuzzing percentage. ex: 10% will spread requests randomly 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // between 90%-100% of the calculated time. 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 0.5, // 50%. 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Maximum amount of time we are willing to delay our request in ms. 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1000 * 60 * 5, // 5 minutes. 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Time to keep an entry from being discarded even when it 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // has no significant state, -1 to never discard. 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) -1, 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Don't use initial delay unless the last request was an error. 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) false, 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const uint64 kAndroidId = 42UL; 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const uint64 kBlankAndroidId = 999999UL; 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const uint64 kBlankSecurityToken = 999999UL; 53010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)const char kCheckinURL[] = "http://foo.bar/checkin"; 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const char kChromeVersion[] = "Version String"; 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const uint64 kSecurityToken = 77; 56a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochconst char kSettingsDigest[] = "settings_digest"; 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CheckinRequestTest : public testing::Test { 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) enum ResponseScenario { 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) VALID_RESPONSE, // Both android_id and security_token set in response. 625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) MISSING_ANDROID_ID, // android_id is missing. 635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) MISSING_SECURITY_TOKEN, // security_token is missing. 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ANDROID_ID_IS_ZER0, // android_id is 0. 655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SECURITY_TOKEN_IS_ZERO // security_token is 0. 665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) }; 675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CheckinRequestTest(); 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual ~CheckinRequestTest(); 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 71a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch void FetcherCallback( 72a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch const checkin_proto::AndroidCheckinResponse& response); 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void CreateRequest(uint64 android_id, uint64 security_token); 755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void SetResponseStatusAndString( 775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) net::HttpStatusCode status_code, 785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& response_data); 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void CompleteFetch(); 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void SetResponse(ResponseScenario response_scenario); 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) protected: 855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool callback_called_; 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint64 android_id_; 875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint64 security_token_; 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int checkin_device_type_; 895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::MessageLoop message_loop_; 905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) net::TestURLFetcherFactory url_fetcher_factory_; 915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; 925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) checkin_proto::ChromeBuildProto chrome_build_proto_; 93a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) std::vector<std::string> account_ids_; 945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<CheckinRequest> request_; 9546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) FakeGCMStatsRecorder recorder_; 965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)CheckinRequestTest::CheckinRequestTest() 995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : callback_called_(false), 1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) android_id_(kBlankAndroidId), 1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) security_token_(kBlankSecurityToken), 1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) checkin_device_type_(0), 1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) url_request_context_getter_(new net::TestURLRequestContextGetter( 104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) message_loop_.message_loop_proxy())) { 105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) account_ids_.push_back("account_id"); 106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)CheckinRequestTest::~CheckinRequestTest() {} 1095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 110a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochvoid CheckinRequestTest::FetcherCallback( 111a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch const checkin_proto::AndroidCheckinResponse& checkin_response) { 1125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) callback_called_ = true; 113a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch if (checkin_response.has_android_id()) 114a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch android_id_ = checkin_response.android_id(); 115a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch if (checkin_response.has_security_token()) 116a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch security_token_ = checkin_response.security_token(); 1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void CheckinRequestTest::CreateRequest(uint64 android_id, 1205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint64 security_token) { 1215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // First setup a chrome_build protobuf. 1225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome_build_proto_.set_platform( 1235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) checkin_proto::ChromeBuildProto::PLATFORM_LINUX); 1245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome_build_proto_.set_channel( 1255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) checkin_proto::ChromeBuildProto::CHANNEL_CANARY); 1265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome_build_proto_.set_chrome_version(kChromeVersion); 127a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 128a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch CheckinRequest::RequestInfo request_info( 129a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch android_id, 130a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch security_token, 131a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch kSettingsDigest, 132a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch account_ids_, 133a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch chrome_build_proto_); 1345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Then create a request with that protobuf and specified android_id, 1355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // security_token. 1365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_.reset(new CheckinRequest( 137010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) GURL(kCheckinURL), 138a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch request_info, 1395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) kDefaultBackoffPolicy, 140a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch base::Bind(&CheckinRequestTest::FetcherCallback, base::Unretained(this)), 141010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) url_request_context_getter_.get(), 142010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) &recorder_)); 1435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Setting android_id_ and security_token_ to blank value, not used elsewhere 1455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // in the tests. 1465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) callback_called_ = false; 1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) android_id_ = kBlankAndroidId; 1485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) security_token_ = kBlankSecurityToken; 1495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void CheckinRequestTest::SetResponseStatusAndString( 1525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) net::HttpStatusCode status_code, 1535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& response_data) { 1545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) net::TestURLFetcher* fetcher = 1555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) url_fetcher_factory_.GetFetcherByID(0); 1565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(fetcher); 1575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) fetcher->set_response_code(status_code); 1585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) fetcher->SetResponseString(response_data); 1595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void CheckinRequestTest::CompleteFetch() { 1625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) net::TestURLFetcher* fetcher = 1635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) url_fetcher_factory_.GetFetcherByID(0); 1645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(fetcher); 1655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) fetcher->delegate()->OnURLFetchComplete(fetcher); 1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void CheckinRequestTest::SetResponse(ResponseScenario response_scenario) { 1695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) checkin_proto::AndroidCheckinResponse response; 1705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) response.set_stats_ok(true); 1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint64 android_id = response_scenario == ANDROID_ID_IS_ZER0 ? 0 : kAndroidId; 1735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint64 security_token = 1745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) response_scenario == SECURITY_TOKEN_IS_ZERO ? 0 : kSecurityToken; 1755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (response_scenario != MISSING_ANDROID_ID) 1775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) response.set_android_id(android_id); 1785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (response_scenario != MISSING_SECURITY_TOKEN) 1805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) response.set_security_token(security_token); 1815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::string response_string; 1835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) response.SerializeToString(&response_string); 1845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponseStatusAndString(net::HTTP_OK, response_string); 1855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 187010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)TEST_F(CheckinRequestTest, FetcherDataAndURL) { 1885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateRequest(kAndroidId, kSecurityToken); 1895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_->Start(); 1905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Get data sent by request. 1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); 1935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(fetcher); 194010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) EXPECT_EQ(GURL(kCheckinURL), fetcher->GetOriginalURL()); 195010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) 1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) checkin_proto::AndroidCheckinRequest request_proto; 1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_proto.ParseFromString(fetcher->upload_data()); 1985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kAndroidId, static_cast<uint64>(request_proto.id())); 1995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kSecurityToken, request_proto.security_token()); 2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(chrome_build_proto_.platform(), 2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_proto.checkin().chrome_build().platform()); 2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(chrome_build_proto_.chrome_version(), 2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_proto.checkin().chrome_build().chrome_version()); 2045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(chrome_build_proto_.channel(), 2055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_proto.checkin().chrome_build().channel()); 2065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#if defined(CHROME_OS) 2085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(checkin_proto::DEVICE_CHROME_OS, request_proto.checkin().type()); 2095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#else 2105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(checkin_proto::DEVICE_CHROME_BROWSER, 2115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_proto.checkin().type()); 2125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif 213a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 214a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch EXPECT_EQ(kSettingsDigest, request_proto.digest()); 215a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ(1, request_proto.account_cookie_size()); 216a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ("[account_id]", request_proto.account_cookie(0)); 2175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(CheckinRequestTest, ResponseBodyEmpty) { 2205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateRequest(0u, 0u); 2215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_->Start(); 2225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponseStatusAndString(net::HTTP_OK, std::string()); 2245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 2255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(callback_called_); 2275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(VALID_RESPONSE); 2295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 2305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(callback_called_); 2325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kAndroidId, android_id_); 2335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kSecurityToken, security_token_); 2345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(CheckinRequestTest, ResponseBodyCorrupted) { 2375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateRequest(0u, 0u); 2385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_->Start(); 2395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponseStatusAndString(net::HTTP_OK, "Corrupted response body"); 2415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 2425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(callback_called_); 2445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(VALID_RESPONSE); 2465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 2475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(callback_called_); 2495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kAndroidId, android_id_); 2505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kSecurityToken, security_token_); 2515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(CheckinRequestTest, ResponseHttpStatusUnauthorized) { 2545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateRequest(0u, 0u); 2555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_->Start(); 2565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponseStatusAndString(net::HTTP_UNAUTHORIZED, std::string()); 2585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 2595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(callback_called_); 261a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch EXPECT_EQ(kBlankAndroidId, android_id_); 262a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch EXPECT_EQ(kBlankSecurityToken, security_token_); 2635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(CheckinRequestTest, ResponseHttpStatusBadRequest) { 2665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateRequest(0u, 0u); 2675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_->Start(); 2685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponseStatusAndString(net::HTTP_BAD_REQUEST, std::string()); 2705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 2715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(callback_called_); 273a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch EXPECT_EQ(kBlankAndroidId, android_id_); 274a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch EXPECT_EQ(kBlankSecurityToken, security_token_); 2755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(CheckinRequestTest, ResponseHttpStatusNotOK) { 2785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateRequest(0u, 0u); 2795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_->Start(); 2805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponseStatusAndString(net::HTTP_INTERNAL_SERVER_ERROR, std::string()); 2825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 2835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(callback_called_); 2855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(VALID_RESPONSE); 2875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 2885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(callback_called_); 2905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kAndroidId, android_id_); 2915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kSecurityToken, security_token_); 2925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(CheckinRequestTest, ResponseMissingAndroidId) { 2955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateRequest(0u, 0u); 2965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_->Start(); 2975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(MISSING_ANDROID_ID); 2995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 3005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(callback_called_); 3025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(VALID_RESPONSE); 3045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 3055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(callback_called_); 3075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kAndroidId, android_id_); 3085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kSecurityToken, security_token_); 3095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 3105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(CheckinRequestTest, ResponseMissingSecurityToken) { 3125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateRequest(0u, 0u); 3135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_->Start(); 3145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(MISSING_SECURITY_TOKEN); 3165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 3175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(callback_called_); 3195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(VALID_RESPONSE); 3215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 3225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(callback_called_); 3245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kAndroidId, android_id_); 3255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kSecurityToken, security_token_); 3265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 3275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(CheckinRequestTest, AndroidIdEqualsZeroInResponse) { 3295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateRequest(0u, 0u); 3305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_->Start(); 3315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(ANDROID_ID_IS_ZER0); 3335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 3345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(callback_called_); 3365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(VALID_RESPONSE); 3385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 3395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(callback_called_); 3415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kAndroidId, android_id_); 3425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kSecurityToken, security_token_); 3435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 3445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(CheckinRequestTest, SecurityTokenEqualsZeroInResponse) { 3465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateRequest(0u, 0u); 3475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_->Start(); 3485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(SECURITY_TOKEN_IS_ZERO); 3505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 3515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(callback_called_); 3535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(VALID_RESPONSE); 3555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 3565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(callback_called_); 3585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kAndroidId, android_id_); 3595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kSecurityToken, security_token_); 3605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 3615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(CheckinRequestTest, SuccessfulFirstTimeCheckin) { 3635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateRequest(0u, 0u); 3645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_->Start(); 3655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(VALID_RESPONSE); 3675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 3685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(callback_called_); 3705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kAndroidId, android_id_); 3715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kSecurityToken, security_token_); 3725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 3735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(CheckinRequestTest, SuccessfulSubsequentCheckin) { 3755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateRequest(kAndroidId, kSecurityToken); 3765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) request_->Start(); 3775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetResponse(VALID_RESPONSE); 3795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CompleteFetch(); 3805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(callback_called_); 3825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kAndroidId, android_id_); 3835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(kSecurityToken, security_token_); 3845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 3855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace gcm 387