| Index: components/gcm_driver/gcm_client_impl_unittest.cc
|
| diff --git a/components/gcm_driver/gcm_client_impl_unittest.cc b/components/gcm_driver/gcm_client_impl_unittest.cc
|
| index 0363f86ce88493726ce9a97846e723927f0c2b71..2a16793d61add2232edf15a31b61e8e9eda2722b 100644
|
| --- a/components/gcm_driver/gcm_client_impl_unittest.cc
|
| +++ b/components/gcm_driver/gcm_client_impl_unittest.cc
|
| @@ -219,6 +219,7 @@ class GCMClientImplTest : public testing::Test,
|
|
|
| void BuildGCMClient(base::TimeDelta clock_step);
|
| void InitializeGCMClient();
|
| + void StartGCMClient();
|
| void ReceiveMessageFromMCS(const MCSMessage& message);
|
| void CompleteCheckin(uint64 android_id,
|
| uint64 security_token,
|
| @@ -333,6 +334,7 @@ void GCMClientImplTest::SetUp() {
|
| InitializeLoop();
|
| BuildGCMClient(base::TimeDelta());
|
| InitializeGCMClient();
|
| + StartGCMClient();
|
| CompleteCheckin(kDeviceAndroidId,
|
| kDeviceSecurityToken,
|
| std::string(),
|
| @@ -452,7 +454,9 @@ void GCMClientImplTest::InitializeGCMClient() {
|
| url_request_context_getter_,
|
| make_scoped_ptr<Encryptor>(new FakeEncryptor),
|
| this);
|
| +}
|
|
|
| +void GCMClientImplTest::StartGCMClient() {
|
| // Start loading and check-in.
|
| gcm_client_->Start();
|
|
|
| @@ -556,6 +560,7 @@ TEST_F(GCMClientImplTest, DISABLED_RegisterAppFromCache) {
|
| // Recreate GCMClient in order to load from the persistent store.
|
| BuildGCMClient(base::TimeDelta());
|
| InitializeGCMClient();
|
| + StartGCMClient();
|
|
|
| EXPECT_TRUE(ExistsRegistration(kAppId));
|
| }
|
| @@ -704,6 +709,7 @@ void GCMClientImplCheckinTest::SetUp() {
|
| // Time will be advancing one hour every time it is checked.
|
| BuildGCMClient(base::TimeDelta::FromSeconds(kSettingsCheckinInterval));
|
| InitializeGCMClient();
|
| + StartGCMClient();
|
| }
|
|
|
| TEST_F(GCMClientImplCheckinTest, GServicesSettingsAfterInitialCheckin) {
|
| @@ -764,6 +770,7 @@ TEST_F(GCMClientImplCheckinTest, LoadGSettingsFromStore) {
|
|
|
| BuildGCMClient(base::TimeDelta());
|
| InitializeGCMClient();
|
| + StartGCMClient();
|
|
|
| EXPECT_EQ(base::TimeDelta::FromSeconds(kSettingsCheckinInterval),
|
| gservices_settings().GetCheckinInterval());
|
| @@ -777,4 +784,57 @@ TEST_F(GCMClientImplCheckinTest, LoadGSettingsFromStore) {
|
| gservices_settings().GetMCSFallbackEndpoint());
|
| }
|
|
|
| +class GCMClientImplStartAndStopTest : public GCMClientImplTest {
|
| +public:
|
| + GCMClientImplStartAndStopTest();
|
| + virtual ~GCMClientImplStartAndStopTest();
|
| +
|
| + virtual void SetUp() OVERRIDE;
|
| +};
|
| +
|
| +GCMClientImplStartAndStopTest::GCMClientImplStartAndStopTest() {
|
| +}
|
| +
|
| +GCMClientImplStartAndStopTest::~GCMClientImplStartAndStopTest() {
|
| +}
|
| +
|
| +void GCMClientImplStartAndStopTest::SetUp() {
|
| + testing::Test::SetUp();
|
| + ASSERT_TRUE(CreateUniqueTempDir());
|
| + InitializeLoop();
|
| + BuildGCMClient(base::TimeDelta());
|
| + InitializeGCMClient();
|
| +}
|
| +
|
| +TEST_F(GCMClientImplStartAndStopTest, StartStopAndRestart) {
|
| + // Start the GCM and wait until it is ready.
|
| + gcm_client()->Start();
|
| + PumpLoopUntilIdle();
|
| +
|
| + // Stop the GCM.
|
| + gcm_client()->Stop();
|
| + PumpLoopUntilIdle();
|
| +
|
| + // Restart the GCM.
|
| + gcm_client()->Start();
|
| + PumpLoopUntilIdle();
|
| +}
|
| +
|
| +TEST_F(GCMClientImplStartAndStopTest, StartAndStopImmediately) {
|
| + // Start the GCM and then stop it immediately.
|
| + gcm_client()->Start();
|
| + gcm_client()->Stop();
|
| +
|
| + PumpLoopUntilIdle();
|
| +}
|
| +
|
| +TEST_F(GCMClientImplStartAndStopTest, StartStopAndRestartImmediately) {
|
| + // Start the GCM and then stop and restart it immediately.
|
| + gcm_client()->Start();
|
| + gcm_client()->Stop();
|
| + gcm_client()->Start();
|
| +
|
| + PumpLoopUntilIdle();
|
| +}
|
| +
|
| } // namespace gcm
|
|
|