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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 }; | 140 }; |
141 | 141 |
142 TestConnectionFactoryImpl::TestConnectionFactoryImpl( | 142 TestConnectionFactoryImpl::TestConnectionFactoryImpl( |
143 const base::Closure& finished_callback) | 143 const base::Closure& finished_callback) |
144 : ConnectionFactoryImpl(BuildEndpoints(), | 144 : ConnectionFactoryImpl(BuildEndpoints(), |
145 net::BackoffEntry::Policy(), | 145 net::BackoffEntry::Policy(), |
146 NULL, | 146 NULL, |
147 NULL, | 147 NULL, |
148 NULL, | 148 NULL, |
149 &dummy_recorder_), | 149 &dummy_recorder_), |
| 150 // Set a non-null time. |
| 151 tick_clock_(base::TimeTicks() + base::TimeDelta::FromMilliseconds(1)), |
150 connect_result_(net::ERR_UNEXPECTED), | 152 connect_result_(net::ERR_UNEXPECTED), |
151 num_expected_attempts_(0), | 153 num_expected_attempts_(0), |
152 connections_fulfilled_(true), | 154 connections_fulfilled_(true), |
153 delay_login_(false), | 155 delay_login_(false), |
154 finished_callback_(finished_callback), | 156 finished_callback_(finished_callback), |
155 scoped_handler_( | 157 scoped_handler_( |
156 new FakeConnectionHandler(base::Bind(&ReadContinuation), | 158 new FakeConnectionHandler(base::Bind(&ReadContinuation), |
157 base::Bind(&WriteContinuation))), | 159 base::Bind(&WriteContinuation))), |
158 fake_handler_(scoped_handler_.get()) { | 160 fake_handler_(scoped_handler_.get()) {} |
159 // Set a non-null time. | |
160 tick_clock_.Advance(base::TimeDelta::FromMilliseconds(1)); | |
161 } | |
162 | 161 |
163 TestConnectionFactoryImpl::~TestConnectionFactoryImpl() { | 162 TestConnectionFactoryImpl::~TestConnectionFactoryImpl() { |
164 EXPECT_EQ(0, num_expected_attempts_); | 163 EXPECT_EQ(0, num_expected_attempts_); |
165 } | 164 } |
166 | 165 |
167 void TestConnectionFactoryImpl::ConnectImpl() { | 166 void TestConnectionFactoryImpl::ConnectImpl() { |
168 ASSERT_GT(num_expected_attempts_, 0); | 167 ASSERT_GT(num_expected_attempts_, 0); |
169 ASSERT_FALSE(GetConnectionHandler()->CanSendMessage()); | 168 ASSERT_FALSE(GetConnectionHandler()->CanSendMessage()); |
170 scoped_ptr<mcs_proto::LoginRequest> request(BuildLoginRequest(0, 0, "")); | 169 scoped_ptr<mcs_proto::LoginRequest> request(BuildLoginRequest(0, 0, "")); |
171 GetConnectionHandler()->Init(*request, NULL); | 170 GetConnectionHandler()->Init(*request, NULL); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 // Now trigger force a re-connection. | 563 // Now trigger force a re-connection. |
565 factory()->SetConnectResult(net::OK); | 564 factory()->SetConnectResult(net::OK); |
566 factory()->Connect(); | 565 factory()->Connect(); |
567 WaitForConnections(); | 566 WaitForConnections(); |
568 | 567 |
569 // Re-connection should succeed. | 568 // Re-connection should succeed. |
570 EXPECT_TRUE(factory()->IsEndpointReachable()); | 569 EXPECT_TRUE(factory()->IsEndpointReachable()); |
571 } | 570 } |
572 | 571 |
573 } // namespace gcm | 572 } // namespace gcm |
OLD | NEW |