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/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/test/simple_test_clock.h" | 10 #include "base/test/simple_test_clock.h" |
11 #include "components/encryptor/os_crypt.h" | 11 #include "components/encryptor/os_crypt.h" |
12 #include "google_apis/gcm/base/mcs_message.h" | 12 #include "google_apis/gcm/base/mcs_message.h" |
13 #include "google_apis/gcm/base/mcs_util.h" | 13 #include "google_apis/gcm/base/mcs_util.h" |
14 #include "google_apis/gcm/engine/fake_connection_factory.h" | 14 #include "google_apis/gcm/engine/fake_connection_factory.h" |
15 #include "google_apis/gcm/engine/fake_connection_handler.h" | 15 #include "google_apis/gcm/engine/fake_connection_handler.h" |
| 16 #include "google_apis/gcm/gcm_stats_recorder.h" |
16 #include "google_apis/gcm/protocol/android_checkin.pb.h" | 17 #include "google_apis/gcm/protocol/android_checkin.pb.h" |
17 #include "google_apis/gcm/protocol/checkin.pb.h" | 18 #include "google_apis/gcm/protocol/checkin.pb.h" |
18 #include "google_apis/gcm/protocol/mcs.pb.h" | 19 #include "google_apis/gcm/protocol/mcs.pb.h" |
19 #include "net/url_request/test_url_fetcher_factory.h" | 20 #include "net/url_request/test_url_fetcher_factory.h" |
20 #include "net/url_request/url_fetcher_delegate.h" | 21 #include "net/url_request/url_fetcher_delegate.h" |
21 #include "net/url_request/url_request_test_util.h" | 22 #include "net/url_request/url_request_test_util.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 | 24 |
24 namespace gcm { | 25 namespace gcm { |
25 | 26 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 uint8 last_message_tag() const { return last_message_tag_; } | 73 uint8 last_message_tag() const { return last_message_tag_; } |
73 const mcs_proto::DataMessageStanza& last_data_message_stanza() const { | 74 const mcs_proto::DataMessageStanza& last_data_message_stanza() const { |
74 return last_data_message_stanza_; | 75 return last_data_message_stanza_; |
75 } | 76 } |
76 | 77 |
77 private: | 78 private: |
78 uint64 last_android_id_; | 79 uint64 last_android_id_; |
79 uint64 last_security_token_; | 80 uint64 last_security_token_; |
80 uint8 last_message_tag_; | 81 uint8 last_message_tag_; |
81 mcs_proto::DataMessageStanza last_data_message_stanza_; | 82 mcs_proto::DataMessageStanza last_data_message_stanza_; |
| 83 gcm::GCMStatsRecorder recorder_; |
82 }; | 84 }; |
83 | 85 |
84 FakeMCSClient::FakeMCSClient(base::Clock* clock, | 86 FakeMCSClient::FakeMCSClient(base::Clock* clock, |
85 ConnectionFactory* connection_factory) | 87 ConnectionFactory* connection_factory) |
86 : MCSClient("", clock, connection_factory, NULL), | 88 : MCSClient("", clock, connection_factory, NULL, & recorder_), |
87 last_android_id_(0u), | 89 last_android_id_(0u), |
88 last_security_token_(0u), | 90 last_security_token_(0u), |
89 last_message_tag_(kNumProtoTypes) { | 91 last_message_tag_(kNumProtoTypes) { |
90 } | 92 } |
91 | 93 |
92 FakeMCSClient::~FakeMCSClient() { | 94 FakeMCSClient::~FakeMCSClient() { |
93 } | 95 } |
94 | 96 |
95 void FakeMCSClient::set_gcm_store(GCMStore* gcm_store) { | 97 void FakeMCSClient::set_gcm_store(GCMStore* gcm_store) { |
96 SetGCMStoreForTesting(gcm_store); | 98 SetGCMStoreForTesting(gcm_store); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 EXPECT_EQ(CurrentTime(), mcs_client()->last_data_message_stanza().sent()); | 456 EXPECT_EQ(CurrentTime(), mcs_client()->last_data_message_stanza().sent()); |
455 EXPECT_EQ("007", mcs_client()->last_data_message_stanza().id()); | 457 EXPECT_EQ("007", mcs_client()->last_data_message_stanza().id()); |
456 EXPECT_EQ("gcm@chrome.com", mcs_client()->last_data_message_stanza().from()); | 458 EXPECT_EQ("gcm@chrome.com", mcs_client()->last_data_message_stanza().from()); |
457 EXPECT_EQ("project_id", mcs_client()->last_data_message_stanza().to()); | 459 EXPECT_EQ("project_id", mcs_client()->last_data_message_stanza().to()); |
458 EXPECT_EQ("key", mcs_client()->last_data_message_stanza().app_data(0).key()); | 460 EXPECT_EQ("key", mcs_client()->last_data_message_stanza().app_data(0).key()); |
459 EXPECT_EQ("value", | 461 EXPECT_EQ("value", |
460 mcs_client()->last_data_message_stanza().app_data(0).value()); | 462 mcs_client()->last_data_message_stanza().app_data(0).value()); |
461 } | 463 } |
462 | 464 |
463 } // namespace gcm | 465 } // namespace gcm |
OLD | NEW |