OLD | NEW |
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 "google_apis/gcm/base/fake_encryptor.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" | 18 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 namespace gcm { | 21 namespace gcm { |
22 | 22 |
23 namespace { | 23 namespace { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 run_loop_.reset(new base::RunLoop()); | 152 run_loop_.reset(new base::RunLoop()); |
153 | 153 |
154 // Advance the clock to a non-zero time. | 154 // Advance the clock to a non-zero time. |
155 clock_.Advance(base::TimeDelta::FromSeconds(1)); | 155 clock_.Advance(base::TimeDelta::FromSeconds(1)); |
156 } | 156 } |
157 | 157 |
158 MCSClientTest::~MCSClientTest() {} | 158 MCSClientTest::~MCSClientTest() {} |
159 | 159 |
160 void MCSClientTest::SetUp() { | 160 void MCSClientTest::SetUp() { |
161 testing::Test::SetUp(); | 161 testing::Test::SetUp(); |
| 162 #if defined(OS_MACOSX) |
| 163 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 164 os_crypt::switches::kUseMockKeychain); |
| 165 #endif // OS_MACOSX |
162 } | 166 } |
163 | 167 |
164 void MCSClientTest::BuildMCSClient() { | 168 void MCSClientTest::BuildMCSClient() { |
165 gcm_store_.reset(new GCMStoreImpl( | 169 gcm_store_.reset(new GCMStoreImpl(temp_directory_.path(), |
166 temp_directory_.path(), | 170 message_loop_.message_loop_proxy())); |
167 message_loop_.message_loop_proxy(), | |
168 make_scoped_ptr<Encryptor>(new FakeEncryptor))); | |
169 mcs_client_.reset(new TestMCSClient(&clock_, | 171 mcs_client_.reset(new TestMCSClient(&clock_, |
170 &connection_factory_, | 172 &connection_factory_, |
171 gcm_store_.get(), | 173 gcm_store_.get(), |
172 &recorder_)); | 174 &recorder_)); |
173 } | 175 } |
174 | 176 |
175 void MCSClientTest::InitializeClient() { | 177 void MCSClientTest::InitializeClient() { |
176 gcm_store_->Load(base::Bind( | 178 gcm_store_->Load(base::Bind( |
177 &MCSClient::Initialize, | 179 &MCSClient::Initialize, |
178 base::Unretained(mcs_client_.get()), | 180 base::Unretained(mcs_client_.get()), |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 | 792 |
791 LoginClient(std::vector<std::string>()); | 793 LoginClient(std::vector<std::string>()); |
792 GetFakeHandler()->ExpectOutgoingMessage(message); | 794 GetFakeHandler()->ExpectOutgoingMessage(message); |
793 GetFakeHandler()->ExpectOutgoingMessage(message2); | 795 GetFakeHandler()->ExpectOutgoingMessage(message2); |
794 PumpLoop(); | 796 PumpLoop(); |
795 } | 797 } |
796 | 798 |
797 } // namespace | 799 } // namespace |
798 | 800 |
799 } // namespace gcm | 801 } // namespace gcm |
OLD | NEW |