| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <map> | 6 #include <map> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/strings/string_tokenizer.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/extensions/state_store.h" | 15 #include "chrome/browser/extensions/state_store.h" |
| 15 #include "chrome/browser/extensions/test_extension_service.h" | 16 #include "chrome/browser/extensions/test_extension_service.h" |
| 16 #include "chrome/browser/extensions/test_extension_system.h" | 17 #include "chrome/browser/extensions/test_extension_system.h" |
| 17 #include "chrome/browser/services/gcm/gcm_client_factory.h" | 18 #include "chrome/browser/services/gcm/gcm_client_factory.h" |
| 18 #include "chrome/browser/services/gcm/gcm_client_mock.h" | 19 #include "chrome/browser/services/gcm/gcm_client_mock.h" |
| 19 #include "chrome/browser/services/gcm/gcm_event_router.h" | 20 #include "chrome/browser/services/gcm/gcm_event_router.h" |
| 20 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 21 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| 21 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 22 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 22 #include "chrome/browser/signin/signin_manager_base.h" | 23 #include "chrome/browser/signin/signin_manager_base.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 48 const char kTestExtensionName[] = "FooBar"; | 49 const char kTestExtensionName[] = "FooBar"; |
| 49 const char kTestingUsername[] = "user1@example.com"; | 50 const char kTestingUsername[] = "user1@example.com"; |
| 50 const char kTestingUsername2[] = "user2@example.com"; | 51 const char kTestingUsername2[] = "user2@example.com"; |
| 51 const char kTestingUsername3[] = "user3@example.com"; | 52 const char kTestingUsername3[] = "user3@example.com"; |
| 52 const char kTestingAppId[] = "TestApp1"; | 53 const char kTestingAppId[] = "TestApp1"; |
| 53 const char kTestingAppId2[] = "TestApp2"; | 54 const char kTestingAppId2[] = "TestApp2"; |
| 54 const char kTestingSha1Cert[] = "testing_cert1"; | 55 const char kTestingSha1Cert[] = "testing_cert1"; |
| 55 const char kUserId[] = "user1"; | 56 const char kUserId[] = "user1"; |
| 56 const char kUserId2[] = "user2"; | 57 const char kUserId2[] = "user2"; |
| 57 | 58 |
| 59 std::vector<std::string> ToSenderList(const std::string& sender_ids) { |
| 60 std::vector<std::string> senders; |
| 61 base::StringTokenizer tokenizer(sender_ids, ","); |
| 62 while (tokenizer.GetNext()) |
| 63 senders.push_back(tokenizer.token()); |
| 64 return senders; |
| 65 } |
| 66 |
| 58 // Helper class for asynchrnous waiting. | 67 // Helper class for asynchrnous waiting. |
| 59 class Waiter { | 68 class Waiter { |
| 60 public: | 69 public: |
| 61 Waiter() {} | 70 Waiter() {} |
| 62 virtual ~Waiter() {} | 71 virtual ~Waiter() {} |
| 63 | 72 |
| 64 // Waits until the asynchrnous operation finishes. | 73 // Waits until the asynchrnous operation finishes. |
| 65 void WaitUntilCompleted() { | 74 void WaitUntilCompleted() { |
| 66 run_loop_.reset(new base::RunLoop); | 75 run_loop_.reset(new base::RunLoop); |
| 67 run_loop_->Run(); | 76 run_loop_->Run(); |
| (...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 EXPECT_EQ(FakeGCMEventRouter::SEND_ERROR_EVENT, | 1026 EXPECT_EQ(FakeGCMEventRouter::SEND_ERROR_EVENT, |
| 1018 consumer()->gcm_event_router()->received_event()); | 1027 consumer()->gcm_event_router()->received_event()); |
| 1019 EXPECT_EQ(kTestingAppId, consumer()->gcm_event_router()->app_id()); | 1028 EXPECT_EQ(kTestingAppId, consumer()->gcm_event_router()->app_id()); |
| 1020 EXPECT_EQ(consumer()->send_message_id(), | 1029 EXPECT_EQ(consumer()->send_message_id(), |
| 1021 consumer()->gcm_event_router()->send_message_id()); | 1030 consumer()->gcm_event_router()->send_message_id()); |
| 1022 EXPECT_NE(GCMClient::SUCCESS, | 1031 EXPECT_NE(GCMClient::SUCCESS, |
| 1023 consumer()->gcm_event_router()->send_result()); | 1032 consumer()->gcm_event_router()->send_result()); |
| 1024 } | 1033 } |
| 1025 | 1034 |
| 1026 TEST_F(GCMProfileServiceSingleProfileTest, MessageReceived) { | 1035 TEST_F(GCMProfileServiceSingleProfileTest, MessageReceived) { |
| 1036 consumer()->Register(kTestingAppId, ToSenderList("sender")); |
| 1037 WaitUntilCompleted(); |
| 1027 GCMClient::IncomingMessage message; | 1038 GCMClient::IncomingMessage message; |
| 1028 message.data["key1"] = "value1"; | 1039 message.data["key1"] = "value1"; |
| 1029 message.data["key2"] = "value2"; | 1040 message.data["key2"] = "value2"; |
| 1041 message.sender_id = "sender"; |
| 1030 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, message); | 1042 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, message); |
| 1031 WaitUntilCompleted(); | 1043 WaitUntilCompleted(); |
| 1032 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, | 1044 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, |
| 1033 consumer()->gcm_event_router()->received_event()); | 1045 consumer()->gcm_event_router()->received_event()); |
| 1034 EXPECT_EQ(kTestingAppId, consumer()->gcm_event_router()->app_id()); | 1046 EXPECT_EQ(kTestingAppId, consumer()->gcm_event_router()->app_id()); |
| 1035 EXPECT_TRUE(message.data == consumer()->gcm_event_router()->message().data); | 1047 EXPECT_TRUE(message.data == consumer()->gcm_event_router()->message().data); |
| 1036 EXPECT_TRUE(consumer()->gcm_event_router()->message().collapse_key.empty()); | 1048 EXPECT_TRUE(consumer()->gcm_event_router()->message().collapse_key.empty()); |
| 1049 EXPECT_EQ(message.sender_id, |
| 1050 consumer()->gcm_event_router()->message().sender_id); |
| 1051 } |
| 1052 |
| 1053 TEST_F(GCMProfileServiceSingleProfileTest, |
| 1054 MessageNotReceivedFromNotRegisteredSender) { |
| 1055 // Explicitly not registering the sender2 here, so that message gets dropped. |
| 1056 consumer()->Register(kTestingAppId, ToSenderList("sender1")); |
| 1057 WaitUntilCompleted(); |
| 1058 GCMClient::IncomingMessage message; |
| 1059 message.data["key1"] = "value1"; |
| 1060 message.data["key2"] = "value2"; |
| 1061 message.sender_id = "sender2"; |
| 1062 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, message); |
| 1063 PumpUILoop(); |
| 1064 EXPECT_EQ(FakeGCMEventRouter::NO_EVENT, |
| 1065 consumer()->gcm_event_router()->received_event()); |
| 1066 consumer()->gcm_event_router()->clear_results(); |
| 1067 |
| 1068 // Register for sender2 and try to receive the message again, which should |
| 1069 // work with no problems. |
| 1070 consumer()->Register(kTestingAppId, ToSenderList("sender1,sender2")); |
| 1071 WaitUntilCompleted(); |
| 1072 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, message); |
| 1073 WaitUntilCompleted(); |
| 1074 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, |
| 1075 consumer()->gcm_event_router()->received_event()); |
| 1076 consumer()->gcm_event_router()->clear_results(); |
| 1077 |
| 1078 // Making sure that sender1 can receive the message as well. |
| 1079 message.sender_id = "sender1"; |
| 1080 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, message); |
| 1081 WaitUntilCompleted(); |
| 1082 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, |
| 1083 consumer()->gcm_event_router()->received_event()); |
| 1084 consumer()->gcm_event_router()->clear_results(); |
| 1085 |
| 1086 // Register for sender1 only and make sure it is not possible to receive the |
| 1087 // message again from from sender1. |
| 1088 consumer()->Register(kTestingAppId, ToSenderList("sender2")); |
| 1089 WaitUntilCompleted(); |
| 1090 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, message); |
| 1091 PumpUILoop(); |
| 1092 EXPECT_EQ(FakeGCMEventRouter::NO_EVENT, |
| 1093 consumer()->gcm_event_router()->received_event()); |
| 1037 } | 1094 } |
| 1038 | 1095 |
| 1039 TEST_F(GCMProfileServiceSingleProfileTest, MessageWithCollapseKeyReceived) { | 1096 TEST_F(GCMProfileServiceSingleProfileTest, MessageWithCollapseKeyReceived) { |
| 1097 consumer()->Register(kTestingAppId, ToSenderList("sender")); |
| 1098 WaitUntilCompleted(); |
| 1040 GCMClient::IncomingMessage message; | 1099 GCMClient::IncomingMessage message; |
| 1041 message.data["key1"] = "value1"; | 1100 message.data["key1"] = "value1"; |
| 1042 message.collapse_key = "collapse_key_value"; | 1101 message.collapse_key = "collapse_key_value"; |
| 1102 message.sender_id = "sender"; |
| 1043 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, message); | 1103 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, message); |
| 1044 WaitUntilCompleted(); | 1104 WaitUntilCompleted(); |
| 1045 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, | 1105 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, |
| 1046 consumer()->gcm_event_router()->received_event()); | 1106 consumer()->gcm_event_router()->received_event()); |
| 1047 EXPECT_EQ(kTestingAppId, consumer()->gcm_event_router()->app_id()); | 1107 EXPECT_EQ(kTestingAppId, consumer()->gcm_event_router()->app_id()); |
| 1048 EXPECT_TRUE(message.data == consumer()->gcm_event_router()->message().data); | 1108 EXPECT_TRUE(message.data == consumer()->gcm_event_router()->message().data); |
| 1049 EXPECT_EQ(message.collapse_key, | 1109 EXPECT_EQ(message.collapse_key, |
| 1050 consumer()->gcm_event_router()->message().collapse_key); | 1110 consumer()->gcm_event_router()->message().collapse_key); |
| 1051 } | 1111 } |
| 1052 | 1112 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 message3.data["hello"] = "world"; | 1221 message3.data["hello"] = "world"; |
| 1162 consumer2()->Send(kTestingAppId2, kUserId, message3); | 1222 consumer2()->Send(kTestingAppId2, kUserId, message3); |
| 1163 | 1223 |
| 1164 WaitUntilCompleted(); | 1224 WaitUntilCompleted(); |
| 1165 | 1225 |
| 1166 EXPECT_EQ(consumer2()->send_message_id(), message3.id); | 1226 EXPECT_EQ(consumer2()->send_message_id(), message3.id); |
| 1167 EXPECT_EQ(GCMClient::SUCCESS, consumer()->send_result()); | 1227 EXPECT_EQ(GCMClient::SUCCESS, consumer()->send_result()); |
| 1168 } | 1228 } |
| 1169 | 1229 |
| 1170 TEST_F(GCMProfileServiceMultiProfileTest, MessageReceived) { | 1230 TEST_F(GCMProfileServiceMultiProfileTest, MessageReceived) { |
| 1231 consumer()->Register(kTestingAppId, ToSenderList("sender")); |
| 1232 WaitUntilCompleted(); |
| 1233 consumer2()->Register(kTestingAppId, ToSenderList("sender")); |
| 1234 WaitUntilCompleted(); |
| 1235 consumer2()->Register(kTestingAppId2, ToSenderList("sender2")); |
| 1236 WaitUntilCompleted(); |
| 1237 |
| 1171 // Trigger an incoming message for an app in one profile. | 1238 // Trigger an incoming message for an app in one profile. |
| 1172 GCMClient::IncomingMessage message; | 1239 GCMClient::IncomingMessage message; |
| 1173 message.data["key1"] = "value1"; | 1240 message.data["key1"] = "value1"; |
| 1174 message.data["key2"] = "value2"; | 1241 message.data["key2"] = "value2"; |
| 1242 message.sender_id = "sender"; |
| 1175 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, message); | 1243 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, message); |
| 1176 | 1244 |
| 1177 // Trigger an incoming message for the same app in another profile. | 1245 // Trigger an incoming message for the same app in another profile. |
| 1178 GCMClient::IncomingMessage message2; | 1246 GCMClient::IncomingMessage message2; |
| 1179 message2.data["foo"] = "bar"; | 1247 message2.data["foo"] = "bar"; |
| 1248 message2.sender_id = "sender"; |
| 1180 consumer2()->GetGCMClient()->ReceiveMessage(kTestingAppId, message2); | 1249 consumer2()->GetGCMClient()->ReceiveMessage(kTestingAppId, message2); |
| 1181 | 1250 |
| 1182 WaitUntilCompleted(); | 1251 WaitUntilCompleted(); |
| 1183 WaitUntilCompleted(); | 1252 WaitUntilCompleted(); |
| 1184 | 1253 |
| 1185 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, | 1254 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, |
| 1186 consumer()->gcm_event_router()->received_event()); | 1255 consumer()->gcm_event_router()->received_event()); |
| 1187 EXPECT_EQ(kTestingAppId, consumer()->gcm_event_router()->app_id()); | 1256 EXPECT_EQ(kTestingAppId, consumer()->gcm_event_router()->app_id()); |
| 1188 EXPECT_TRUE(message.data == consumer()->gcm_event_router()->message().data); | 1257 EXPECT_TRUE(message.data == consumer()->gcm_event_router()->message().data); |
| 1258 EXPECT_EQ("sender", consumer()->gcm_event_router()->message().sender_id); |
| 1189 | 1259 |
| 1190 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, | 1260 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, |
| 1191 consumer2()->gcm_event_router()->received_event()); | 1261 consumer2()->gcm_event_router()->received_event()); |
| 1192 EXPECT_EQ(kTestingAppId, consumer2()->gcm_event_router()->app_id()); | 1262 EXPECT_EQ(kTestingAppId, consumer2()->gcm_event_router()->app_id()); |
| 1193 EXPECT_TRUE(message2.data == consumer2()->gcm_event_router()->message().data); | 1263 EXPECT_TRUE(message2.data == consumer2()->gcm_event_router()->message().data); |
| 1264 EXPECT_EQ("sender", consumer2()->gcm_event_router()->message().sender_id); |
| 1194 | 1265 |
| 1195 // Trigger another incoming message for a different app in another profile. | 1266 // Trigger another incoming message for a different app in another profile. |
| 1196 GCMClient::IncomingMessage message3; | 1267 GCMClient::IncomingMessage message3; |
| 1197 message3.data["bar1"] = "foo1"; | 1268 message3.data["bar1"] = "foo1"; |
| 1198 message3.data["bar2"] = "foo2"; | 1269 message3.data["bar2"] = "foo2"; |
| 1270 message3.sender_id = "sender2"; |
| 1199 consumer2()->GetGCMClient()->ReceiveMessage(kTestingAppId2, message3); | 1271 consumer2()->GetGCMClient()->ReceiveMessage(kTestingAppId2, message3); |
| 1200 | 1272 |
| 1201 WaitUntilCompleted(); | 1273 WaitUntilCompleted(); |
| 1202 | 1274 |
| 1203 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, | 1275 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, |
| 1204 consumer2()->gcm_event_router()->received_event()); | 1276 consumer2()->gcm_event_router()->received_event()); |
| 1205 EXPECT_EQ(kTestingAppId2, consumer2()->gcm_event_router()->app_id()); | 1277 EXPECT_EQ(kTestingAppId2, consumer2()->gcm_event_router()->app_id()); |
| 1206 EXPECT_TRUE(message3.data == consumer2()->gcm_event_router()->message().data); | 1278 EXPECT_TRUE(message3.data == consumer2()->gcm_event_router()->message().data); |
| 1279 EXPECT_EQ("sender2", consumer2()->gcm_event_router()->message().sender_id); |
| 1207 } | 1280 } |
| 1208 | 1281 |
| 1209 // Test a set of GCM operations on multiple profiles. | 1282 // Test a set of GCM operations on multiple profiles. |
| 1210 // 1) Register 1 app in profile1 and register 2 apps in profile2; | 1283 // 1) Register 1 app in profile1 and register 2 apps in profile2; |
| 1211 // 2) Send a message from profile1; | 1284 // 2) Send a message from profile1; |
| 1212 // 3) Receive a message to an app in profile1 and receive a message for each of | 1285 // 3) Receive a message to an app in profile1 and receive a message for each of |
| 1213 // two apps in profile2; | 1286 // two apps in profile2; |
| 1214 // 4) Send a message foe ach of two apps in profile2; | 1287 // 4) Send a message foe ach of two apps in profile2; |
| 1215 // 5) Sign out of profile1. | 1288 // 5) Sign out of profile1. |
| 1216 // 6) Register/send stops working for profile1; | 1289 // 6) Register/send stops working for profile1; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 | 1330 |
| 1258 WaitUntilCompleted(); | 1331 WaitUntilCompleted(); |
| 1259 | 1332 |
| 1260 EXPECT_EQ(consumer()->send_message_id(), out_message.id); | 1333 EXPECT_EQ(consumer()->send_message_id(), out_message.id); |
| 1261 EXPECT_EQ(GCMClient::SUCCESS, consumer()->send_result()); | 1334 EXPECT_EQ(GCMClient::SUCCESS, consumer()->send_result()); |
| 1262 | 1335 |
| 1263 // Trigger an incoming message for an app in one profile. | 1336 // Trigger an incoming message for an app in one profile. |
| 1264 GCMClient::IncomingMessage in_message; | 1337 GCMClient::IncomingMessage in_message; |
| 1265 in_message.data["in1"] = "in_data1"; | 1338 in_message.data["in1"] = "in_data1"; |
| 1266 in_message.data["in1_2"] = "in_data1_2"; | 1339 in_message.data["in1_2"] = "in_data1_2"; |
| 1340 in_message.sender_id = "sender1"; |
| 1267 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, in_message); | 1341 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, in_message); |
| 1268 | 1342 |
| 1269 WaitUntilCompleted(); | 1343 WaitUntilCompleted(); |
| 1270 | 1344 |
| 1271 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, | 1345 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, |
| 1272 consumer()->gcm_event_router()->received_event()); | 1346 consumer()->gcm_event_router()->received_event()); |
| 1273 EXPECT_EQ(kTestingAppId, consumer()->gcm_event_router()->app_id()); | 1347 EXPECT_EQ(kTestingAppId, consumer()->gcm_event_router()->app_id()); |
| 1274 EXPECT_TRUE( | 1348 EXPECT_TRUE( |
| 1275 in_message.data == consumer()->gcm_event_router()->message().data); | 1349 in_message.data == consumer()->gcm_event_router()->message().data); |
| 1276 | 1350 |
| 1277 // Trigger 2 incoming messages, one for each app respectively, in another | 1351 // Trigger 2 incoming messages, one for each app respectively, in another |
| 1278 // profile. | 1352 // profile. |
| 1279 GCMClient::IncomingMessage in_message2; | 1353 GCMClient::IncomingMessage in_message2; |
| 1280 in_message2.data["in2"] = "in_data2"; | 1354 in_message2.data["in2"] = "in_data2"; |
| 1355 in_message2.sender_id = "sender3"; |
| 1281 consumer2()->GetGCMClient()->ReceiveMessage(kTestingAppId2, in_message2); | 1356 consumer2()->GetGCMClient()->ReceiveMessage(kTestingAppId2, in_message2); |
| 1282 | 1357 |
| 1283 GCMClient::IncomingMessage in_message3; | 1358 GCMClient::IncomingMessage in_message3; |
| 1284 in_message3.data["in3"] = "in_data3"; | 1359 in_message3.data["in3"] = "in_data3"; |
| 1285 in_message3.data["in3_2"] = "in_data3_2"; | 1360 in_message3.data["in3_2"] = "in_data3_2"; |
| 1361 in_message3.sender_id = "foo"; |
| 1286 consumer2()->GetGCMClient()->ReceiveMessage(kTestingAppId, in_message3); | 1362 consumer2()->GetGCMClient()->ReceiveMessage(kTestingAppId, in_message3); |
| 1287 | 1363 |
| 1288 consumer2()->gcm_event_router()->clear_results(); | 1364 consumer2()->gcm_event_router()->clear_results(); |
| 1289 WaitUntilCompleted(); | 1365 WaitUntilCompleted(); |
| 1290 | 1366 |
| 1291 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, | 1367 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, |
| 1292 consumer2()->gcm_event_router()->received_event()); | 1368 consumer2()->gcm_event_router()->received_event()); |
| 1293 EXPECT_EQ(kTestingAppId2, consumer2()->gcm_event_router()->app_id()); | 1369 EXPECT_EQ(kTestingAppId2, consumer2()->gcm_event_router()->app_id()); |
| 1294 EXPECT_TRUE( | 1370 EXPECT_TRUE( |
| 1295 in_message2.data == consumer2()->gcm_event_router()->message().data); | 1371 in_message2.data == consumer2()->gcm_event_router()->message().data); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 consumer2()->gcm_event_router()->received_event()); | 1440 consumer2()->gcm_event_router()->received_event()); |
| 1365 EXPECT_EQ(kTestingAppId, consumer2()->gcm_event_router()->app_id()); | 1441 EXPECT_EQ(kTestingAppId, consumer2()->gcm_event_router()->app_id()); |
| 1366 EXPECT_EQ(consumer2()->send_message_id(), | 1442 EXPECT_EQ(consumer2()->send_message_id(), |
| 1367 consumer2()->gcm_event_router()->send_message_id()); | 1443 consumer2()->gcm_event_router()->send_message_id()); |
| 1368 EXPECT_NE(GCMClient::SUCCESS, | 1444 EXPECT_NE(GCMClient::SUCCESS, |
| 1369 consumer2()->gcm_event_router()->send_result()); | 1445 consumer2()->gcm_event_router()->send_result()); |
| 1370 | 1446 |
| 1371 // Sign in with a different user. | 1447 // Sign in with a different user. |
| 1372 consumer()->SignIn(kTestingUsername3); | 1448 consumer()->SignIn(kTestingUsername3); |
| 1373 | 1449 |
| 1450 // Signing out cleared all registrations, so we need to register again. |
| 1451 consumer()->Register(kTestingAppId, ToSenderList("sender1")); |
| 1452 WaitUntilCompleted(); |
| 1453 |
| 1374 // Incoming message will go through for the new signed-in user. | 1454 // Incoming message will go through for the new signed-in user. |
| 1375 GCMClient::IncomingMessage in_message5; | 1455 GCMClient::IncomingMessage in_message5; |
| 1376 in_message5.data["in5"] = "in_data5"; | 1456 in_message5.data["in5"] = "in_data5"; |
| 1457 in_message5.sender_id = "sender1"; |
| 1377 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, in_message5); | 1458 consumer()->GetGCMClient()->ReceiveMessage(kTestingAppId, in_message5); |
| 1378 | 1459 |
| 1379 consumer()->gcm_event_router()->clear_results(); | 1460 consumer()->gcm_event_router()->clear_results(); |
| 1380 WaitUntilCompleted(); | 1461 WaitUntilCompleted(); |
| 1381 | 1462 |
| 1382 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, | 1463 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, |
| 1383 consumer()->gcm_event_router()->received_event()); | 1464 consumer()->gcm_event_router()->received_event()); |
| 1384 EXPECT_TRUE( | 1465 EXPECT_TRUE( |
| 1385 in_message5.data == consumer()->gcm_event_router()->message().data); | 1466 in_message5.data == consumer()->gcm_event_router()->message().data); |
| 1386 } | 1467 } |
| 1387 | 1468 |
| 1388 } // namespace gcm | 1469 } // namespace gcm |
| OLD | NEW |