| 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 | 6 |
| 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "base/thread_task_runner_handle.h" |
| 7 #include "google_apis/gcm/engine/checkin_request.h" | 9 #include "google_apis/gcm/engine/checkin_request.h" |
| 8 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" | 10 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" |
| 9 #include "google_apis/gcm/protocol/checkin.pb.h" | 11 #include "google_apis/gcm/protocol/checkin.pb.h" |
| 10 #include "net/base/backoff_entry.h" | 12 #include "net/base/backoff_entry.h" |
| 11 #include "net/url_request/test_url_fetcher_factory.h" | 13 #include "net/url_request/test_url_fetcher_factory.h" |
| 12 #include "net/url_request/url_request_test_util.h" | 14 #include "net/url_request/url_request_test_util.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 16 |
| 15 namespace gcm { | 17 namespace gcm { |
| 16 | 18 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 82 |
| 81 void CompleteFetch(); | 83 void CompleteFetch(); |
| 82 | 84 |
| 83 void SetResponse(ResponseScenario response_scenario); | 85 void SetResponse(ResponseScenario response_scenario); |
| 84 | 86 |
| 85 protected: | 87 protected: |
| 86 bool callback_called_; | 88 bool callback_called_; |
| 87 uint64 android_id_; | 89 uint64 android_id_; |
| 88 uint64 security_token_; | 90 uint64 security_token_; |
| 89 int checkin_device_type_; | 91 int checkin_device_type_; |
| 90 base::MessageLoop message_loop_; | 92 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
| 93 base::ThreadTaskRunnerHandle task_runner_handle_; |
| 91 net::TestURLFetcherFactory url_fetcher_factory_; | 94 net::TestURLFetcherFactory url_fetcher_factory_; |
| 92 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; | 95 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; |
| 93 checkin_proto::ChromeBuildProto chrome_build_proto_; | 96 checkin_proto::ChromeBuildProto chrome_build_proto_; |
| 94 scoped_ptr<CheckinRequest> request_; | 97 scoped_ptr<CheckinRequest> request_; |
| 95 FakeGCMStatsRecorder recorder_; | 98 FakeGCMStatsRecorder recorder_; |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 CheckinRequestTest::CheckinRequestTest() | 101 CheckinRequestTest::CheckinRequestTest() |
| 99 : callback_called_(false), | 102 : callback_called_(false), |
| 100 android_id_(kBlankAndroidId), | 103 android_id_(kBlankAndroidId), |
| 101 security_token_(kBlankSecurityToken), | 104 security_token_(kBlankSecurityToken), |
| 102 checkin_device_type_(0), | 105 checkin_device_type_(0), |
| 106 task_runner_(new base::TestSimpleTaskRunner()), |
| 107 task_runner_handle_(task_runner_), |
| 103 url_request_context_getter_(new net::TestURLRequestContextGetter( | 108 url_request_context_getter_(new net::TestURLRequestContextGetter( |
| 104 message_loop_.task_runner())) { | 109 task_runner_)) { |
| 105 } | 110 } |
| 106 | 111 |
| 107 CheckinRequestTest::~CheckinRequestTest() {} | 112 CheckinRequestTest::~CheckinRequestTest() {} |
| 108 | 113 |
| 109 void CheckinRequestTest::FetcherCallback( | 114 void CheckinRequestTest::FetcherCallback( |
| 110 const checkin_proto::AndroidCheckinResponse& checkin_response) { | 115 const checkin_proto::AndroidCheckinResponse& checkin_response) { |
| 111 callback_called_ = true; | 116 callback_called_ = true; |
| 112 if (checkin_response.has_android_id()) | 117 if (checkin_response.has_android_id()) |
| 113 android_id_ = checkin_response.android_id(); | 118 android_id_ = checkin_response.android_id(); |
| 114 if (checkin_response.has_security_token()) | 119 if (checkin_response.has_security_token()) |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 384 |
| 380 SetResponse(VALID_RESPONSE); | 385 SetResponse(VALID_RESPONSE); |
| 381 CompleteFetch(); | 386 CompleteFetch(); |
| 382 | 387 |
| 383 EXPECT_TRUE(callback_called_); | 388 EXPECT_TRUE(callback_called_); |
| 384 EXPECT_EQ(kAndroidId, android_id_); | 389 EXPECT_EQ(kAndroidId, android_id_); |
| 385 EXPECT_EQ(kSecurityToken, security_token_); | 390 EXPECT_EQ(kSecurityToken, security_token_); |
| 386 } | 391 } |
| 387 | 392 |
| 388 } // namespace gcm | 393 } // namespace gcm |
| OLD | NEW |