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

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

Issue 1137463003: Support getting and deleting token for Instance ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add new files Created 5 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_tokenizer.h" 10 #include "base/strings/string_tokenizer.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 RegistrationRequestTest::~RegistrationRequestTest() {} 95 RegistrationRequestTest::~RegistrationRequestTest() {}
96 96
97 void RegistrationRequestTest::RegistrationCallback( 97 void RegistrationRequestTest::RegistrationCallback(
98 RegistrationRequest::Status status, 98 RegistrationRequest::Status status,
99 const std::string& registration_id) { 99 const std::string& registration_id) {
100 status_ = status; 100 status_ = status;
101 registration_id_ = registration_id; 101 registration_id_ = registration_id;
102 callback_called_ = true; 102 callback_called_ = true;
103 } 103 }
104 104
105 void RegistrationRequestTest::CreateRequest(const std::string& sender_ids) { 105 void RegistrationRequestTest::CreateRequest(const std::string& sender_ids) {
fgorski 2015/05/13 18:32:41 How about adding tests for Instance ID specific co
jianli 2015/05/13 22:42:57 Done.
106 std::vector<std::string> senders; 106 std::vector<std::string> senders;
107 base::StringTokenizer tokenizer(sender_ids, ","); 107 base::StringTokenizer tokenizer(sender_ids, ",");
108 while (tokenizer.GetNext()) 108 while (tokenizer.GetNext())
109 senders.push_back(tokenizer.token()); 109 senders.push_back(tokenizer.token());
110 110
111 scoped_ptr<RegistrationRequest::GCMRequestInfo> gcm_request_info(
112 new RegistrationRequest::GCMRequestInfo);
113 gcm_request_info->android_id = kAndroidId;
114 gcm_request_info->security_token = kSecurityToken;
115 gcm_request_info->app_id = kAppId;
116 gcm_request_info->sender_ids = senders;
111 request_.reset(new RegistrationRequest( 117 request_.reset(new RegistrationRequest(
112 GURL(kRegistrationURL), 118 GURL(kRegistrationURL),
113 RegistrationRequest::RequestInfo(kAndroidId, 119 gcm_request_info.Pass(),
114 kSecurityToken,
115 kAppId,
116 senders),
117 kDefaultBackoffPolicy, 120 kDefaultBackoffPolicy,
118 base::Bind(&RegistrationRequestTest::RegistrationCallback, 121 base::Bind(&RegistrationRequestTest::RegistrationCallback,
119 base::Unretained(this)), 122 base::Unretained(this)),
120 max_retry_count_, 123 max_retry_count_,
121 url_request_context_getter_.get(), 124 url_request_context_getter_.get(),
122 &recorder_)); 125 &recorder_));
123 } 126 }
124 127
125 void RegistrationRequestTest::SetResponseStatusAndString( 128 void RegistrationRequestTest::SetResponseStatusAndString(
126 net::HttpStatusCode status_code, 129 net::HttpStatusCode status_code,
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 421
419 SetResponseStatusAndString(net::HTTP_GATEWAY_TIMEOUT, "token=2501"); 422 SetResponseStatusAndString(net::HTTP_GATEWAY_TIMEOUT, "token=2501");
420 CompleteFetch(); 423 CompleteFetch();
421 424
422 EXPECT_TRUE(callback_called_); 425 EXPECT_TRUE(callback_called_);
423 EXPECT_EQ(RegistrationRequest::REACHED_MAX_RETRIES, status_); 426 EXPECT_EQ(RegistrationRequest::REACHED_MAX_RETRIES, status_);
424 EXPECT_EQ(std::string(), registration_id_); 427 EXPECT_EQ(std::string(), registration_id_);
425 } 428 }
426 429
427 } // namespace gcm 430 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698