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

Side by Side Diff: google_apis/gcm/engine/checkin_request_unittest.cc

Issue 261573002: Add checkin activity recording to gcm recorder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing jian's comments. Created 6 years, 7 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
OLDNEW
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 bool callback_called_; 84 bool callback_called_;
84 uint64 android_id_; 85 uint64 android_id_;
85 uint64 security_token_; 86 uint64 security_token_;
86 int checkin_device_type_; 87 int checkin_device_type_;
87 base::MessageLoop message_loop_; 88 base::MessageLoop message_loop_;
88 net::TestURLFetcherFactory url_fetcher_factory_; 89 net::TestURLFetcherFactory url_fetcher_factory_;
89 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; 90 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_;
90 checkin_proto::ChromeBuildProto chrome_build_proto_; 91 checkin_proto::ChromeBuildProto chrome_build_proto_;
91 std::vector<std::string> account_ids_; 92 std::vector<std::string> account_ids_;
92 scoped_ptr<CheckinRequest> request_; 93 scoped_ptr<CheckinRequest> request_;
94 GCMStatsRecorder recorder_;
93 }; 95 };
94 96
95 CheckinRequestTest::CheckinRequestTest() 97 CheckinRequestTest::CheckinRequestTest()
96 : callback_called_(false), 98 : callback_called_(false),
97 android_id_(kBlankAndroidId), 99 android_id_(kBlankAndroidId),
98 security_token_(kBlankSecurityToken), 100 security_token_(kBlankSecurityToken),
99 checkin_device_type_(0), 101 checkin_device_type_(0),
100 url_request_context_getter_(new net::TestURLRequestContextGetter( 102 url_request_context_getter_(new net::TestURLRequestContextGetter(
101 message_loop_.message_loop_proxy())) { 103 message_loop_.message_loop_proxy())) {
102 account_ids_.push_back("account_id"); 104 account_ids_.push_back("account_id");
(...skipping 24 matching lines...) Expand all
127 security_token, 129 security_token,
128 kSettingsDigest, 130 kSettingsDigest,
129 account_ids_, 131 account_ids_,
130 chrome_build_proto_); 132 chrome_build_proto_);
131 // Then create a request with that protobuf and specified android_id, 133 // Then create a request with that protobuf and specified android_id,
132 // security_token. 134 // security_token.
133 request_.reset(new CheckinRequest( 135 request_.reset(new CheckinRequest(
134 request_info, 136 request_info,
135 kDefaultBackoffPolicy, 137 kDefaultBackoffPolicy,
136 base::Bind(&CheckinRequestTest::FetcherCallback, base::Unretained(this)), 138 base::Bind(&CheckinRequestTest::FetcherCallback, base::Unretained(this)),
137 url_request_context_getter_.get())); 139 url_request_context_getter_.get(),
140 &recorder_));
138 141
139 // Setting android_id_ and security_token_ to blank value, not used elsewhere 142 // Setting android_id_ and security_token_ to blank value, not used elsewhere
140 // in the tests. 143 // in the tests.
141 callback_called_ = false; 144 callback_called_ = false;
142 android_id_ = kBlankAndroidId; 145 android_id_ = kBlankAndroidId;
143 security_token_ = kBlankSecurityToken; 146 security_token_ = kBlankSecurityToken;
144 } 147 }
145 148
146 void CheckinRequestTest::SetResponseStatusAndString( 149 void CheckinRequestTest::SetResponseStatusAndString(
147 net::HttpStatusCode status_code, 150 net::HttpStatusCode status_code,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 375
373 SetResponse(VALID_RESPONSE); 376 SetResponse(VALID_RESPONSE);
374 CompleteFetch(); 377 CompleteFetch();
375 378
376 EXPECT_TRUE(callback_called_); 379 EXPECT_TRUE(callback_called_);
377 EXPECT_EQ(kAndroidId, android_id_); 380 EXPECT_EQ(kAndroidId, android_id_);
378 EXPECT_EQ(kSecurityToken, security_token_); 381 EXPECT_EQ(kSecurityToken, security_token_);
379 } 382 }
380 383
381 } // namespace gcm 384 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698