Index: components/gcm_driver/gcm_driver_desktop_unittest.cc |
diff --git a/components/gcm_driver/gcm_driver_desktop_unittest.cc b/components/gcm_driver/gcm_driver_desktop_unittest.cc |
index 8d9211bd7a75269d8549922d6b731c677f0cd3e6..b7bb533feaedf2a3ecebfb6696c10a4ae185b096 100644 |
--- a/components/gcm_driver/gcm_driver_desktop_unittest.cc |
+++ b/components/gcm_driver/gcm_driver_desktop_unittest.cc |
@@ -825,9 +825,7 @@ TEST_F(GCMDriverFunctionalTest, UnregisterWhenAsyncOperationPending) { |
std::vector<std::string> sender_ids; |
sender_ids.push_back("sender1"); |
// First start registration without waiting for it to complete. |
- Register(kTestAppID1, |
- sender_ids, |
- GCMDriverTest::DO_NOT_WAIT); |
+ Register(kTestAppID1, sender_ids, GCMDriverTest::DO_NOT_WAIT); |
// Test that unregistration fails with async operation pending when there is a |
// registration already in progress. |
@@ -859,9 +857,7 @@ TEST_F(GCMDriverFunctionalTest, RegisterWhenAsyncOperationPending) { |
std::vector<std::string> sender_ids; |
sender_ids.push_back("sender1"); |
// First start registration without waiting for it to complete. |
- Register(kTestAppID1, |
- sender_ids, |
- GCMDriverTest::DO_NOT_WAIT); |
+ Register(kTestAppID1, sender_ids, GCMDriverTest::DO_NOT_WAIT); |
// Test that registration fails with async operation pending when there is a |
// registration already in progress. |
@@ -873,24 +869,34 @@ TEST_F(GCMDriverFunctionalTest, RegisterWhenAsyncOperationPending) { |
// Complete the registration. |
WaitForAsyncOperation(); |
EXPECT_EQ(GCMClient::SUCCESS, registration_result()); |
+} |
- // Start unregistration without waiting for it to complete. This time no async |
- // operation is pending. |
+TEST_F(GCMDriverFunctionalTest, RegisterAfterUnfinishedUnregister) { |
+ // Register and wait for it to complete. |
+ std::vector<std::string> sender_ids; |
+ sender_ids.push_back("sender1"); |
+ Register(kTestAppID1, sender_ids, GCMDriverTest::WAIT); |
+ EXPECT_EQ(GCMClient::SUCCESS, registration_result()); |
+ EXPECT_EQ(GetGCMClient()->GetRegistrationIdFromSenderIds(sender_ids), |
+ registration_id()); |
+ |
+ // Clears the results the would be set by the Register callback in preparation |
+ // to call register 2nd time. |
+ ClearResults(); |
+ |
+ // Start unregistration without waiting for it to complete. |
Unregister(kTestAppID1, GCMDriverTest::DO_NOT_WAIT); |
- // Test that registration fails with async operation pending when there is an |
- // unregistration already in progress. |
+ // Register immeidately after unregistration is not completed. |
+ sender_ids.push_back("sender2"); |
Register(kTestAppID1, sender_ids, GCMDriverTest::WAIT); |
- EXPECT_EQ(GCMClient::ASYNC_OPERATION_PENDING, |
- registration_result()); |
- // Complete the first unregistration expecting success. |
+ // We need one more waiting since the waiting in Register is indeed for |
+ // uncompleted Unregister. |
WaitForAsyncOperation(); |
- EXPECT_EQ(GCMClient::SUCCESS, unregistration_result()); |
- |
- // Test that it is ok to register again after unregistration. |
- Register(kTestAppID1, sender_ids, GCMDriverTest::WAIT); |
EXPECT_EQ(GCMClient::SUCCESS, registration_result()); |
+ EXPECT_EQ(GetGCMClient()->GetRegistrationIdFromSenderIds(sender_ids), |
+ registration_id()); |
} |
TEST_F(GCMDriverFunctionalTest, Send) { |