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" |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 EXPECT_TRUE(consumer()->registration_id().empty()); | 806 EXPECT_TRUE(consumer()->registration_id().empty()); |
807 EXPECT_EQ(GCMClient::UNKNOWN_ERROR, consumer()->registration_result()); | 807 EXPECT_EQ(GCMClient::UNKNOWN_ERROR, consumer()->registration_result()); |
808 | 808 |
809 // Register operation will be invoked after GCMClient becomes ready. | 809 // Register operation will be invoked after GCMClient becomes ready. |
810 consumer()->GetGCMClient()->SetReady(); | 810 consumer()->GetGCMClient()->SetReady(); |
811 WaitUntilCompleted(); | 811 WaitUntilCompleted(); |
812 EXPECT_EQ(old_registration_id, consumer()->registration_id()); | 812 EXPECT_EQ(old_registration_id, consumer()->registration_id()); |
813 EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result()); | 813 EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result()); |
814 } | 814 } |
815 | 815 |
| 816 TEST_F(GCMProfileServiceSingleProfileTest, |
| 817 PersistedRegistrationInfoRemoveAfterSignOut) { |
| 818 std::vector<std::string> sender_ids; |
| 819 sender_ids.push_back("sender1"); |
| 820 consumer()->Register(kTestingAppId, sender_ids); |
| 821 WaitUntilCompleted(); |
| 822 |
| 823 // The app id and registration info should be persisted. |
| 824 EXPECT_TRUE(profile()->GetPrefs()->HasPrefPath(prefs::kGCMApps)); |
| 825 EXPECT_TRUE(consumer()->HasPersistedRegistrationInfo(kTestingAppId)); |
| 826 |
| 827 consumer()->SignOut(); |
| 828 PumpUILoop(); |
| 829 |
| 830 // The app id and persisted registration info should be removed. |
| 831 EXPECT_FALSE(profile()->GetPrefs()->HasPrefPath(prefs::kGCMApps)); |
| 832 EXPECT_FALSE(consumer()->HasPersistedRegistrationInfo(kTestingAppId)); |
| 833 } |
| 834 |
816 TEST_F(GCMProfileServiceSingleProfileTest, RegisterAfterSignOut) { | 835 TEST_F(GCMProfileServiceSingleProfileTest, RegisterAfterSignOut) { |
817 // This will trigger check-out. | 836 // This will trigger check-out. |
818 consumer()->SignOut(); | 837 consumer()->SignOut(); |
819 | 838 |
820 std::vector<std::string> sender_ids; | 839 std::vector<std::string> sender_ids; |
821 sender_ids.push_back("sender1"); | 840 sender_ids.push_back("sender1"); |
822 consumer()->Register(kTestingAppId, sender_ids); | 841 consumer()->Register(kTestingAppId, sender_ids); |
823 | 842 |
824 EXPECT_TRUE(consumer()->registration_id().empty()); | 843 EXPECT_TRUE(consumer()->registration_id().empty()); |
825 EXPECT_EQ(GCMClient::NOT_SIGNED_IN, consumer()->registration_result()); | 844 EXPECT_EQ(GCMClient::NOT_SIGNED_IN, consumer()->registration_result()); |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 consumer()->gcm_event_router()->clear_results(); | 1264 consumer()->gcm_event_router()->clear_results(); |
1246 WaitUntilCompleted(); | 1265 WaitUntilCompleted(); |
1247 | 1266 |
1248 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, | 1267 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, |
1249 consumer()->gcm_event_router()->received_event()); | 1268 consumer()->gcm_event_router()->received_event()); |
1250 EXPECT_TRUE( | 1269 EXPECT_TRUE( |
1251 in_message5.data == consumer()->gcm_event_router()->message().data); | 1270 in_message5.data == consumer()->gcm_event_router()->message().data); |
1252 } | 1271 } |
1253 | 1272 |
1254 } // namespace gcm | 1273 } // namespace gcm |
OLD | NEW |