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 <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/registration_request.h" | 11 #include "google_apis/gcm/engine/registration_request.h" |
12 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 12 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" |
13 #include "net/url_request/test_url_fetcher_factory.h" | 13 #include "net/url_request/test_url_fetcher_factory.h" |
14 #include "net/url_request/url_request_status.h" | 14 #include "net/url_request/url_request_status.h" |
15 #include "net/url_request/url_request_test_util.h" | 15 #include "net/url_request/url_request_test_util.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 namespace gcm { | 18 namespace gcm { |
19 | 19 |
20 namespace { | 20 namespace { |
21 const uint64 kAndroidId = 42UL; | 21 const uint64 kAndroidId = 42UL; |
22 const char kAppId[] = "TestAppId"; | 22 const char kAppId[] = "TestAppId"; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 protected: | 75 protected: |
76 int max_retry_count_; | 76 int max_retry_count_; |
77 RegistrationRequest::Status status_; | 77 RegistrationRequest::Status status_; |
78 std::string registration_id_; | 78 std::string registration_id_; |
79 bool callback_called_; | 79 bool callback_called_; |
80 std::map<std::string, std::string> extras_; | 80 std::map<std::string, std::string> extras_; |
81 scoped_ptr<RegistrationRequest> request_; | 81 scoped_ptr<RegistrationRequest> request_; |
82 base::MessageLoop message_loop_; | 82 base::MessageLoop message_loop_; |
83 net::TestURLFetcherFactory url_fetcher_factory_; | 83 net::TestURLFetcherFactory url_fetcher_factory_; |
84 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; | 84 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; |
85 GCMStatsRecorder recorder_; | 85 FakeGCMStatsRecorder recorder_; |
86 }; | 86 }; |
87 | 87 |
88 RegistrationRequestTest::RegistrationRequestTest() | 88 RegistrationRequestTest::RegistrationRequestTest() |
89 : max_retry_count_(2), | 89 : max_retry_count_(2), |
90 status_(RegistrationRequest::SUCCESS), | 90 status_(RegistrationRequest::SUCCESS), |
91 callback_called_(false), | 91 callback_called_(false), |
92 url_request_context_getter_(new net::TestURLRequestContextGetter( | 92 url_request_context_getter_(new net::TestURLRequestContextGetter( |
93 message_loop_.message_loop_proxy())) {} | 93 message_loop_.message_loop_proxy())) {} |
94 | 94 |
95 RegistrationRequestTest::~RegistrationRequestTest() {} | 95 RegistrationRequestTest::~RegistrationRequestTest() {} |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 | 418 |
419 SetResponseStatusAndString(net::HTTP_GATEWAY_TIMEOUT, "token=2501"); | 419 SetResponseStatusAndString(net::HTTP_GATEWAY_TIMEOUT, "token=2501"); |
420 CompleteFetch(); | 420 CompleteFetch(); |
421 | 421 |
422 EXPECT_TRUE(callback_called_); | 422 EXPECT_TRUE(callback_called_); |
423 EXPECT_EQ(RegistrationRequest::REACHED_MAX_RETRIES, status_); | 423 EXPECT_EQ(RegistrationRequest::REACHED_MAX_RETRIES, status_); |
424 EXPECT_EQ(std::string(), registration_id_); | 424 EXPECT_EQ(std::string(), registration_id_); |
425 } | 425 } |
426 | 426 |
427 } // namespace gcm | 427 } // namespace gcm |
OLD | NEW |