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

Unified Diff: components/gcm_driver/gcm_driver_desktop_unittest.cc

Issue 683913005: [GCM] Support registration before unregistration finishes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more comments Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/gcm_driver/gcm_driver.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « components/gcm_driver/gcm_driver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698