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

Side by Side Diff: google_apis/gcm/engine/mcs_client_unittest.cc

Issue 1124783002: [GCM] Wiring heartbeat interval calls to GCMDriver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@store-heartbeat-gcm
Patch Set: Rebasing Created 5 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
OLDNEW
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/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 public: 106 public:
107 MCSClientTest(); 107 MCSClientTest();
108 ~MCSClientTest() override; 108 ~MCSClientTest() override;
109 109
110 void SetUp() override; 110 void SetUp() override;
111 111
112 void BuildMCSClient(); 112 void BuildMCSClient();
113 void InitializeClient(); 113 void InitializeClient();
114 void StoreCredentials(); 114 void StoreCredentials();
115 void LoginClient(const std::vector<std::string>& acknowledged_ids); 115 void LoginClient(const std::vector<std::string>& acknowledged_ids);
116 void LoginClientWithHeartbeat(
117 const std::vector<std::string>& acknowledged_ids,
118 int heartbeat_interval_ms);
116 void AddExpectedLoginRequest(const std::vector<std::string>& acknowledged_ids, 119 void AddExpectedLoginRequest(const std::vector<std::string>& acknowledged_ids,
117 int custom_heartbeat_interval); 120 int heartbeat_interval_ms);
118 121
119 base::SimpleTestClock* clock() { return &clock_; } 122 base::SimpleTestClock* clock() { return &clock_; }
120 TestMCSClient* mcs_client() const { return mcs_client_.get(); } 123 TestMCSClient* mcs_client() const { return mcs_client_.get(); }
121 FakeConnectionFactory* connection_factory() { 124 FakeConnectionFactory* connection_factory() {
122 return &connection_factory_; 125 return &connection_factory_;
123 } 126 }
124 bool init_success() const { return init_success_; } 127 bool init_success() const { return init_success_; }
125 uint64 restored_android_id() const { return restored_android_id_; } 128 uint64 restored_android_id() const { return restored_android_id_; }
126 uint64 restored_security_token() const { return restored_security_token_; } 129 uint64 restored_security_token() const { return restored_security_token_; }
127 MCSMessage* received_message() const { return received_message_.get(); } 130 MCSMessage* received_message() const { return received_message_.get(); }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 base::Unretained(this)), 205 base::Unretained(this)),
203 base::Bind(&MCSClientTest::MessageReceivedCallback, 206 base::Bind(&MCSClientTest::MessageReceivedCallback,
204 base::Unretained(this)), 207 base::Unretained(this)),
205 base::Bind(&MCSClientTest::MessageSentCallback, base::Unretained(this)))); 208 base::Bind(&MCSClientTest::MessageSentCallback, base::Unretained(this))));
206 run_loop_->RunUntilIdle(); 209 run_loop_->RunUntilIdle();
207 run_loop_.reset(new base::RunLoop()); 210 run_loop_.reset(new base::RunLoop());
208 } 211 }
209 212
210 void MCSClientTest::LoginClient( 213 void MCSClientTest::LoginClient(
211 const std::vector<std::string>& acknowledged_ids) { 214 const std::vector<std::string>& acknowledged_ids) {
212 AddExpectedLoginRequest(acknowledged_ids, 0); 215 LoginClientWithHeartbeat(acknowledged_ids, 0);
216 }
217
218 void MCSClientTest::LoginClientWithHeartbeat(
219 const std::vector<std::string>& acknowledged_ids,
220 int heartbeat_interval_ms) {
221 AddExpectedLoginRequest(acknowledged_ids, heartbeat_interval_ms);
213 mcs_client_->Login(kAndroidId, kSecurityToken); 222 mcs_client_->Login(kAndroidId, kSecurityToken);
214 run_loop_->Run(); 223 run_loop_->Run();
215 run_loop_.reset(new base::RunLoop()); 224 run_loop_.reset(new base::RunLoop());
216 } 225 }
217 226
218 void MCSClientTest::AddExpectedLoginRequest( 227 void MCSClientTest::AddExpectedLoginRequest(
219 const std::vector<std::string>& acknowledged_ids, 228 const std::vector<std::string>& acknowledged_ids,
220 int custom_heartbeat_interval) { 229 int heartbeat_interval_ms) {
221 scoped_ptr<mcs_proto::LoginRequest> login_request = 230 scoped_ptr<mcs_proto::LoginRequest> login_request =
222 BuildLoginRequest(kAndroidId, kSecurityToken, ""); 231 BuildLoginRequest(kAndroidId, kSecurityToken, "");
223 for (size_t i = 0; i < acknowledged_ids.size(); ++i) 232 for (size_t i = 0; i < acknowledged_ids.size(); ++i)
224 login_request->add_received_persistent_id(acknowledged_ids[i]); 233 login_request->add_received_persistent_id(acknowledged_ids[i]);
225 if (custom_heartbeat_interval) { 234 if (heartbeat_interval_ms) {
226 mcs_proto::Setting* setting = login_request->add_setting(); 235 mcs_proto::Setting* setting = login_request->add_setting();
227 setting->set_name("hbping"); 236 setting->set_name("hbping");
228 setting->set_value(base::IntToString(custom_heartbeat_interval)); 237 setting->set_value(base::IntToString(heartbeat_interval_ms));
229 } 238 }
230 GetFakeHandler()->ExpectOutgoingMessage( 239 GetFakeHandler()->ExpectOutgoingMessage(
231 MCSMessage(kLoginRequestTag, login_request.Pass())); 240 MCSMessage(kLoginRequestTag, login_request.Pass()));
232 } 241 }
233 242
234 void MCSClientTest::StoreCredentials() { 243 void MCSClientTest::StoreCredentials() {
235 gcm_store_->SetDeviceCredentials( 244 gcm_store_->SetDeviceCredentials(
236 kAndroidId, kSecurityToken, 245 kAndroidId, kSecurityToken,
237 base::Bind(&MCSClientTest::SetDeviceCredentialsCallback, 246 base::Bind(&MCSClientTest::SetDeviceCredentialsCallback,
238 base::Unretained(this))); 247 base::Unretained(this)));
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 "token", 900 "token",
892 1)); 901 1));
893 mcs_client()->SendMessage(message2); 902 mcs_client()->SendMessage(message2);
894 903
895 LoginClient(std::vector<std::string>()); 904 LoginClient(std::vector<std::string>());
896 GetFakeHandler()->ExpectOutgoingMessage(message); 905 GetFakeHandler()->ExpectOutgoingMessage(message);
897 GetFakeHandler()->ExpectOutgoingMessage(message2); 906 GetFakeHandler()->ExpectOutgoingMessage(message2);
898 PumpLoop(); 907 PumpLoop();
899 } 908 }
900 909
910 // Test case for setting a custom heartbeat interval, when it is too short.
911 // Covers both connection restart and storing of custom intervals.
912 TEST_F(MCSClientTest, CustomHeartbeatIntervalTooShort) {
913 BuildMCSClient();
914 InitializeClient();
915 LoginClient(std::vector<std::string>());
916 PumpLoop();
917 StoreCredentials();
918
919 HeartbeatManager* hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
920 // By default custom client interval is not set.
921 EXPECT_FALSE(hb_manager->HasClientHeartbeatInterval());
922
923 const std::string component_1 = "component1";
924 int interval_ms = 30 * 1000; // 30 seconds, too low.
925 mcs_client()->AddHeartbeatInterval(component_1, interval_ms);
926 // Setting was too low so it was ignored.
927 EXPECT_FALSE(hb_manager->HasClientHeartbeatInterval());
928
929 // Restore and check again to make sure that nothing was set in store.
930 BuildMCSClient();
931 InitializeClient();
932 LoginClientWithHeartbeat(std::vector<std::string>(), 0);
933 PumpLoop();
934
935 hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
936 EXPECT_FALSE(hb_manager->HasClientHeartbeatInterval());
937 }
938 \
Nicolas Zea 2015/05/13 17:57:37 remove \
fgorski 2015/05/13 18:59:16 Done.
939 // Test case for setting a custom heartbeat interval, when it is too long.
940 // Covers both connection restart and storing of custom intervals.
941 TEST_F(MCSClientTest, CustomHeartbeatIntervalTooLong) {
942 BuildMCSClient();
943 InitializeClient();
944 LoginClient(std::vector<std::string>());
945 PumpLoop();
946 StoreCredentials();
947
948 HeartbeatManager* hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
949
950 const std::string component_1 = "component1";
951 int interval_ms = 60 * 60 * 1000; // 1 hour, too high.
952 mcs_client()->AddHeartbeatInterval(component_1, interval_ms);
953 // Setting was too high, again it was ignored.
954 EXPECT_FALSE(hb_manager->HasClientHeartbeatInterval());
955
956 // Restore and check again to make sure that nothing was set in store.
957 BuildMCSClient();
958 InitializeClient();
959 LoginClientWithHeartbeat(std::vector<std::string>(), 0);
960 PumpLoop();
961
962 // Setting was too high, again it was ignored.
963 hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
964 EXPECT_FALSE(hb_manager->HasClientHeartbeatInterval());
965 }
966
901 // Tests adding and removing custom heartbeat interval. 967 // Tests adding and removing custom heartbeat interval.
902 TEST_F(MCSClientTest, CustomHeartbeatInterval) { 968 // Covers both connection restart and storing of custom intervals.
903 BuildMCSClient(); 969 TEST_F(MCSClientTest, CustomHeartbeatIntervalSingleInterval) {
904 InitializeClient(); 970 BuildMCSClient();
905 LoginClient(std::vector<std::string>()); 971 InitializeClient();
906 972 LoginClient(std::vector<std::string>());
907 TestConnectionListener test_connection_listener; 973 PumpLoop();
908 connection_factory()->SetConnectionListener(&test_connection_listener); 974 StoreCredentials();
909 975
910 HeartbeatManager& hb_manager = mcs_client()->GetHeartbeatManagerForTesting(); 976 TestConnectionListener test_connection_listener;
911 // By default custom client interval is not set. 977 connection_factory()->SetConnectionListener(&test_connection_listener);
912 EXPECT_FALSE(hb_manager.HasClientHeartbeatInterval()); 978
913 979 HeartbeatManager* hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
914 const std::string component_1 = "component1"; 980
915 int interval_ms = 30 * 1000; // 30 seconds, too low. 981 const std::string component_1 = "component1";
916 mcs_client()->AddHeartbeatInterval(component_1, interval_ms); 982 int interval_ms = 5 * 60 * 1000; // 5 minutes. A valid setting.
917 // Setting was too low so it was ignored. 983
918 EXPECT_FALSE(hb_manager.HasClientHeartbeatInterval()); 984 AddExpectedLoginRequest(std::vector<std::string>(), interval_ms);
919 985 mcs_client()->AddHeartbeatInterval(component_1, interval_ms);
920 interval_ms = 60 * 60 * 1000; // 1 hour, too high. 986 PumpLoop();
921 mcs_client()->AddHeartbeatInterval(component_1, interval_ms); 987
922 // Setting was too high, again it was ignored. 988 // Interval was OK. HearbeatManager should get that setting now.
923 EXPECT_FALSE(hb_manager.HasClientHeartbeatInterval()); 989 EXPECT_TRUE(hb_manager->HasClientHeartbeatInterval());
924 990 EXPECT_EQ(interval_ms, hb_manager->GetClientHeartbeatIntervalMs());
925 int expected_disconnect_counter = 0; 991 EXPECT_EQ(1, test_connection_listener.get_disconnect_counter());
926 EXPECT_EQ(expected_disconnect_counter, 992
927 test_connection_listener.get_disconnect_counter()); 993 // Check that setting was persisted and will take effect upon restart.
928 994 BuildMCSClient();
929 interval_ms = 5 * 60 * 1000; // 5 minutes. A valid setting. 995 InitializeClient();
930 AddExpectedLoginRequest(std::vector<std::string>(), interval_ms); 996 LoginClientWithHeartbeat(std::vector<std::string>(), interval_ms);
931 mcs_client()->AddHeartbeatInterval(component_1, interval_ms); 997 PumpLoop();
932 // Setting was OK. HearbeatManager should get that setting now. 998
933 EXPECT_TRUE(hb_manager.HasClientHeartbeatInterval()); 999 // HB manger uses the shortest persisted interval after restart.
934 EXPECT_EQ(interval_ms, hb_manager.GetClientHeartbeatIntervalMs()); 1000 hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
935 1001 EXPECT_TRUE(hb_manager->HasClientHeartbeatInterval());
936 ++expected_disconnect_counter; 1002 EXPECT_EQ(interval_ms, hb_manager->GetClientHeartbeatIntervalMs());
937 EXPECT_EQ(expected_disconnect_counter, 1003
938 test_connection_listener.get_disconnect_counter()); 1004 mcs_client()->RemoveHeartbeatInterval(component_1);
1005 PumpLoop();
1006
1007 // Check that setting was persisted and will take effect upon restart.
1008 BuildMCSClient();
1009 InitializeClient();
1010 LoginClientWithHeartbeat(std::vector<std::string>(), 0);
1011 PumpLoop();
1012
1013 hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
1014 EXPECT_FALSE(hb_manager->HasClientHeartbeatInterval());
1015 }
1016
1017 // Tests adding custom heartbeat interval before connection is initilaized.
Nicolas Zea 2015/05/13 17:57:37 nit: initialized
fgorski 2015/05/13 18:59:16 Done.
1018 TEST_F(MCSClientTest, CustomHeartbeatIntervalSetBeforeInitialize) {
1019 BuildMCSClient();
1020
1021 const std::string component_1 = "component1";
1022 int interval_ms = 5 * 60 * 1000; // 5 minutes. A valid setting.
1023 mcs_client()->AddHeartbeatInterval(component_1, interval_ms);
1024 InitializeClient();
1025 LoginClientWithHeartbeat(std::vector<std::string>(), interval_ms);
Nicolas Zea 2015/05/13 17:57:37 verify HasClientHeartbeatInterval (here and in the
fgorski 2015/05/13 18:59:16 Done. Added here and below. Other tests already ha
1026 }
1027
1028 // Tests adding custom heartbeat interval after connection is initialized, but
1029 // but before login is sent.
1030 TEST_F(MCSClientTest, CustomHeartbeatIntervalSetBeforeLogin) {
1031 BuildMCSClient();
1032
1033 const std::string component_1 = "component1";
1034 int interval_ms = 5 * 60 * 1000; // 5 minutes. A valid setting.
1035 InitializeClient();
1036 mcs_client()->AddHeartbeatInterval(component_1, interval_ms);
1037 LoginClientWithHeartbeat(std::vector<std::string>(), interval_ms);
1038 }
1039
1040 // Tests situation when two heartbeat intervals are set and second is longer.
1041 // Covers both connection restart and storing of custom intervals.
1042 TEST_F(MCSClientTest, CustomHeartbeatIntervalSecondIntervalLonger) {
1043 BuildMCSClient();
1044 InitializeClient();
1045 LoginClient(std::vector<std::string>());
1046 PumpLoop();
1047 StoreCredentials();
1048
1049 TestConnectionListener test_connection_listener;
1050 connection_factory()->SetConnectionListener(&test_connection_listener);
1051
1052 HeartbeatManager* hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
1053
1054 const std::string component_1 = "component1";
1055 int interval_ms = 5 * 60 * 1000; // 5 minutes. A valid setting.
1056
1057 AddExpectedLoginRequest(std::vector<std::string>(), interval_ms);
1058 mcs_client()->AddHeartbeatInterval(component_1, interval_ms);
1059 PumpLoop();
939 1060
940 const std::string component_2 = "component2"; 1061 const std::string component_2 = "component2";
941 int other_interval_ms = 10 * 60 * 1000; // 10 minutes. A valid setting. 1062 int other_interval_ms = 10 * 60 * 1000; // 10 minutes. A valid setting.
942 mcs_client()->AddHeartbeatInterval(component_2, other_interval_ms); 1063 mcs_client()->AddHeartbeatInterval(component_2, other_interval_ms);
943 // Setting was OK, but higher than the previous setting and HearbeatManager 1064 PumpLoop();
944 // will not be updated. 1065
945 EXPECT_TRUE(hb_manager.HasClientHeartbeatInterval()); 1066 // Interval was OK, but longer. HearbeatManager will use the first one.
946 EXPECT_EQ(interval_ms, hb_manager.GetClientHeartbeatIntervalMs()); 1067 EXPECT_TRUE(hb_manager->HasClientHeartbeatInterval());
947 // No connection reset expected. 1068 EXPECT_EQ(interval_ms, hb_manager->GetClientHeartbeatIntervalMs());
948 EXPECT_EQ(expected_disconnect_counter, 1069 EXPECT_EQ(1, test_connection_listener.get_disconnect_counter());
949 test_connection_listener.get_disconnect_counter()); 1070
950 1071 // Check that setting was persisted and will take effect upon restart.
951 other_interval_ms = 3 * 60 * 1000; // 3 minutes. A valid setting. 1072 BuildMCSClient();
1073 InitializeClient();
1074 LoginClientWithHeartbeat(std::vector<std::string>(), interval_ms);
1075 PumpLoop();
1076
1077 // HB manger uses the shortest persisted interval after restart.
1078 hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
1079 EXPECT_TRUE(hb_manager->HasClientHeartbeatInterval());
1080 EXPECT_EQ(interval_ms, hb_manager->GetClientHeartbeatIntervalMs());
1081 }
1082
1083 // Tests situation when two heartbeat intervals are set and second is shorter.
1084 // Covers both connection restart and storing of custom intervals.
1085 TEST_F(MCSClientTest, CustomHeartbeatIntervalSecondIntervalShorter) {
1086 BuildMCSClient();
1087 InitializeClient();
1088 LoginClient(std::vector<std::string>());
1089 PumpLoop();
1090 StoreCredentials();
1091
1092 TestConnectionListener test_connection_listener;
1093 connection_factory()->SetConnectionListener(&test_connection_listener);
1094
1095 HeartbeatManager* hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
1096
1097 const std::string component_1 = "component1";
1098 int interval_ms = 5 * 60 * 1000; // 5 minutes. A valid setting.
1099
1100 AddExpectedLoginRequest(std::vector<std::string>(), interval_ms);
1101 mcs_client()->AddHeartbeatInterval(component_1, interval_ms);
1102 PumpLoop();
1103
1104 const std::string component_2 = "component2";
1105 int other_interval_ms = 3 * 60 * 1000; // 3 minutes. A valid setting.
952 AddExpectedLoginRequest(std::vector<std::string>(), other_interval_ms); 1106 AddExpectedLoginRequest(std::vector<std::string>(), other_interval_ms);
953 mcs_client()->AddHeartbeatInterval(component_2, other_interval_ms); 1107 mcs_client()->AddHeartbeatInterval(component_2, other_interval_ms);
954 // Setting was OK and lower then present setting. HearbeatManager should get 1108 PumpLoop();
955 // that setting now. 1109 // Interval was OK. HearbeatManager should get that setting now.
956 EXPECT_TRUE(hb_manager.HasClientHeartbeatInterval()); 1110 EXPECT_TRUE(hb_manager->HasClientHeartbeatInterval());
957 EXPECT_EQ(other_interval_ms, hb_manager.GetClientHeartbeatIntervalMs()); 1111 EXPECT_EQ(other_interval_ms, hb_manager->GetClientHeartbeatIntervalMs());
958 ++expected_disconnect_counter; 1112 EXPECT_EQ(2, test_connection_listener.get_disconnect_counter());
959 EXPECT_EQ(expected_disconnect_counter, 1113
960 test_connection_listener.get_disconnect_counter()); 1114 // Check that setting was persisted and will take effect upon restart.
1115 BuildMCSClient();
1116 InitializeClient();
1117 LoginClientWithHeartbeat(std::vector<std::string>(), other_interval_ms);
1118 PumpLoop();
1119
1120 // HB manger uses the shortest persisted interval after restart.
1121 hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
1122 EXPECT_TRUE(hb_manager->HasClientHeartbeatInterval());
1123 EXPECT_EQ(other_interval_ms, hb_manager->GetClientHeartbeatIntervalMs());
1124 }
1125
1126 // Tests situation shorter of two intervals is removed.
1127 // Covers both connection restart and storing of custom intervals.
1128 TEST_F(MCSClientTest, CustomHeartbeatIntervalRemoveShorterInterval) {
1129 BuildMCSClient();
1130 InitializeClient();
1131 LoginClient(std::vector<std::string>());
1132 PumpLoop();
1133 StoreCredentials();
1134
1135 TestConnectionListener test_connection_listener;
1136 connection_factory()->SetConnectionListener(&test_connection_listener);
1137
1138 HeartbeatManager* hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
1139
1140 const std::string component_1 = "component1";
1141 int interval_ms = 5 * 60 * 1000; // 5 minutes. A valid setting.
1142
1143 AddExpectedLoginRequest(std::vector<std::string>(), interval_ms);
1144 mcs_client()->AddHeartbeatInterval(component_1, interval_ms);
1145 PumpLoop();
1146
1147 const std::string component_2 = "component2";
1148 int other_interval_ms = 3 * 60 * 1000; // 3 minutes. A valid setting.
1149 AddExpectedLoginRequest(std::vector<std::string>(), other_interval_ms);
1150 mcs_client()->AddHeartbeatInterval(component_2, other_interval_ms);
1151 PumpLoop();
961 1152
962 mcs_client()->RemoveHeartbeatInterval(component_2); 1153 mcs_client()->RemoveHeartbeatInterval(component_2);
1154 PumpLoop();
1155
963 // Removing the lowest setting reverts to second lowest. 1156 // Removing the lowest setting reverts to second lowest.
964 EXPECT_TRUE(hb_manager.HasClientHeartbeatInterval()); 1157 EXPECT_TRUE(hb_manager->HasClientHeartbeatInterval());
965 EXPECT_EQ(interval_ms, hb_manager.GetClientHeartbeatIntervalMs()); 1158 EXPECT_EQ(interval_ms, hb_manager->GetClientHeartbeatIntervalMs());
966 // No connection reset expected. 1159 // No connection reset expected.
967 EXPECT_EQ(expected_disconnect_counter, 1160 EXPECT_EQ(2, test_connection_listener.get_disconnect_counter());
968 test_connection_listener.get_disconnect_counter()); 1161
969 1162 // Check that setting was persisted and will take effect upon restart.
970 mcs_client()->RemoveHeartbeatInterval(component_1); 1163 BuildMCSClient();
971 // Removing all of the intervals, removes it from the HeartbeatManager. 1164 InitializeClient();
972 EXPECT_FALSE(hb_manager.HasClientHeartbeatInterval()); 1165 LoginClientWithHeartbeat(std::vector<std::string>(), interval_ms);
973 // No connection reset expected. 1166 PumpLoop();
974 EXPECT_EQ(expected_disconnect_counter, 1167
975 test_connection_listener.get_disconnect_counter()); 1168 // HB manger uses the shortest persisted interval after restart.
976 1169 hb_manager = mcs_client()->GetHeartbeatManagerForTesting();
977 mcs_client()->AddHeartbeatInterval(component_2, other_interval_ms); 1170 EXPECT_TRUE(hb_manager->HasClientHeartbeatInterval());
978 mcs_client()->AddHeartbeatInterval(component_1, interval_ms); 1171 EXPECT_EQ(interval_ms, hb_manager->GetClientHeartbeatIntervalMs());
979 EXPECT_TRUE(hb_manager.HasClientHeartbeatInterval());
980 EXPECT_EQ(other_interval_ms, hb_manager.GetClientHeartbeatIntervalMs());
981 // No connection reset expected.
982 EXPECT_EQ(expected_disconnect_counter,
983 test_connection_listener.get_disconnect_counter());
984
985 // Removing interval other than lowest does not change anything.
986 mcs_client()->RemoveHeartbeatInterval(component_1);
987 EXPECT_TRUE(hb_manager.HasClientHeartbeatInterval());
988 EXPECT_EQ(other_interval_ms, hb_manager.GetClientHeartbeatIntervalMs());
989 // No connection reset expected.
990 EXPECT_EQ(expected_disconnect_counter,
991 test_connection_listener.get_disconnect_counter());
992 } 1172 }
993 1173
994 } // namespace 1174 } // namespace
995 1175
996 } // namespace gcm 1176 } // namespace gcm
OLDNEW
« google_apis/gcm/engine/mcs_client.h ('K') | « google_apis/gcm/engine/mcs_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698