| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "google_apis/gcm/engine/checkin_request.h" | 8 #include "google_apis/gcm/engine/checkin_request.h" |
| 9 #include "google_apis/gcm/gcm_stats_recorder.h" |
| 9 #include "google_apis/gcm/protocol/checkin.pb.h" | 10 #include "google_apis/gcm/protocol/checkin.pb.h" |
| 10 #include "net/base/backoff_entry.h" | 11 #include "net/base/backoff_entry.h" |
| 11 #include "net/url_request/test_url_fetcher_factory.h" | 12 #include "net/url_request/test_url_fetcher_factory.h" |
| 12 #include "net/url_request/url_request_test_util.h" | 13 #include "net/url_request/url_request_test_util.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 namespace gcm { | 16 namespace gcm { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 bool callback_called_; | 82 bool callback_called_; |
| 82 uint64 android_id_; | 83 uint64 android_id_; |
| 83 uint64 security_token_; | 84 uint64 security_token_; |
| 84 int checkin_device_type_; | 85 int checkin_device_type_; |
| 85 base::MessageLoop message_loop_; | 86 base::MessageLoop message_loop_; |
| 86 net::TestURLFetcherFactory url_fetcher_factory_; | 87 net::TestURLFetcherFactory url_fetcher_factory_; |
| 87 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; | 88 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; |
| 88 checkin_proto::ChromeBuildProto chrome_build_proto_; | 89 checkin_proto::ChromeBuildProto chrome_build_proto_; |
| 89 std::vector<std::string> account_ids_; | 90 std::vector<std::string> account_ids_; |
| 90 scoped_ptr<CheckinRequest> request_; | 91 scoped_ptr<CheckinRequest> request_; |
| 92 gcm::GCMStatsRecorder recorder_; |
| 91 }; | 93 }; |
| 92 | 94 |
| 93 CheckinRequestTest::CheckinRequestTest() | 95 CheckinRequestTest::CheckinRequestTest() |
| 94 : callback_called_(false), | 96 : callback_called_(false), |
| 95 android_id_(kBlankAndroidId), | 97 android_id_(kBlankAndroidId), |
| 96 security_token_(kBlankSecurityToken), | 98 security_token_(kBlankSecurityToken), |
| 97 checkin_device_type_(0), | 99 checkin_device_type_(0), |
| 98 url_request_context_getter_(new net::TestURLRequestContextGetter( | 100 url_request_context_getter_(new net::TestURLRequestContextGetter( |
| 99 message_loop_.message_loop_proxy())) { | 101 message_loop_.message_loop_proxy())) { |
| 100 account_ids_.push_back("account_id"); | 102 account_ids_.push_back("account_id"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 119 chrome_build_proto_.set_chrome_version(kChromeVersion); | 121 chrome_build_proto_.set_chrome_version(kChromeVersion); |
| 120 // Then create a request with that protobuf and specified android_id, | 122 // Then create a request with that protobuf and specified android_id, |
| 121 // security_token. | 123 // security_token. |
| 122 request_.reset(new CheckinRequest( | 124 request_.reset(new CheckinRequest( |
| 123 base::Bind(&CheckinRequestTest::FetcherCallback, base::Unretained(this)), | 125 base::Bind(&CheckinRequestTest::FetcherCallback, base::Unretained(this)), |
| 124 kDefaultBackoffPolicy, | 126 kDefaultBackoffPolicy, |
| 125 chrome_build_proto_, | 127 chrome_build_proto_, |
| 126 android_id, | 128 android_id, |
| 127 security_token, | 129 security_token, |
| 128 account_ids_, | 130 account_ids_, |
| 129 url_request_context_getter_.get())); | 131 url_request_context_getter_.get(), |
| 132 &recorder_)); |
| 130 | 133 |
| 131 // Setting android_id_ and security_token_ to blank value, not used elsewhere | 134 // Setting android_id_ and security_token_ to blank value, not used elsewhere |
| 132 // in the tests. | 135 // in the tests. |
| 133 callback_called_ = false; | 136 callback_called_ = false; |
| 134 android_id_ = kBlankAndroidId; | 137 android_id_ = kBlankAndroidId; |
| 135 security_token_ = kBlankSecurityToken; | 138 security_token_ = kBlankSecurityToken; |
| 136 } | 139 } |
| 137 | 140 |
| 138 void CheckinRequestTest::SetResponseStatusAndString( | 141 void CheckinRequestTest::SetResponseStatusAndString( |
| 139 net::HttpStatusCode status_code, | 142 net::HttpStatusCode status_code, |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 366 |
| 364 SetResponse(VALID_RESPONSE); | 367 SetResponse(VALID_RESPONSE); |
| 365 CompleteFetch(); | 368 CompleteFetch(); |
| 366 | 369 |
| 367 EXPECT_TRUE(callback_called_); | 370 EXPECT_TRUE(callback_called_); |
| 368 EXPECT_EQ(kAndroidId, android_id_); | 371 EXPECT_EQ(kAndroidId, android_id_); |
| 369 EXPECT_EQ(kSecurityToken, security_token_); | 372 EXPECT_EQ(kSecurityToken, security_token_); |
| 370 } | 373 } |
| 371 | 374 |
| 372 } // namespace gcm | 375 } // namespace gcm |
| OLD | NEW |