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 "components/gcm_driver/gcm_driver_desktop.h" | 5 #include "components/gcm_driver/gcm_driver_desktop.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } // namespace | 92 } // namespace |
93 | 93 |
94 class GCMDriverTest : public testing::Test { | 94 class GCMDriverTest : public testing::Test { |
95 public: | 95 public: |
96 enum WaitToFinish { | 96 enum WaitToFinish { |
97 DO_NOT_WAIT, | 97 DO_NOT_WAIT, |
98 WAIT | 98 WAIT |
99 }; | 99 }; |
100 | 100 |
101 GCMDriverTest(); | 101 GCMDriverTest(); |
102 virtual ~GCMDriverTest(); | 102 ~GCMDriverTest() override; |
103 | 103 |
104 // testing::Test: | 104 // testing::Test: |
105 virtual void SetUp() override; | 105 void SetUp() override; |
106 virtual void TearDown() override; | 106 void TearDown() override; |
107 | 107 |
108 GCMDriverDesktop* driver() { return driver_.get(); } | 108 GCMDriverDesktop* driver() { return driver_.get(); } |
109 FakeGCMAppHandler* gcm_app_handler() { return gcm_app_handler_.get(); } | 109 FakeGCMAppHandler* gcm_app_handler() { return gcm_app_handler_.get(); } |
110 FakeGCMConnectionObserver* gcm_connection_observer() { | 110 FakeGCMConnectionObserver* gcm_connection_observer() { |
111 return gcm_connection_observer_.get(); | 111 return gcm_connection_observer_.get(); |
112 } | 112 } |
113 const std::string& registration_id() const { return registration_id_; } | 113 const std::string& registration_id() const { return registration_id_; } |
114 GCMClient::Result registration_result() const { return registration_result_; } | 114 GCMClient::Result registration_result() const { return registration_result_; } |
115 const std::string& send_message_id() const { return send_message_id_; } | 115 const std::string& send_message_id() const { return send_message_id_; } |
116 GCMClient::Result send_result() const { return send_result_; } | 116 GCMClient::Result send_result() const { return send_result_; } |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 GetGCMClient()->PerformDelayedLoading(); | 674 GetGCMClient()->PerformDelayedLoading(); |
675 WaitForAsyncOperation(); | 675 WaitForAsyncOperation(); |
676 EXPECT_EQ(message.id, send_message_id()); | 676 EXPECT_EQ(message.id, send_message_id()); |
677 EXPECT_EQ(GCMClient::SUCCESS, send_result()); | 677 EXPECT_EQ(GCMClient::SUCCESS, send_result()); |
678 } | 678 } |
679 | 679 |
680 // Tests a single instance of GCMDriver. | 680 // Tests a single instance of GCMDriver. |
681 class GCMDriverFunctionalTest : public GCMDriverTest { | 681 class GCMDriverFunctionalTest : public GCMDriverTest { |
682 public: | 682 public: |
683 GCMDriverFunctionalTest(); | 683 GCMDriverFunctionalTest(); |
684 virtual ~GCMDriverFunctionalTest(); | 684 ~GCMDriverFunctionalTest() override; |
685 | 685 |
686 // GCMDriverTest: | 686 // GCMDriverTest: |
687 virtual void SetUp() override; | 687 void SetUp() override; |
688 | 688 |
689 private: | 689 private: |
690 DISALLOW_COPY_AND_ASSIGN(GCMDriverFunctionalTest); | 690 DISALLOW_COPY_AND_ASSIGN(GCMDriverFunctionalTest); |
691 }; | 691 }; |
692 | 692 |
693 GCMDriverFunctionalTest::GCMDriverFunctionalTest() { | 693 GCMDriverFunctionalTest::GCMDriverFunctionalTest() { |
694 } | 694 } |
695 | 695 |
696 GCMDriverFunctionalTest::~GCMDriverFunctionalTest() { | 696 GCMDriverFunctionalTest::~GCMDriverFunctionalTest() { |
697 } | 697 } |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 gcm_app_handler()->WaitForNotification(); | 982 gcm_app_handler()->WaitForNotification(); |
983 EXPECT_EQ(FakeGCMAppHandler::MESSAGES_DELETED_EVENT, | 983 EXPECT_EQ(FakeGCMAppHandler::MESSAGES_DELETED_EVENT, |
984 gcm_app_handler()->received_event()); | 984 gcm_app_handler()->received_event()); |
985 EXPECT_EQ(kTestAppID1, gcm_app_handler()->app_id()); | 985 EXPECT_EQ(kTestAppID1, gcm_app_handler()->app_id()); |
986 } | 986 } |
987 | 987 |
988 // Tests a single instance of GCMDriver. | 988 // Tests a single instance of GCMDriver. |
989 class GCMChannelStatusSyncerTest : public GCMDriverTest { | 989 class GCMChannelStatusSyncerTest : public GCMDriverTest { |
990 public: | 990 public: |
991 GCMChannelStatusSyncerTest(); | 991 GCMChannelStatusSyncerTest(); |
992 virtual ~GCMChannelStatusSyncerTest(); | 992 ~GCMChannelStatusSyncerTest() override; |
993 | 993 |
994 // testing::Test: | 994 // testing::Test: |
995 virtual void SetUp() override; | 995 void SetUp() override; |
996 | 996 |
997 void CompleteGCMChannelStatusRequest(bool enabled, int poll_interval_seconds); | 997 void CompleteGCMChannelStatusRequest(bool enabled, int poll_interval_seconds); |
998 bool CompareDelaySeconds(bool expected_delay_seconds, | 998 bool CompareDelaySeconds(bool expected_delay_seconds, |
999 bool actual_delay_seconds); | 999 bool actual_delay_seconds); |
1000 | 1000 |
1001 GCMChannelStatusSyncer* syncer() { | 1001 GCMChannelStatusSyncer* syncer() { |
1002 return driver()->gcm_channel_status_syncer_for_testing(); | 1002 return driver()->gcm_channel_status_syncer_for_testing(); |
1003 } | 1003 } |
1004 | 1004 |
1005 private: | 1005 private: |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 // After start-up, the request should still be scheduled at the expected | 1238 // After start-up, the request should still be scheduled at the expected |
1239 // updated interval. | 1239 // updated interval. |
1240 actual_delay_seconds = | 1240 actual_delay_seconds = |
1241 syncer()->current_request_delay_interval().InSeconds(); | 1241 syncer()->current_request_delay_interval().InSeconds(); |
1242 EXPECT_TRUE(CompareDelaySeconds(expected_delay_seconds, actual_delay_seconds)) | 1242 EXPECT_TRUE(CompareDelaySeconds(expected_delay_seconds, actual_delay_seconds)) |
1243 << "expected delay: " << expected_delay_seconds | 1243 << "expected delay: " << expected_delay_seconds |
1244 << " actual delay: " << actual_delay_seconds; | 1244 << " actual delay: " << actual_delay_seconds; |
1245 } | 1245 } |
1246 | 1246 |
1247 } // namespace gcm | 1247 } // namespace gcm |
OLD | NEW |