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/encryptor.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/protocol/android_checkin.pb.h" | 16 #include "google_apis/gcm/protocol/android_checkin.pb.h" |
17 #include "google_apis/gcm/protocol/checkin.pb.h" | 17 #include "google_apis/gcm/protocol/checkin.pb.h" |
18 #include "google_apis/gcm/protocol/mcs.pb.h" | 18 #include "google_apis/gcm/protocol/mcs.pb.h" |
19 #include "net/url_request/test_url_fetcher_factory.h" | 19 #include "net/url_request/test_url_fetcher_factory.h" |
20 #include "net/url_request/url_fetcher_delegate.h" | 20 #include "net/url_request/url_fetcher_delegate.h" |
21 #include "net/url_request/url_request_test_util.h" | 21 #include "net/url_request/url_request_test_util.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 checkin_proto::ChromeBuildProto chrome_build_proto; | 280 checkin_proto::ChromeBuildProto chrome_build_proto; |
281 gcm_client_->Initialize(chrome_build_proto, | 281 gcm_client_->Initialize(chrome_build_proto, |
282 temp_directory_.path(), | 282 temp_directory_.path(), |
283 std::vector<std::string>(), | 283 std::vector<std::string>(), |
284 message_loop_.message_loop_proxy(), | 284 message_loop_.message_loop_proxy(), |
285 url_request_context_getter_, | 285 url_request_context_getter_, |
286 this); | 286 this); |
287 | 287 |
288 #if defined(OS_MACOSX) | 288 #if defined(OS_MACOSX) |
289 // On OSX, prevent the Keychain permissions popup during unit tests. | 289 // On OSX, prevent the Keychain permissions popup during unit tests. |
290 Encryptor::UseMockKeychain(true); // Must be after Initialize. | 290 OSCrypt::UseMockKeychain(true); // Must be after Initialize. |
291 #endif | 291 #endif |
292 | 292 |
293 // Starting loading and check-in. | 293 // Starting loading and check-in. |
294 gcm_client_->Load(); | 294 gcm_client_->Load(); |
295 | 295 |
296 // Ensuring that mcs_client is using the same gcm_store as gcm_client. | 296 // Ensuring that mcs_client is using the same gcm_store as gcm_client. |
297 mcs_client()->set_gcm_store(gcm_client_->gcm_store_.get()); | 297 mcs_client()->set_gcm_store(gcm_client_->gcm_store_.get()); |
298 PumpLoopUntilIdle(); | 298 PumpLoopUntilIdle(); |
299 CompleteCheckin(kDeviceAndroidId, kDeviceSecurityToken); | 299 CompleteCheckin(kDeviceAndroidId, kDeviceSecurityToken); |
300 } | 300 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 EXPECT_EQ(CurrentTime(), mcs_client()->last_data_message_stanza().sent()); | 444 EXPECT_EQ(CurrentTime(), mcs_client()->last_data_message_stanza().sent()); |
445 EXPECT_EQ("007", mcs_client()->last_data_message_stanza().id()); | 445 EXPECT_EQ("007", mcs_client()->last_data_message_stanza().id()); |
446 EXPECT_EQ("gcm@chrome.com", mcs_client()->last_data_message_stanza().from()); | 446 EXPECT_EQ("gcm@chrome.com", mcs_client()->last_data_message_stanza().from()); |
447 EXPECT_EQ("project_id", mcs_client()->last_data_message_stanza().to()); | 447 EXPECT_EQ("project_id", mcs_client()->last_data_message_stanza().to()); |
448 EXPECT_EQ("key", mcs_client()->last_data_message_stanza().app_data(0).key()); | 448 EXPECT_EQ("key", mcs_client()->last_data_message_stanza().app_data(0).key()); |
449 EXPECT_EQ("value", | 449 EXPECT_EQ("value", |
450 mcs_client()->last_data_message_stanza().app_data(0).value()); | 450 mcs_client()->last_data_message_stanza().app_data(0).value()); |
451 } | 451 } |
452 | 452 |
453 } // namespace gcm | 453 } // namespace gcm |
OLD | NEW |