OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "google_apis/gcm/engine/connection_factory_impl.h" | 5 #include "google_apis/gcm/engine/connection_factory_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/test/simple_test_tick_clock.h" | 11 #include "base/test/simple_test_tick_clock.h" |
12 #include "google_apis/gcm/base/mcs_util.h" | 12 #include "google_apis/gcm/base/mcs_util.h" |
13 #include "google_apis/gcm/engine/fake_connection_handler.h" | 13 #include "google_apis/gcm/engine/fake_connection_handler.h" |
| 14 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
14 #include "net/base/backoff_entry.h" | 15 #include "net/base/backoff_entry.h" |
15 #include "net/http/http_network_session.h" | 16 #include "net/http/http_network_session.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 class Policy; | 19 class Policy; |
19 | 20 |
20 namespace gcm { | 21 namespace gcm { |
21 namespace { | 22 namespace { |
22 | 23 |
23 const char kMCSEndpoint[] = "http://my.server"; | 24 const char kMCSEndpoint[] = "http://my.server"; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 int num_expected_attempts_; | 143 int num_expected_attempts_; |
143 // Whether all expected connection attempts have been fulfilled since an | 144 // Whether all expected connection attempts have been fulfilled since an |
144 // expectation was last set. | 145 // expectation was last set. |
145 bool connections_fulfilled_; | 146 bool connections_fulfilled_; |
146 // Whether to delay a login handshake completion or not. | 147 // Whether to delay a login handshake completion or not. |
147 bool delay_login_; | 148 bool delay_login_; |
148 // Callback to invoke when all connection attempts have been made. | 149 // Callback to invoke when all connection attempts have been made. |
149 base::Closure finished_callback_; | 150 base::Closure finished_callback_; |
150 // The current fake connection handler.. | 151 // The current fake connection handler.. |
151 FakeConnectionHandler* fake_handler_; | 152 FakeConnectionHandler* fake_handler_; |
| 153 GCMStatsRecorder dummy_recorder_; |
152 }; | 154 }; |
153 | 155 |
154 TestConnectionFactoryImpl::TestConnectionFactoryImpl( | 156 TestConnectionFactoryImpl::TestConnectionFactoryImpl( |
155 const base::Closure& finished_callback) | 157 const base::Closure& finished_callback) |
156 : ConnectionFactoryImpl(BuildEndpoints(), | 158 : ConnectionFactoryImpl(BuildEndpoints(), |
157 net::BackoffEntry::Policy(), | 159 net::BackoffEntry::Policy(), |
158 NULL, | 160 NULL, |
159 NULL), | 161 NULL, |
| 162 &dummy_recorder_), |
160 connect_result_(net::ERR_UNEXPECTED), | 163 connect_result_(net::ERR_UNEXPECTED), |
161 num_expected_attempts_(0), | 164 num_expected_attempts_(0), |
162 connections_fulfilled_(true), | 165 connections_fulfilled_(true), |
163 delay_login_(false), | 166 delay_login_(false), |
164 finished_callback_(finished_callback), | 167 finished_callback_(finished_callback), |
165 fake_handler_(NULL) { | 168 fake_handler_(NULL) { |
166 // Set a non-null time. | 169 // Set a non-null time. |
167 tick_clock_.Advance(base::TimeDelta::FromMilliseconds(1)); | 170 tick_clock_.Advance(base::TimeDelta::FromMilliseconds(1)); |
168 } | 171 } |
169 | 172 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 EXPECT_NE(retry_time, factory()->NextRetryAttempt()); | 504 EXPECT_NE(retry_time, factory()->NextRetryAttempt()); |
502 retry_time = factory()->NextRetryAttempt(); | 505 retry_time = factory()->NextRetryAttempt(); |
503 EXPECT_FALSE(retry_time.is_null()); | 506 EXPECT_FALSE(retry_time.is_null()); |
504 EXPECT_GE((retry_time - connect_time).InMilliseconds(), | 507 EXPECT_GE((retry_time - connect_time).InMilliseconds(), |
505 CalculateBackoff(3)); | 508 CalculateBackoff(3)); |
506 EXPECT_FALSE(factory()->IsEndpointReachable()); | 509 EXPECT_FALSE(factory()->IsEndpointReachable()); |
507 } | 510 } |
508 | 511 |
509 } // namespace | 512 } // namespace |
510 } // namespace gcm | 513 } // namespace gcm |
OLD | NEW |