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

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

Issue 1239993004: Fix all failed and canceled URLRequestStatuses without errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix more failures Created 5 years, 4 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"
11 #include "google_apis/gcm/engine/gcm_registration_request_handler.h" 11 #include "google_apis/gcm/engine/gcm_registration_request_handler.h"
12 #include "google_apis/gcm/engine/gcm_request_test_base.h" 12 #include "google_apis/gcm/engine/gcm_request_test_base.h"
13 #include "google_apis/gcm/engine/instance_id_get_token_request_handler.h" 13 #include "google_apis/gcm/engine/instance_id_get_token_request_handler.h"
14 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" 14 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h"
15 #include "net/base/load_flags.h" 15 #include "net/base/load_flags.h"
16 #include "net/base/net_errors.h"
16 #include "net/url_request/url_request_status.h" 17 #include "net/url_request/url_request_status.h"
17 18
18 namespace gcm { 19 namespace gcm {
19 20
20 namespace { 21 namespace {
21 const uint64 kAndroidId = 42UL; 22 const uint64 kAndroidId = 42UL;
22 const char kAppId[] = "TestAppId"; 23 const char kAppId[] = "TestAppId";
23 const char kDeveloperId[] = "Project1"; 24 const char kDeveloperId[] = "Project1";
24 const char kLoginHeader[] = "AidLogin"; 25 const char kLoginHeader[] = "AidLogin";
25 const char kRegistrationURL[] = "http://foo.bar/register"; 26 const char kRegistrationURL[] = "http://foo.bar/register";
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 314
314 EXPECT_TRUE(callback_called_); 315 EXPECT_TRUE(callback_called_);
315 EXPECT_EQ(RegistrationRequest::INVALID_SENDER, status_); 316 EXPECT_EQ(RegistrationRequest::INVALID_SENDER, status_);
316 EXPECT_EQ(std::string(), registration_id_); 317 EXPECT_EQ(std::string(), registration_id_);
317 } 318 }
318 319
319 TEST_F(GCMRegistrationRequestTest, RequestNotSuccessful) { 320 TEST_F(GCMRegistrationRequestTest, RequestNotSuccessful) {
320 CreateRequest("sender1,sender2"); 321 CreateRequest("sender1,sender2");
321 request_->Start(); 322 request_->Start();
322 323
323 net::URLRequestStatus request_status(net::URLRequestStatus::FAILED, 1);
324 SetResponse(net::HTTP_OK, "token=2501"); 324 SetResponse(net::HTTP_OK, "token=2501");
325 325
326 net::TestURLFetcher* fetcher = GetFetcher(); 326 net::TestURLFetcher* fetcher = GetFetcher();
327 ASSERT_TRUE(fetcher); 327 ASSERT_TRUE(fetcher);
328 GetFetcher()->set_status(request_status); 328 GetFetcher()->set_status(net::URLRequestStatus::FromError(net::ERR_FAILED));
329 329
330 CompleteFetch(); 330 CompleteFetch();
331 331
332 EXPECT_FALSE(callback_called_); 332 EXPECT_FALSE(callback_called_);
333 333
334 // Ensuring a retry happened and succeeded. 334 // Ensuring a retry happened and succeeded.
335 SetResponse(net::HTTP_OK, "token=2501"); 335 SetResponse(net::HTTP_OK, "token=2501");
336 CompleteFetch(); 336 CompleteFetch();
337 337
338 EXPECT_TRUE(callback_called_); 338 EXPECT_TRUE(callback_called_);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 518
519 SetResponse(net::HTTP_OK, "token=2501"); 519 SetResponse(net::HTTP_OK, "token=2501");
520 CompleteFetch(); 520 CompleteFetch();
521 521
522 EXPECT_TRUE(callback_called_); 522 EXPECT_TRUE(callback_called_);
523 EXPECT_EQ(RegistrationRequest::SUCCESS, status_); 523 EXPECT_EQ(RegistrationRequest::SUCCESS, status_);
524 EXPECT_EQ("2501", registration_id_); 524 EXPECT_EQ("2501", registration_id_);
525 } 525 }
526 526
527 } // namespace gcm 527 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gaia/oauth2_mint_token_flow_unittest.cc ('k') | mojo/services/network/url_loader_impl_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698