| 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 "google_apis/gcm/gcm_client_impl.h" | 5 #include "google_apis/gcm/gcm_client_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 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" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 virtual scoped_ptr<MCSClient> BuildMCSClient( | 124 virtual scoped_ptr<MCSClient> BuildMCSClient( |
| 125 const std::string& version, | 125 const std::string& version, |
| 126 base::Clock* clock, | 126 base::Clock* clock, |
| 127 ConnectionFactory* connection_factory, | 127 ConnectionFactory* connection_factory, |
| 128 GCMStore* gcm_store, | 128 GCMStore* gcm_store, |
| 129 GCMStatsRecorder* recorder) OVERRIDE; | 129 GCMStatsRecorder* recorder) OVERRIDE; |
| 130 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory( | 130 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory( |
| 131 const std::vector<GURL>& endpoints, | 131 const std::vector<GURL>& endpoints, |
| 132 const net::BackoffEntry::Policy& backoff_policy, | 132 const net::BackoffEntry::Policy& backoff_policy, |
| 133 scoped_refptr<net::HttpNetworkSession> network_session, | 133 scoped_refptr<net::HttpNetworkSession> network_session, |
| 134 net::NetLog* net_log) OVERRIDE; | 134 net::NetLog* net_log, |
| 135 GCMStatsRecorder* recorder) OVERRIDE; |
| 135 }; | 136 }; |
| 136 | 137 |
| 137 FakeGCMInternalsBuilder::FakeGCMInternalsBuilder() {} | 138 FakeGCMInternalsBuilder::FakeGCMInternalsBuilder() {} |
| 138 | 139 |
| 139 FakeGCMInternalsBuilder::~FakeGCMInternalsBuilder() {} | 140 FakeGCMInternalsBuilder::~FakeGCMInternalsBuilder() {} |
| 140 | 141 |
| 141 scoped_ptr<base::Clock> FakeGCMInternalsBuilder::BuildClock() { | 142 scoped_ptr<base::Clock> FakeGCMInternalsBuilder::BuildClock() { |
| 142 return make_scoped_ptr<base::Clock>(new base::SimpleTestClock()); | 143 return make_scoped_ptr<base::Clock>(new base::SimpleTestClock()); |
| 143 } | 144 } |
| 144 | 145 |
| 145 scoped_ptr<MCSClient> FakeGCMInternalsBuilder::BuildMCSClient( | 146 scoped_ptr<MCSClient> FakeGCMInternalsBuilder::BuildMCSClient( |
| 146 const std::string& version, | 147 const std::string& version, |
| 147 base::Clock* clock, | 148 base::Clock* clock, |
| 148 ConnectionFactory* connection_factory, | 149 ConnectionFactory* connection_factory, |
| 149 GCMStore* gcm_store, | 150 GCMStore* gcm_store, |
| 150 GCMStatsRecorder* recorder) { | 151 GCMStatsRecorder* recorder) { |
| 151 return make_scoped_ptr<MCSClient>(new FakeMCSClient(clock, | 152 return make_scoped_ptr<MCSClient>(new FakeMCSClient(clock, |
| 152 connection_factory, | 153 connection_factory, |
| 153 gcm_store, | 154 gcm_store, |
| 154 recorder)); | 155 recorder)); |
| 155 } | 156 } |
| 156 | 157 |
| 157 scoped_ptr<ConnectionFactory> FakeGCMInternalsBuilder::BuildConnectionFactory( | 158 scoped_ptr<ConnectionFactory> FakeGCMInternalsBuilder::BuildConnectionFactory( |
| 158 const std::vector<GURL>& endpoints, | 159 const std::vector<GURL>& endpoints, |
| 159 const net::BackoffEntry::Policy& backoff_policy, | 160 const net::BackoffEntry::Policy& backoff_policy, |
| 160 scoped_refptr<net::HttpNetworkSession> network_session, | 161 scoped_refptr<net::HttpNetworkSession> network_session, |
| 161 net::NetLog* net_log) { | 162 net::NetLog* net_log, |
| 163 GCMStatsRecorder* recorder) { |
| 162 return make_scoped_ptr<ConnectionFactory>(new FakeConnectionFactory()); | 164 return make_scoped_ptr<ConnectionFactory>(new FakeConnectionFactory()); |
| 163 } | 165 } |
| 164 | 166 |
| 165 } // namespace | 167 } // namespace |
| 166 | 168 |
| 167 class GCMClientImplTest : public testing::Test, | 169 class GCMClientImplTest : public testing::Test, |
| 168 public GCMClient::Delegate { | 170 public GCMClient::Delegate { |
| 169 public: | 171 public: |
| 170 GCMClientImplTest(); | 172 GCMClientImplTest(); |
| 171 virtual ~GCMClientImplTest(); | 173 virtual ~GCMClientImplTest(); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 EXPECT_EQ(CurrentTime(), mcs_client()->last_data_message_stanza().sent()); | 598 EXPECT_EQ(CurrentTime(), mcs_client()->last_data_message_stanza().sent()); |
| 597 EXPECT_EQ("007", mcs_client()->last_data_message_stanza().id()); | 599 EXPECT_EQ("007", mcs_client()->last_data_message_stanza().id()); |
| 598 EXPECT_EQ("gcm@chrome.com", mcs_client()->last_data_message_stanza().from()); | 600 EXPECT_EQ("gcm@chrome.com", mcs_client()->last_data_message_stanza().from()); |
| 599 EXPECT_EQ(kSender, mcs_client()->last_data_message_stanza().to()); | 601 EXPECT_EQ(kSender, mcs_client()->last_data_message_stanza().to()); |
| 600 EXPECT_EQ("key", mcs_client()->last_data_message_stanza().app_data(0).key()); | 602 EXPECT_EQ("key", mcs_client()->last_data_message_stanza().app_data(0).key()); |
| 601 EXPECT_EQ("value", | 603 EXPECT_EQ("value", |
| 602 mcs_client()->last_data_message_stanza().app_data(0).value()); | 604 mcs_client()->last_data_message_stanza().app_data(0).value()); |
| 603 } | 605 } |
| 604 | 606 |
| 605 } // namespace gcm | 607 } // namespace gcm |
| OLD | NEW |