| 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 30 matching lines...) Expand all Loading... |
| 41 const char kTestAppID1[] = "TestApp1"; | 41 const char kTestAppID1[] = "TestApp1"; |
| 42 const char kTestAppID2[] = "TestApp2"; | 42 const char kTestAppID2[] = "TestApp2"; |
| 43 const char kUserID1[] = "user1"; | 43 const char kUserID1[] = "user1"; |
| 44 | 44 |
| 45 class FakeGCMConnectionObserver : public GCMConnectionObserver { | 45 class FakeGCMConnectionObserver : public GCMConnectionObserver { |
| 46 public: | 46 public: |
| 47 FakeGCMConnectionObserver(); | 47 FakeGCMConnectionObserver(); |
| 48 virtual ~FakeGCMConnectionObserver(); | 48 virtual ~FakeGCMConnectionObserver(); |
| 49 | 49 |
| 50 // gcm::GCMConnectionObserver implementation: | 50 // gcm::GCMConnectionObserver implementation: |
| 51 virtual void OnConnected(const net::IPEndPoint& ip_endpoint) OVERRIDE; | 51 virtual void OnConnected(const net::IPEndPoint& ip_endpoint) override; |
| 52 virtual void OnDisconnected() OVERRIDE; | 52 virtual void OnDisconnected() override; |
| 53 | 53 |
| 54 bool connected() const { return connected_; } | 54 bool connected() const { return connected_; } |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 bool connected_; | 57 bool connected_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 FakeGCMConnectionObserver::FakeGCMConnectionObserver() : connected_(false) { | 60 FakeGCMConnectionObserver::FakeGCMConnectionObserver() : connected_(false) { |
| 61 } | 61 } |
| 62 | 62 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 public: | 94 public: |
| 95 enum WaitToFinish { | 95 enum WaitToFinish { |
| 96 DO_NOT_WAIT, | 96 DO_NOT_WAIT, |
| 97 WAIT | 97 WAIT |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 GCMDriverTest(); | 100 GCMDriverTest(); |
| 101 virtual ~GCMDriverTest(); | 101 virtual ~GCMDriverTest(); |
| 102 | 102 |
| 103 // testing::Test: | 103 // testing::Test: |
| 104 virtual void SetUp() OVERRIDE; | 104 virtual void SetUp() override; |
| 105 virtual void TearDown() OVERRIDE; | 105 virtual void TearDown() override; |
| 106 | 106 |
| 107 GCMDriverDesktop* driver() { return driver_.get(); } | 107 GCMDriverDesktop* driver() { return driver_.get(); } |
| 108 FakeGCMAppHandler* gcm_app_handler() { return gcm_app_handler_.get(); } | 108 FakeGCMAppHandler* gcm_app_handler() { return gcm_app_handler_.get(); } |
| 109 FakeGCMConnectionObserver* gcm_connection_observer() { | 109 FakeGCMConnectionObserver* gcm_connection_observer() { |
| 110 return gcm_connection_observer_.get(); | 110 return gcm_connection_observer_.get(); |
| 111 } | 111 } |
| 112 const std::string& registration_id() const { return registration_id_; } | 112 const std::string& registration_id() const { return registration_id_; } |
| 113 GCMClient::Result registration_result() const { return registration_result_; } | 113 GCMClient::Result registration_result() const { return registration_result_; } |
| 114 const std::string& send_message_id() const { return send_message_id_; } | 114 const std::string& send_message_id() const { return send_message_id_; } |
| 115 GCMClient::Result send_result() const { return send_result_; } | 115 GCMClient::Result send_result() const { return send_result_; } |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 EXPECT_EQ(GCMClient::SUCCESS, send_result()); | 658 EXPECT_EQ(GCMClient::SUCCESS, send_result()); |
| 659 } | 659 } |
| 660 | 660 |
| 661 // Tests a single instance of GCMDriver. | 661 // Tests a single instance of GCMDriver. |
| 662 class GCMDriverFunctionalTest : public GCMDriverTest { | 662 class GCMDriverFunctionalTest : public GCMDriverTest { |
| 663 public: | 663 public: |
| 664 GCMDriverFunctionalTest(); | 664 GCMDriverFunctionalTest(); |
| 665 virtual ~GCMDriverFunctionalTest(); | 665 virtual ~GCMDriverFunctionalTest(); |
| 666 | 666 |
| 667 // GCMDriverTest: | 667 // GCMDriverTest: |
| 668 virtual void SetUp() OVERRIDE; | 668 virtual void SetUp() override; |
| 669 | 669 |
| 670 private: | 670 private: |
| 671 DISALLOW_COPY_AND_ASSIGN(GCMDriverFunctionalTest); | 671 DISALLOW_COPY_AND_ASSIGN(GCMDriverFunctionalTest); |
| 672 }; | 672 }; |
| 673 | 673 |
| 674 GCMDriverFunctionalTest::GCMDriverFunctionalTest() { | 674 GCMDriverFunctionalTest::GCMDriverFunctionalTest() { |
| 675 } | 675 } |
| 676 | 676 |
| 677 GCMDriverFunctionalTest::~GCMDriverFunctionalTest() { | 677 GCMDriverFunctionalTest::~GCMDriverFunctionalTest() { |
| 678 } | 678 } |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 EXPECT_EQ(kTestAppID1, gcm_app_handler()->app_id()); | 943 EXPECT_EQ(kTestAppID1, gcm_app_handler()->app_id()); |
| 944 } | 944 } |
| 945 | 945 |
| 946 // Tests a single instance of GCMDriver. | 946 // Tests a single instance of GCMDriver. |
| 947 class GCMChannelStatusSyncerTest : public GCMDriverTest { | 947 class GCMChannelStatusSyncerTest : public GCMDriverTest { |
| 948 public: | 948 public: |
| 949 GCMChannelStatusSyncerTest(); | 949 GCMChannelStatusSyncerTest(); |
| 950 virtual ~GCMChannelStatusSyncerTest(); | 950 virtual ~GCMChannelStatusSyncerTest(); |
| 951 | 951 |
| 952 // testing::Test: | 952 // testing::Test: |
| 953 virtual void SetUp() OVERRIDE; | 953 virtual void SetUp() override; |
| 954 | 954 |
| 955 void CompleteGCMChannelStatusRequest(bool enabled, int poll_interval_seconds); | 955 void CompleteGCMChannelStatusRequest(bool enabled, int poll_interval_seconds); |
| 956 bool CompareDelaySeconds(bool expected_delay_seconds, | 956 bool CompareDelaySeconds(bool expected_delay_seconds, |
| 957 bool actual_delay_seconds); | 957 bool actual_delay_seconds); |
| 958 | 958 |
| 959 GCMChannelStatusSyncer* syncer() { | 959 GCMChannelStatusSyncer* syncer() { |
| 960 return driver()->gcm_channel_status_syncer_for_testing(); | 960 return driver()->gcm_channel_status_syncer_for_testing(); |
| 961 } | 961 } |
| 962 | 962 |
| 963 private: | 963 private: |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 // After start-up, the request should still be scheduled at the expected | 1180 // After start-up, the request should still be scheduled at the expected |
| 1181 // updated interval. | 1181 // updated interval. |
| 1182 actual_delay_seconds = | 1182 actual_delay_seconds = |
| 1183 syncer()->current_request_delay_interval().InSeconds(); | 1183 syncer()->current_request_delay_interval().InSeconds(); |
| 1184 EXPECT_TRUE(CompareDelaySeconds(expected_delay_seconds, actual_delay_seconds)) | 1184 EXPECT_TRUE(CompareDelaySeconds(expected_delay_seconds, actual_delay_seconds)) |
| 1185 << "expected delay: " << expected_delay_seconds | 1185 << "expected delay: " << expected_delay_seconds |
| 1186 << " actual delay: " << actual_delay_seconds; | 1186 << " actual delay: " << actual_delay_seconds; |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 } // namespace gcm | 1189 } // namespace gcm |
| OLD | NEW |