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

Side by Side Diff: chrome/browser/services/gcm/gcm_profile_service_unittest.cc

Issue 183013007: [GCM] Stop/restart GCM when the state is forced off/on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch to land Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 EXPECT_EQ(GCMClientMock::CHECKED_OUT, consumer()->GetGCMClient()->status()); 642 EXPECT_EQ(GCMClientMock::CHECKED_OUT, consumer()->GetGCMClient()->status());
643 643
644 // Sign-in with a different username. 644 // Sign-in with a different username.
645 consumer()->SignIn(kTestingUsername2); 645 consumer()->SignIn(kTestingUsername2);
646 646
647 // GCMClient should be loaded again. 647 // GCMClient should be loaded again.
648 EXPECT_TRUE(consumer()->IsGCMClientReady()); 648 EXPECT_TRUE(consumer()->IsGCMClientReady());
649 EXPECT_EQ(GCMClientMock::LOADED, consumer()->GetGCMClient()->status()); 649 EXPECT_EQ(GCMClientMock::LOADED, consumer()->GetGCMClient()->status());
650 } 650 }
651 651
652 TEST_F(GCMProfileServiceTest, StopAndRestartGCM) {
653 // Positive channel signal is provided in SetUp.
654 consumer()->CreateGCMProfileServiceInstance();
655 consumer()->SignIn(kTestingUsername);
656
657 // GCMClient should be loaded.
658 EXPECT_TRUE(consumer()->IsGCMClientReady());
659 EXPECT_EQ(GCMClientMock::LOADED, consumer()->GetGCMClient()->status());
660
661 // Stops the GCM.
662 consumer()->GetGCMProfileService()->Stop();
663 PumpIOLoop();
664
665 // GCMClient should be stopped.
666 EXPECT_FALSE(consumer()->IsGCMClientReady());
667 EXPECT_EQ(GCMClientMock::STOPPED, consumer()->GetGCMClient()->status());
668
669 // Restarts the GCM.
670 consumer()->GetGCMProfileService()->Start();
671 PumpIOLoop();
672
673 // GCMClient should be loaded.
674 EXPECT_TRUE(consumer()->IsGCMClientReady());
675 EXPECT_EQ(GCMClientMock::LOADED, consumer()->GetGCMClient()->status());
676
677 // Stops the GCM.
678 consumer()->GetGCMProfileService()->Stop();
679 PumpIOLoop();
680
681 // GCMClient should be stopped.
682 EXPECT_FALSE(consumer()->IsGCMClientReady());
683 EXPECT_EQ(GCMClientMock::STOPPED, consumer()->GetGCMClient()->status());
684
685 // Signs out.
686 consumer()->SignOut();
687
688 // GCMClient should be checked out.
689 EXPECT_FALSE(consumer()->IsGCMClientReady());
690 EXPECT_EQ(GCMClientMock::CHECKED_OUT, consumer()->GetGCMClient()->status());
691 }
692
652 TEST_F(GCMProfileServiceTest, RegisterWhenNotSignedIn) { 693 TEST_F(GCMProfileServiceTest, RegisterWhenNotSignedIn) {
653 consumer()->CreateGCMProfileServiceInstance(); 694 consumer()->CreateGCMProfileServiceInstance();
654 695
655 std::vector<std::string> sender_ids; 696 std::vector<std::string> sender_ids;
656 sender_ids.push_back("sender1"); 697 sender_ids.push_back("sender1");
657 consumer()->Register(kTestingAppId, sender_ids); 698 consumer()->Register(kTestingAppId, sender_ids);
658 699
659 EXPECT_TRUE(consumer()->registration_id().empty()); 700 EXPECT_TRUE(consumer()->registration_id().empty());
660 EXPECT_EQ(GCMClient::NOT_SIGNED_IN, consumer()->registration_result()); 701 EXPECT_EQ(GCMClient::NOT_SIGNED_IN, consumer()->registration_result());
661 } 702 }
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 consumer()->gcm_event_router()->clear_results(); 1420 consumer()->gcm_event_router()->clear_results();
1380 WaitUntilCompleted(); 1421 WaitUntilCompleted();
1381 1422
1382 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, 1423 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT,
1383 consumer()->gcm_event_router()->received_event()); 1424 consumer()->gcm_event_router()->received_event());
1384 EXPECT_TRUE( 1425 EXPECT_TRUE(
1385 in_message5.data == consumer()->gcm_event_router()->message().data); 1426 in_message5.data == consumer()->gcm_event_router()->message().data);
1386 } 1427 }
1387 1428
1388 } // namespace gcm 1429 } // namespace gcm
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/gcm_profile_service.cc ('k') | chrome/browser/sync/profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698