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

Side by Side Diff: google_apis/gcm/gcm_client_impl_unittest.cc

Issue 261853012: Componentize GCM Part 1: create GCM component and move some files over (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix trybot Created 6 years, 7 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
OLDNEW
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"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/time/clock.h" 12 #include "base/time/clock.h"
13 #include "components/os_crypt/os_crypt_switches.h" 13 #include "google_apis/gcm/base/fake_encryptor.h"
14 #include "google_apis/gcm/base/mcs_message.h" 14 #include "google_apis/gcm/base/mcs_message.h"
15 #include "google_apis/gcm/base/mcs_util.h" 15 #include "google_apis/gcm/base/mcs_util.h"
16 #include "google_apis/gcm/engine/fake_connection_factory.h" 16 #include "google_apis/gcm/engine/fake_connection_factory.h"
17 #include "google_apis/gcm/engine/fake_connection_handler.h" 17 #include "google_apis/gcm/engine/fake_connection_handler.h"
18 #include "google_apis/gcm/engine/gservices_settings.h" 18 #include "google_apis/gcm/engine/gservices_settings.h"
19 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" 19 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
20 #include "google_apis/gcm/protocol/android_checkin.pb.h" 20 #include "google_apis/gcm/protocol/android_checkin.pb.h"
21 #include "google_apis/gcm/protocol/checkin.pb.h" 21 #include "google_apis/gcm/protocol/checkin.pb.h"
22 #include "google_apis/gcm/protocol/mcs.pb.h" 22 #include "google_apis/gcm/protocol/mcs.pb.h"
23 #include "net/url_request/test_url_fetcher_factory.h" 23 #include "net/url_request/test_url_fetcher_factory.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 : last_event_(NONE), 322 : last_event_(NONE),
323 last_result_(GCMClient::UNKNOWN_ERROR), 323 last_result_(GCMClient::UNKNOWN_ERROR),
324 url_request_context_getter_(new net::TestURLRequestContextGetter( 324 url_request_context_getter_(new net::TestURLRequestContextGetter(
325 message_loop_.message_loop_proxy())) { 325 message_loop_.message_loop_proxy())) {
326 } 326 }
327 327
328 GCMClientImplTest::~GCMClientImplTest() {} 328 GCMClientImplTest::~GCMClientImplTest() {}
329 329
330 void GCMClientImplTest::SetUp() { 330 void GCMClientImplTest::SetUp() {
331 testing::Test::SetUp(); 331 testing::Test::SetUp();
332 #if defined(OS_MACOSX)
333 base::CommandLine::ForCurrentProcess()->AppendSwitch(
334 os_crypt::switches::kUseMockKeychain);
335 #endif // OS_MACOSX
336 ASSERT_TRUE(CreateUniqueTempDir()); 332 ASSERT_TRUE(CreateUniqueTempDir());
337 InitializeLoop(); 333 InitializeLoop();
338 BuildGCMClient(base::TimeDelta()); 334 BuildGCMClient(base::TimeDelta());
339 InitializeGCMClient(); 335 InitializeGCMClient();
340 CompleteCheckin(kDeviceAndroidId, 336 CompleteCheckin(kDeviceAndroidId,
341 kDeviceSecurityToken, 337 kDeviceSecurityToken,
342 std::string(), 338 std::string(),
343 std::map<std::string, std::string>()); 339 std::map<std::string, std::string>());
344 } 340 }
345 341
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 void GCMClientImplTest::InitializeGCMClient() { 442 void GCMClientImplTest::InitializeGCMClient() {
447 clock()->Advance(base::TimeDelta::FromMilliseconds(1)); 443 clock()->Advance(base::TimeDelta::FromMilliseconds(1));
448 444
449 // Actual initialization. 445 // Actual initialization.
450 checkin_proto::ChromeBuildProto chrome_build_proto; 446 checkin_proto::ChromeBuildProto chrome_build_proto;
451 gcm_client_->Initialize(chrome_build_proto, 447 gcm_client_->Initialize(chrome_build_proto,
452 temp_directory_.path(), 448 temp_directory_.path(),
453 std::vector<std::string>(), 449 std::vector<std::string>(),
454 message_loop_.message_loop_proxy(), 450 message_loop_.message_loop_proxy(),
455 url_request_context_getter_, 451 url_request_context_getter_,
452 make_scoped_ptr<Encryptor>(new FakeEncryptor),
456 this); 453 this);
457 454
458 // Start loading and check-in. 455 // Start loading and check-in.
459 gcm_client_->Load(); 456 gcm_client_->Load();
460 457
461 PumpLoopUntilIdle(); 458 PumpLoopUntilIdle();
462 } 459 }
463 460
464 void GCMClientImplTest::ReceiveMessageFromMCS(const MCSMessage& message) { 461 void GCMClientImplTest::ReceiveMessageFromMCS(const MCSMessage& message) {
465 gcm_client_->OnMessageReceivedFromMCS(message); 462 gcm_client_->OnMessageReceivedFromMCS(message);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 }; 691 };
695 692
696 GCMClientImplCheckinTest::GCMClientImplCheckinTest() { 693 GCMClientImplCheckinTest::GCMClientImplCheckinTest() {
697 } 694 }
698 695
699 GCMClientImplCheckinTest::~GCMClientImplCheckinTest() { 696 GCMClientImplCheckinTest::~GCMClientImplCheckinTest() {
700 } 697 }
701 698
702 void GCMClientImplCheckinTest::SetUp() { 699 void GCMClientImplCheckinTest::SetUp() {
703 testing::Test::SetUp(); 700 testing::Test::SetUp();
704 #if defined(OS_MACOSX)
705 base::CommandLine::ForCurrentProcess()->AppendSwitch(
706 os_crypt::switches::kUseMockKeychain);
707 #endif // OS_MACOSX
708 // Creating unique temp directory that will be used by GCMStore shared between 701 // Creating unique temp directory that will be used by GCMStore shared between
709 // GCM Client and G-services settings. 702 // GCM Client and G-services settings.
710 ASSERT_TRUE(CreateUniqueTempDir()); 703 ASSERT_TRUE(CreateUniqueTempDir());
711 InitializeLoop(); 704 InitializeLoop();
712 // Time will be advancing one hour every time it is checked. 705 // Time will be advancing one hour every time it is checked.
713 BuildGCMClient(base::TimeDelta::FromSeconds(kSettingsCheckinInterval)); 706 BuildGCMClient(base::TimeDelta::FromSeconds(kSettingsCheckinInterval));
714 InitializeGCMClient(); 707 InitializeGCMClient();
715 } 708 }
716 709
717 TEST_F(GCMClientImplCheckinTest, GServicesSettingsAfterInitialCheckin) { 710 TEST_F(GCMClientImplCheckinTest, GServicesSettingsAfterInitialCheckin) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 gservices_settings().checkin_interval()); 760 gservices_settings().checkin_interval());
768 EXPECT_EQ(GURL("http://alternative.url/checkin"), 761 EXPECT_EQ(GURL("http://alternative.url/checkin"),
769 gservices_settings().checkin_url()); 762 gservices_settings().checkin_url());
770 EXPECT_EQ(GURL("http://alternative.url/registration"), 763 EXPECT_EQ(GURL("http://alternative.url/registration"),
771 gservices_settings().registration_url()); 764 gservices_settings().registration_url());
772 EXPECT_EQ("http://alternative.gcm.host", gservices_settings().mcs_hostname()); 765 EXPECT_EQ("http://alternative.gcm.host", gservices_settings().mcs_hostname());
773 EXPECT_EQ(443, gservices_settings().mcs_secure_port()); 766 EXPECT_EQ(443, gservices_settings().mcs_secure_port());
774 } 767 }
775 768
776 } // namespace gcm 769 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698