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/monitoring/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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 bool callback_called_; | 85 bool callback_called_; |
85 uint64 android_id_; | 86 uint64 android_id_; |
86 uint64 security_token_; | 87 uint64 security_token_; |
87 int checkin_device_type_; | 88 int checkin_device_type_; |
88 base::MessageLoop message_loop_; | 89 base::MessageLoop message_loop_; |
89 net::TestURLFetcherFactory url_fetcher_factory_; | 90 net::TestURLFetcherFactory url_fetcher_factory_; |
90 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; | 91 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; |
91 checkin_proto::ChromeBuildProto chrome_build_proto_; | 92 checkin_proto::ChromeBuildProto chrome_build_proto_; |
92 std::vector<std::string> account_ids_; | 93 std::vector<std::string> account_ids_; |
93 scoped_ptr<CheckinRequest> request_; | 94 scoped_ptr<CheckinRequest> request_; |
| 95 GCMStatsRecorder recorder_; |
94 }; | 96 }; |
95 | 97 |
96 CheckinRequestTest::CheckinRequestTest() | 98 CheckinRequestTest::CheckinRequestTest() |
97 : callback_called_(false), | 99 : callback_called_(false), |
98 android_id_(kBlankAndroidId), | 100 android_id_(kBlankAndroidId), |
99 security_token_(kBlankSecurityToken), | 101 security_token_(kBlankSecurityToken), |
100 checkin_device_type_(0), | 102 checkin_device_type_(0), |
101 url_request_context_getter_(new net::TestURLRequestContextGetter( | 103 url_request_context_getter_(new net::TestURLRequestContextGetter( |
102 message_loop_.message_loop_proxy())) { | 104 message_loop_.message_loop_proxy())) { |
103 account_ids_.push_back("account_id"); | 105 account_ids_.push_back("account_id"); |
(...skipping 25 matching lines...) Expand all Loading... |
129 kSettingsDigest, | 131 kSettingsDigest, |
130 account_ids_, | 132 account_ids_, |
131 chrome_build_proto_); | 133 chrome_build_proto_); |
132 // Then create a request with that protobuf and specified android_id, | 134 // Then create a request with that protobuf and specified android_id, |
133 // security_token. | 135 // security_token. |
134 request_.reset(new CheckinRequest( | 136 request_.reset(new CheckinRequest( |
135 GURL(kCheckinURL), | 137 GURL(kCheckinURL), |
136 request_info, | 138 request_info, |
137 kDefaultBackoffPolicy, | 139 kDefaultBackoffPolicy, |
138 base::Bind(&CheckinRequestTest::FetcherCallback, base::Unretained(this)), | 140 base::Bind(&CheckinRequestTest::FetcherCallback, base::Unretained(this)), |
139 url_request_context_getter_.get())); | 141 url_request_context_getter_.get(), |
| 142 &recorder_)); |
140 | 143 |
141 // Setting android_id_ and security_token_ to blank value, not used elsewhere | 144 // Setting android_id_ and security_token_ to blank value, not used elsewhere |
142 // in the tests. | 145 // in the tests. |
143 callback_called_ = false; | 146 callback_called_ = false; |
144 android_id_ = kBlankAndroidId; | 147 android_id_ = kBlankAndroidId; |
145 security_token_ = kBlankSecurityToken; | 148 security_token_ = kBlankSecurityToken; |
146 } | 149 } |
147 | 150 |
148 void CheckinRequestTest::SetResponseStatusAndString( | 151 void CheckinRequestTest::SetResponseStatusAndString( |
149 net::HttpStatusCode status_code, | 152 net::HttpStatusCode status_code, |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 377 |
375 SetResponse(VALID_RESPONSE); | 378 SetResponse(VALID_RESPONSE); |
376 CompleteFetch(); | 379 CompleteFetch(); |
377 | 380 |
378 EXPECT_TRUE(callback_called_); | 381 EXPECT_TRUE(callback_called_); |
379 EXPECT_EQ(kAndroidId, android_id_); | 382 EXPECT_EQ(kAndroidId, android_id_); |
380 EXPECT_EQ(kSecurityToken, security_token_); | 383 EXPECT_EQ(kSecurityToken, security_token_); |
381 } | 384 } |
382 | 385 |
383 } // namespace gcm | 386 } // namespace gcm |
OLD | NEW |