Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(714)

Side by Side Diff: trunk/src/google_apis/gcm/engine/mcs_client_unittest.cc

Issue 240583002: Revert 264313 "Add activity recording capability to gcm internal..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/google_apis/gcm/engine/mcs_client.cc ('k') | trunk/src/google_apis/gcm/gcm.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/mcs_client.h" 5 #include "google_apis/gcm/engine/mcs_client.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"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/test/simple_test_clock.h" 12 #include "base/test/simple_test_clock.h"
13 #include "components/os_crypt/os_crypt_switches.h" 13 #include "components/os_crypt/os_crypt_switches.h"
14 #include "google_apis/gcm/base/mcs_util.h" 14 #include "google_apis/gcm/base/mcs_util.h"
15 #include "google_apis/gcm/engine/fake_connection_factory.h" 15 #include "google_apis/gcm/engine/fake_connection_factory.h"
16 #include "google_apis/gcm/engine/fake_connection_handler.h" 16 #include "google_apis/gcm/engine/fake_connection_handler.h"
17 #include "google_apis/gcm/engine/gcm_store_impl.h" 17 #include "google_apis/gcm/engine/gcm_store_impl.h"
18 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
19 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
20 19
21 namespace gcm { 20 namespace gcm {
22 21
23 namespace { 22 namespace {
24 23
25 const uint64 kAndroidId = 54321; 24 const uint64 kAndroidId = 54321;
26 const uint64 kSecurityToken = 12345; 25 const uint64 kSecurityToken = 12345;
27 26
28 // Number of messages to send when testing batching. 27 // Number of messages to send when testing batching.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 data_message.set_token(token); 60 data_message.set_token(token);
62 data_message.set_device_user_id(user_id); 61 data_message.set_device_user_id(user_id);
63 return MCSMessage(kDataMessageStanzaTag, data_message); 62 return MCSMessage(kDataMessageStanzaTag, data_message);
64 } 63 }
65 64
66 // MCSClient with overriden exposed persistent id logic. 65 // MCSClient with overriden exposed persistent id logic.
67 class TestMCSClient : public MCSClient { 66 class TestMCSClient : public MCSClient {
68 public: 67 public:
69 TestMCSClient(base::Clock* clock, 68 TestMCSClient(base::Clock* clock,
70 ConnectionFactory* connection_factory, 69 ConnectionFactory* connection_factory,
71 GCMStore* gcm_store, 70 GCMStore* gcm_store)
72 gcm::GCMStatsRecorder* recorder) 71 : MCSClient("", clock, connection_factory, gcm_store),
73 : MCSClient("", clock, connection_factory, gcm_store, recorder),
74 next_id_(0) { 72 next_id_(0) {
75 } 73 }
76 74
77 virtual std::string GetNextPersistentId() OVERRIDE { 75 virtual std::string GetNextPersistentId() OVERRIDE {
78 return base::UintToString(++next_id_); 76 return base::UintToString(++next_id_);
79 } 77 }
80 78
81 private: 79 private:
82 uint32 next_id_; 80 uint32 next_id_;
83 }; 81 };
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 scoped_ptr<GCMStore> gcm_store_; 129 scoped_ptr<GCMStore> gcm_store_;
132 130
133 FakeConnectionFactory connection_factory_; 131 FakeConnectionFactory connection_factory_;
134 scoped_ptr<TestMCSClient> mcs_client_; 132 scoped_ptr<TestMCSClient> mcs_client_;
135 bool init_success_; 133 bool init_success_;
136 uint64 restored_android_id_; 134 uint64 restored_android_id_;
137 uint64 restored_security_token_; 135 uint64 restored_security_token_;
138 scoped_ptr<MCSMessage> received_message_; 136 scoped_ptr<MCSMessage> received_message_;
139 std::string sent_message_id_; 137 std::string sent_message_id_;
140 MCSClient::MessageSendStatus message_send_status_; 138 MCSClient::MessageSendStatus message_send_status_;
141
142 gcm::GCMStatsRecorder recorder_;
143 }; 139 };
144 140
145 MCSClientTest::MCSClientTest() 141 MCSClientTest::MCSClientTest()
146 : run_loop_(new base::RunLoop()), 142 : run_loop_(new base::RunLoop()),
147 init_success_(true), 143 init_success_(true),
148 restored_android_id_(0), 144 restored_android_id_(0),
149 restored_security_token_(0), 145 restored_security_token_(0),
150 message_send_status_(MCSClient::SENT) { 146 message_send_status_(MCSClient::SENT) {
151 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir()); 147 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir());
152 run_loop_.reset(new base::RunLoop()); 148 run_loop_.reset(new base::RunLoop());
(...skipping 10 matching lines...) Expand all
163 base::CommandLine::ForCurrentProcess()->AppendSwitch( 159 base::CommandLine::ForCurrentProcess()->AppendSwitch(
164 os_crypt::switches::kUseMockKeychain); 160 os_crypt::switches::kUseMockKeychain);
165 #endif // OS_MACOSX 161 #endif // OS_MACOSX
166 } 162 }
167 163
168 void MCSClientTest::BuildMCSClient() { 164 void MCSClientTest::BuildMCSClient() {
169 gcm_store_.reset(new GCMStoreImpl(temp_directory_.path(), 165 gcm_store_.reset(new GCMStoreImpl(temp_directory_.path(),
170 message_loop_.message_loop_proxy())); 166 message_loop_.message_loop_proxy()));
171 mcs_client_.reset(new TestMCSClient(&clock_, 167 mcs_client_.reset(new TestMCSClient(&clock_,
172 &connection_factory_, 168 &connection_factory_,
173 gcm_store_.get(), 169 gcm_store_.get()));
174 &recorder_));
175 } 170 }
176 171
177 void MCSClientTest::InitializeClient() { 172 void MCSClientTest::InitializeClient() {
178 gcm_store_->Load(base::Bind( 173 gcm_store_->Load(base::Bind(
179 &MCSClient::Initialize, 174 &MCSClient::Initialize,
180 base::Unretained(mcs_client_.get()), 175 base::Unretained(mcs_client_.get()),
181 base::Bind(&MCSClientTest::ErrorCallback, 176 base::Bind(&MCSClientTest::ErrorCallback,
182 base::Unretained(this)), 177 base::Unretained(this)),
183 base::Bind(&MCSClientTest::MessageReceivedCallback, 178 base::Bind(&MCSClientTest::MessageReceivedCallback,
184 base::Unretained(this)), 179 base::Unretained(this)),
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 787
793 LoginClient(std::vector<std::string>()); 788 LoginClient(std::vector<std::string>());
794 GetFakeHandler()->ExpectOutgoingMessage(message); 789 GetFakeHandler()->ExpectOutgoingMessage(message);
795 GetFakeHandler()->ExpectOutgoingMessage(message2); 790 GetFakeHandler()->ExpectOutgoingMessage(message2);
796 PumpLoop(); 791 PumpLoop();
797 } 792 }
798 793
799 } // namespace 794 } // namespace
800 795
801 } // namespace gcm 796 } // namespace gcm
OLDNEW
« no previous file with comments | « trunk/src/google_apis/gcm/engine/mcs_client.cc ('k') | trunk/src/google_apis/gcm/gcm.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698