| Index: chrome/browser/services/gcm/gcm_service_unittest.cc
|
| diff --git a/chrome/browser/services/gcm/gcm_service_unittest.cc b/chrome/browser/services/gcm/gcm_service_unittest.cc
|
| index 530239fc68e34c40e53d50234d641ba35413a2fe..6a2e7433f21ff2b8bacc96727cdc3941da2d0fae 100644
|
| --- a/chrome/browser/services/gcm/gcm_service_unittest.cc
|
| +++ b/chrome/browser/services/gcm/gcm_service_unittest.cc
|
| @@ -74,8 +74,8 @@ class FakeGCMAppHandler : public GCMAppHandler {
|
|
|
| const Event& received_event() const { return received_event_; }
|
| const std::string& app_id() const { return app_id_; }
|
| - const GCMClient::IncomingMessage& message() const { return message_; }
|
| - const GCMClient::SendErrorDetails& send_error_details() const {
|
| + const IncomingMessage& message() const { return message_; }
|
| + const SendErrorDetails& send_error_details() const {
|
| return send_error_details_;
|
| }
|
|
|
| @@ -84,11 +84,11 @@ class FakeGCMAppHandler : public GCMAppHandler {
|
| // GCMAppHandler:
|
| virtual void ShutdownHandler() OVERRIDE;
|
| virtual void OnMessage(const std::string& app_id,
|
| - const GCMClient::IncomingMessage& message) OVERRIDE;
|
| + const IncomingMessage& message) OVERRIDE;
|
| virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE;
|
| virtual void OnSendError(
|
| const std::string& app_id,
|
| - const GCMClient::SendErrorDetails& send_error_details) OVERRIDE;
|
| + const SendErrorDetails& send_error_details) OVERRIDE;
|
|
|
| private:
|
| void ClearResults();
|
| @@ -97,8 +97,8 @@ class FakeGCMAppHandler : public GCMAppHandler {
|
|
|
| Event received_event_;
|
| std::string app_id_;
|
| - GCMClient::IncomingMessage message_;
|
| - GCMClient::SendErrorDetails send_error_details_;
|
| + IncomingMessage message_;
|
| + SendErrorDetails send_error_details_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(FakeGCMAppHandler);
|
| };
|
| @@ -142,7 +142,7 @@ void FakeGCMAppHandler::ShutdownHandler() {
|
| }
|
|
|
| void FakeGCMAppHandler::OnMessage(const std::string& app_id,
|
| - const GCMClient::IncomingMessage& message) {
|
| + const IncomingMessage& message) {
|
| ClearResults();
|
| received_event_ = MESSAGE_EVENT;
|
| app_id_ = app_id;
|
| @@ -161,7 +161,7 @@ void FakeGCMAppHandler::OnMessagesDeleted(const std::string& app_id) {
|
|
|
| void FakeGCMAppHandler::OnSendError(
|
| const std::string& app_id,
|
| - const GCMClient::SendErrorDetails& send_error_details) {
|
| + const SendErrorDetails& send_error_details) {
|
| ClearResults();
|
| received_event_ = SEND_ERROR_EVENT;
|
| app_id_ = app_id;
|
| @@ -173,8 +173,8 @@ void FakeGCMAppHandler::OnSendError(
|
| void FakeGCMAppHandler::ClearResults() {
|
| received_event_ = NO_EVENT;
|
| app_id_.clear();
|
| - message_ = GCMClient::IncomingMessage();
|
| - send_error_details_ = GCMClient::SendErrorDetails();
|
| + message_ = IncomingMessage();
|
| + send_error_details_ = SendErrorDetails();
|
| }
|
|
|
| TestGCMService::TestGCMService(
|
| @@ -220,10 +220,10 @@ class TestGCMServiceWrapper {
|
| TestGCMService* service() { return service_.get(); }
|
| FakeGCMAppHandler* gcm_app_handler() { return gcm_app_handler_.get(); }
|
| const std::string& registration_id() const { return registration_id_; }
|
| - GCMClient::Result registration_result() const { return registration_result_; }
|
| + Result registration_result() const { return registration_result_; }
|
| const std::string& send_message_id() const { return send_message_id_; }
|
| - GCMClient::Result send_result() const { return send_result_; }
|
| - GCMClient::Result unregistration_result() const {
|
| + Result send_result() const { return send_result_; }
|
| + Result unregistration_result() const {
|
| return unregistration_result_;
|
| }
|
|
|
| @@ -244,7 +244,7 @@ class TestGCMServiceWrapper {
|
| WaitToFinish wait_to_finish);
|
| void Send(const std::string& app_id,
|
| const std::string& receiver_id,
|
| - const GCMClient::OutgoingMessage& message,
|
| + const OutgoingMessage& message,
|
| WaitToFinish wait_to_finish);
|
| void Unregister(const std::string& app_id, WaitToFinish wait_to_finish);
|
|
|
| @@ -252,9 +252,9 @@ class TestGCMServiceWrapper {
|
|
|
| private:
|
| void RegisterCompleted(const std::string& registration_id,
|
| - GCMClient::Result result);
|
| - void SendCompleted(const std::string& message_id, GCMClient::Result result);
|
| - void UnregisterCompleted(GCMClient::Result result);
|
| + Result result);
|
| + void SendCompleted(const std::string& message_id, Result result);
|
| + void UnregisterCompleted(Result result);
|
|
|
| scoped_refptr<net::URLRequestContextGetter> request_context_;
|
| FakeOAuth2TokenService token_service_;
|
| @@ -266,10 +266,10 @@ class TestGCMServiceWrapper {
|
| base::Closure async_operation_completed_callback_;
|
|
|
| std::string registration_id_;
|
| - GCMClient::Result registration_result_;
|
| + Result registration_result_;
|
| std::string send_message_id_;
|
| - GCMClient::Result send_result_;
|
| - GCMClient::Result unregistration_result_;
|
| + Result send_result_;
|
| + Result unregistration_result_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TestGCMServiceWrapper);
|
| };
|
| @@ -278,9 +278,9 @@ TestGCMServiceWrapper::TestGCMServiceWrapper(
|
| const scoped_refptr<net::URLRequestContextGetter>& request_context)
|
| : request_context_(request_context),
|
| identity_provider_(NULL),
|
| - registration_result_(GCMClient::UNKNOWN_ERROR),
|
| - send_result_(GCMClient::UNKNOWN_ERROR),
|
| - unregistration_result_(GCMClient::UNKNOWN_ERROR) {
|
| + registration_result_(RESULT_UNKNOWN_ERROR),
|
| + send_result_(RESULT_UNKNOWN_ERROR),
|
| + unregistration_result_(RESULT_UNKNOWN_ERROR) {
|
| identity_provider_owner_.reset(new FakeIdentityProvider(&token_service_));
|
| identity_provider_ = identity_provider_owner_.get();
|
| }
|
| @@ -296,11 +296,11 @@ TestGCMServiceWrapper::~TestGCMServiceWrapper() {
|
|
|
| void TestGCMServiceWrapper::ClearRegistrationResult() {
|
| registration_id_.clear();
|
| - registration_result_ = GCMClient::UNKNOWN_ERROR;
|
| + registration_result_ = RESULT_UNKNOWN_ERROR;
|
| }
|
|
|
| void TestGCMServiceWrapper::ClearUnregistrationResult() {
|
| - unregistration_result_ = GCMClient::UNKNOWN_ERROR;
|
| + unregistration_result_ = RESULT_UNKNOWN_ERROR;
|
| }
|
|
|
| bool TestGCMServiceWrapper::ServiceHasAppHandlers() const {
|
| @@ -354,7 +354,7 @@ void TestGCMServiceWrapper::Register(const std::string& app_id,
|
|
|
| void TestGCMServiceWrapper::Send(const std::string& app_id,
|
| const std::string& receiver_id,
|
| - const GCMClient::OutgoingMessage& message,
|
| + const OutgoingMessage& message,
|
| WaitToFinish wait_to_finish) {
|
| base::RunLoop run_loop;
|
| async_operation_completed_callback_ = run_loop.QuitClosure();
|
| @@ -386,7 +386,7 @@ void TestGCMServiceWrapper::WaitForAsyncOperation() {
|
|
|
| void TestGCMServiceWrapper::RegisterCompleted(
|
| const std::string& registration_id,
|
| - GCMClient::Result result) {
|
| + Result result) {
|
| registration_id_ = registration_id;
|
| registration_result_ = result;
|
| if (!async_operation_completed_callback_.is_null())
|
| @@ -394,14 +394,14 @@ void TestGCMServiceWrapper::RegisterCompleted(
|
| }
|
|
|
| void TestGCMServiceWrapper::SendCompleted(const std::string& message_id,
|
| - GCMClient::Result result) {
|
| + Result result) {
|
| send_message_id_ = message_id;
|
| send_result_ = result;
|
| if (!async_operation_completed_callback_.is_null())
|
| async_operation_completed_callback_.Run();
|
| }
|
|
|
| -void TestGCMServiceWrapper::UnregisterCompleted(GCMClient::Result result) {
|
| +void TestGCMServiceWrapper::UnregisterCompleted(Result result) {
|
| unregistration_result_ = result;
|
| if (!async_operation_completed_callback_.is_null())
|
| async_operation_completed_callback_.Run();
|
| @@ -575,7 +575,7 @@ TEST_F(GCMServiceTest, RegisterWhenNotSignedIn) {
|
| wrapper_->Register(kTestAppID1, sender_ids, TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_TRUE(wrapper_->registration_id().empty());
|
| - EXPECT_EQ(GCMClient::NOT_SIGNED_IN, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_NOT_SIGNED_IN, wrapper_->registration_result());
|
| }
|
|
|
| TEST_F(GCMServiceTest, RegisterUnderNonPositiveChannelSignal) {
|
| @@ -601,19 +601,19 @@ TEST_F(GCMServiceTest, RegisterUnderNonPositiveChannelSignal) {
|
| const std::string expected_registration_id =
|
| GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids);
|
| EXPECT_EQ(expected_registration_id, wrapper_->registration_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
| }
|
|
|
| TEST_F(GCMServiceTest, SendWhenNotSignedIn) {
|
| wrapper_->CreateService(true, GCMClientMock::NO_DELAY_LOADING);
|
|
|
| - GCMClient::OutgoingMessage message;
|
| + OutgoingMessage message;
|
| message.id = "1";
|
| message.data["key1"] = "value1";
|
| wrapper_->Send(kTestAppID1, kUserID1, message, TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_TRUE(wrapper_->send_message_id().empty());
|
| - EXPECT_EQ(GCMClient::NOT_SIGNED_IN, wrapper_->send_result());
|
| + EXPECT_EQ(RESULT_NOT_SIGNED_IN, wrapper_->send_result());
|
| }
|
|
|
| TEST_F(GCMServiceTest, SendUnderNonPositiveChannelSignal) {
|
| @@ -627,7 +627,7 @@ TEST_F(GCMServiceTest, SendUnderNonPositiveChannelSignal) {
|
| EXPECT_EQ(GCMClientMock::UNINITIALIZED, wrapper_->GetGCMClient()->status());
|
|
|
| // Invoking send will make GCMClient checked in.
|
| - GCMClient::OutgoingMessage message;
|
| + OutgoingMessage message;
|
| message.id = "1";
|
| message.data["key1"] = "value1";
|
| wrapper_->Send(kTestAppID1, kUserID1, message, TestGCMServiceWrapper::WAIT);
|
| @@ -638,7 +638,7 @@ TEST_F(GCMServiceTest, SendUnderNonPositiveChannelSignal) {
|
|
|
| // Sending should succeed.
|
| EXPECT_EQ(message.id, wrapper_->send_message_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->send_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->send_result());
|
| }
|
|
|
| // Tests a single instance of GCMService.
|
| @@ -675,7 +675,7 @@ TEST_F(GCMServiceSingleInstanceTest, Register) {
|
| GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids);
|
|
|
| EXPECT_EQ(expected_registration_id, wrapper_->registration_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
| }
|
|
|
| TEST_F(GCMServiceSingleInstanceTest, RegisterError) {
|
| @@ -684,7 +684,7 @@ TEST_F(GCMServiceSingleInstanceTest, RegisterError) {
|
| wrapper_->Register(kTestAppID1, sender_ids, TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_TRUE(wrapper_->registration_id().empty());
|
| - EXPECT_NE(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_NE(RESULT_SUCCESS, wrapper_->registration_result());
|
| }
|
|
|
| TEST_F(GCMServiceSingleInstanceTest, RegisterAgainWithSameSenderIDs) {
|
| @@ -696,7 +696,7 @@ TEST_F(GCMServiceSingleInstanceTest, RegisterAgainWithSameSenderIDs) {
|
| GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids);
|
|
|
| EXPECT_EQ(expected_registration_id, wrapper_->registration_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
|
|
| // Clears the results the would be set by the Register callback in preparation
|
| // to call register 2nd time.
|
| @@ -712,7 +712,7 @@ TEST_F(GCMServiceSingleInstanceTest, RegisterAgainWithSameSenderIDs) {
|
| TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_EQ(expected_registration_id, wrapper_->registration_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
| }
|
|
|
| TEST_F(GCMServiceSingleInstanceTest, RegisterAgainWithDifferentSenderIDs) {
|
| @@ -723,7 +723,7 @@ TEST_F(GCMServiceSingleInstanceTest, RegisterAgainWithDifferentSenderIDs) {
|
| GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids);
|
|
|
| EXPECT_EQ(expected_registration_id, wrapper_->registration_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
|
|
| // Make sender IDs different.
|
| sender_ids.push_back("sender2");
|
| @@ -734,7 +734,7 @@ TEST_F(GCMServiceSingleInstanceTest, RegisterAgainWithDifferentSenderIDs) {
|
| // registration ID.
|
| wrapper_->Register(kTestAppID1, sender_ids, TestGCMServiceWrapper::WAIT);
|
| EXPECT_EQ(expected_registration_id2, wrapper_->registration_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
| }
|
|
|
| TEST_F(GCMServiceSingleInstanceTest, GCMClientNotReadyBeforeRegistration) {
|
| @@ -752,13 +752,13 @@ TEST_F(GCMServiceSingleInstanceTest, GCMClientNotReadyBeforeRegistration) {
|
| PumpIOLoop();
|
| PumpUILoop();
|
| EXPECT_TRUE(wrapper_->registration_id().empty());
|
| - EXPECT_EQ(GCMClient::UNKNOWN_ERROR, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_UNKNOWN_ERROR, wrapper_->registration_result());
|
|
|
| // Register operation will be invoked after GCMClient becomes ready.
|
| wrapper_->GetGCMClient()->PerformDelayedLoading();
|
| wrapper_->WaitForAsyncOperation();
|
| EXPECT_FALSE(wrapper_->registration_id().empty());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
| }
|
|
|
| TEST_F(GCMServiceSingleInstanceTest, RegisterAfterSignOut) {
|
| @@ -770,7 +770,7 @@ TEST_F(GCMServiceSingleInstanceTest, RegisterAfterSignOut) {
|
| wrapper_->Register(kTestAppID1, sender_ids, TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_TRUE(wrapper_->registration_id().empty());
|
| - EXPECT_EQ(GCMClient::NOT_SIGNED_IN, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_NOT_SIGNED_IN, wrapper_->registration_result());
|
| }
|
|
|
| TEST_F(GCMServiceSingleInstanceTest, UnregisterExplicitly) {
|
| @@ -779,11 +779,11 @@ TEST_F(GCMServiceSingleInstanceTest, UnregisterExplicitly) {
|
| wrapper_->Register(kTestAppID1, sender_ids, TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_FALSE(wrapper_->registration_id().empty());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
|
|
| wrapper_->Unregister(kTestAppID1, TestGCMServiceWrapper::WAIT);
|
|
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->unregistration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->unregistration_result());
|
| }
|
|
|
| TEST_F(GCMServiceSingleInstanceTest, UnregisterWhenAsyncOperationPending) {
|
| @@ -797,12 +797,12 @@ TEST_F(GCMServiceSingleInstanceTest, UnregisterWhenAsyncOperationPending) {
|
| // Test that unregistration fails with async operation pending when there is a
|
| // registration already in progress.
|
| wrapper_->Unregister(kTestAppID1, TestGCMServiceWrapper::WAIT);
|
| - EXPECT_EQ(GCMClient::ASYNC_OPERATION_PENDING,
|
| + EXPECT_EQ(RESULT_ASYNC_OPERATION_PENDING,
|
| wrapper_->unregistration_result());
|
|
|
| // Complete the unregistration.
|
| wrapper_->WaitForAsyncOperation();
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
|
|
| // Start unregistration without waiting for it to complete. This time no async
|
| // operation is pending.
|
| @@ -811,13 +811,13 @@ TEST_F(GCMServiceSingleInstanceTest, UnregisterWhenAsyncOperationPending) {
|
| // Test that unregistration fails with async operation pending when there is
|
| // an unregistration already in progress.
|
| wrapper_->Unregister(kTestAppID1, TestGCMServiceWrapper::WAIT);
|
| - EXPECT_EQ(GCMClient::ASYNC_OPERATION_PENDING,
|
| + EXPECT_EQ(RESULT_ASYNC_OPERATION_PENDING,
|
| wrapper_->unregistration_result());
|
| wrapper_->ClearUnregistrationResult();
|
|
|
| // Complete unregistration.
|
| wrapper_->WaitForAsyncOperation();
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->unregistration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->unregistration_result());
|
| }
|
|
|
| TEST_F(GCMServiceSingleInstanceTest, RegisterWhenAsyncOperationPending) {
|
| @@ -831,13 +831,13 @@ TEST_F(GCMServiceSingleInstanceTest, RegisterWhenAsyncOperationPending) {
|
| // Test that registration fails with async operation pending when there is a
|
| // registration already in progress.
|
| wrapper_->Register(kTestAppID1, sender_ids, TestGCMServiceWrapper::WAIT);
|
| - EXPECT_EQ(GCMClient::ASYNC_OPERATION_PENDING,
|
| + EXPECT_EQ(RESULT_ASYNC_OPERATION_PENDING,
|
| wrapper_->registration_result());
|
| wrapper_->ClearRegistrationResult();
|
|
|
| // Complete the registration.
|
| wrapper_->WaitForAsyncOperation();
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
|
|
| // Start unregistration without waiting for it to complete. This time no async
|
| // operation is pending.
|
| @@ -846,27 +846,27 @@ TEST_F(GCMServiceSingleInstanceTest, RegisterWhenAsyncOperationPending) {
|
| // Test that registration fails with async operation pending when there is an
|
| // unregistration already in progress.
|
| wrapper_->Register(kTestAppID1, sender_ids, TestGCMServiceWrapper::WAIT);
|
| - EXPECT_EQ(GCMClient::ASYNC_OPERATION_PENDING,
|
| + EXPECT_EQ(RESULT_ASYNC_OPERATION_PENDING,
|
| wrapper_->registration_result());
|
|
|
| // Complete the first unregistration expecting success.
|
| wrapper_->WaitForAsyncOperation();
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->unregistration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->unregistration_result());
|
|
|
| // Test that it is ok to register again after unregistration.
|
| wrapper_->Register(kTestAppID1, sender_ids, TestGCMServiceWrapper::WAIT);
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
| }
|
|
|
| TEST_F(GCMServiceSingleInstanceTest, Send) {
|
| - GCMClient::OutgoingMessage message;
|
| + OutgoingMessage message;
|
| message.id = "1";
|
| message.data["key1"] = "value1";
|
| message.data["key2"] = "value2";
|
| wrapper_->Send(kTestAppID1, kUserID1, message, TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_EQ(message.id, wrapper_->send_message_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->send_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->send_result());
|
| }
|
|
|
| TEST_F(GCMServiceSingleInstanceTest, GCMClientNotReadyBeforeSending) {
|
| @@ -876,7 +876,7 @@ TEST_F(GCMServiceSingleInstanceTest, GCMClientNotReadyBeforeSending) {
|
| wrapper_->SignIn(kTestAccountID1);
|
|
|
| // The sending is on hold until GCMClient is ready.
|
| - GCMClient::OutgoingMessage message;
|
| + OutgoingMessage message;
|
| message.id = "1";
|
| message.data["key1"] = "value1";
|
| message.data["key2"] = "value2";
|
| @@ -888,31 +888,31 @@ TEST_F(GCMServiceSingleInstanceTest, GCMClientNotReadyBeforeSending) {
|
| PumpUILoop();
|
|
|
| EXPECT_TRUE(wrapper_->send_message_id().empty());
|
| - EXPECT_EQ(GCMClient::UNKNOWN_ERROR, wrapper_->send_result());
|
| + EXPECT_EQ(RESULT_UNKNOWN_ERROR, wrapper_->send_result());
|
|
|
| // Send operation will be invoked after GCMClient becomes ready.
|
| wrapper_->GetGCMClient()->PerformDelayedLoading();
|
| wrapper_->WaitForAsyncOperation();
|
| EXPECT_EQ(message.id, wrapper_->send_message_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->send_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->send_result());
|
| }
|
|
|
| TEST_F(GCMServiceSingleInstanceTest, SendAfterSignOut) {
|
| // This will trigger check-out.
|
| wrapper_->SignOut();
|
|
|
| - GCMClient::OutgoingMessage message;
|
| + OutgoingMessage message;
|
| message.id = "1";
|
| message.data["key1"] = "value1";
|
| message.data["key2"] = "value2";
|
| wrapper_->Send(kTestAppID1, kUserID1, message, TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_TRUE(wrapper_->send_message_id().empty());
|
| - EXPECT_EQ(GCMClient::NOT_SIGNED_IN, wrapper_->send_result());
|
| + EXPECT_EQ(RESULT_NOT_SIGNED_IN, wrapper_->send_result());
|
| }
|
|
|
| TEST_F(GCMServiceSingleInstanceTest, SendError) {
|
| - GCMClient::OutgoingMessage message;
|
| + OutgoingMessage message;
|
| // Embedding error in id will tell the mock to simulate the send error.
|
| message.id = "1@error";
|
| message.data["key1"] = "value1";
|
| @@ -920,7 +920,7 @@ TEST_F(GCMServiceSingleInstanceTest, SendError) {
|
| wrapper_->Send(kTestAppID1, kUserID1, message, TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_EQ(message.id, wrapper_->send_message_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->send_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->send_result());
|
|
|
| // Wait for the send error.
|
| wrapper_->gcm_app_handler()->WaitForNotification();
|
| @@ -929,7 +929,7 @@ TEST_F(GCMServiceSingleInstanceTest, SendError) {
|
| EXPECT_EQ(kTestAppID1, wrapper_->gcm_app_handler()->app_id());
|
| EXPECT_EQ(message.id,
|
| wrapper_->gcm_app_handler()->send_error_details().message_id);
|
| - EXPECT_NE(GCMClient::SUCCESS,
|
| + EXPECT_NE(RESULT_SUCCESS,
|
| wrapper_->gcm_app_handler()->send_error_details().result);
|
| EXPECT_EQ(message.data,
|
| wrapper_->gcm_app_handler()->send_error_details().additional_data);
|
| @@ -939,7 +939,7 @@ TEST_F(GCMServiceSingleInstanceTest, MessageReceived) {
|
| wrapper_->Register(kTestAppID1,
|
| ToSenderList("sender"),
|
| TestGCMServiceWrapper::WAIT);
|
| - GCMClient::IncomingMessage message;
|
| + IncomingMessage message;
|
| message.data["key1"] = "value1";
|
| message.data["key2"] = "value2";
|
| message.sender_id = "sender";
|
| @@ -958,7 +958,7 @@ TEST_F(GCMServiceSingleInstanceTest, MessageWithCollapseKeyReceived) {
|
| wrapper_->Register(kTestAppID1,
|
| ToSenderList("sender"),
|
| TestGCMServiceWrapper::WAIT);
|
| - GCMClient::IncomingMessage message;
|
| + IncomingMessage message;
|
| message.data["key1"] = "value1";
|
| message.collapse_key = "collapse_key_value";
|
| message.sender_id = "sender";
|
| @@ -1034,11 +1034,11 @@ TEST_F(GCMServiceMultipleInstanceTest, Register) {
|
|
|
| EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids),
|
| wrapper_->registration_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
|
|
| EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids2),
|
| wrapper2_->registration_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper2_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper2_->registration_result());
|
|
|
| // Register a different app in a different instance.
|
| std::vector<std::string> sender_ids3;
|
| @@ -1049,37 +1049,37 @@ TEST_F(GCMServiceMultipleInstanceTest, Register) {
|
|
|
| EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids3),
|
| wrapper2_->registration_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper2_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper2_->registration_result());
|
| }
|
|
|
| TEST_F(GCMServiceMultipleInstanceTest, Send) {
|
| // Send a message from one app in one instance.
|
| - GCMClient::OutgoingMessage message;
|
| + OutgoingMessage message;
|
| message.id = "1";
|
| message.data["key1"] = "value1";
|
| message.data["key2"] = "value2";
|
| wrapper_->Send(kTestAppID1, kUserID1, message, TestGCMServiceWrapper::WAIT);
|
|
|
| // Send a message from same app in another instance.
|
| - GCMClient::OutgoingMessage message2;
|
| + OutgoingMessage message2;
|
| message2.id = "2";
|
| message2.data["foo"] = "bar";
|
| wrapper2_->Send(kTestAppID1, kUserID2, message2, TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_EQ(message.id, wrapper_->send_message_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->send_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->send_result());
|
|
|
| EXPECT_EQ(message2.id, wrapper2_->send_message_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper2_->send_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper2_->send_result());
|
|
|
| // Send another message from different app in another instance.
|
| - GCMClient::OutgoingMessage message3;
|
| + OutgoingMessage message3;
|
| message3.id = "3";
|
| message3.data["hello"] = "world";
|
| wrapper2_->Send(kTestAppID2, kUserID1, message3, TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_EQ(message3.id, wrapper2_->send_message_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper2_->send_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper2_->send_result());
|
| }
|
|
|
| TEST_F(GCMServiceMultipleInstanceTest, MessageReceived) {
|
| @@ -1094,7 +1094,7 @@ TEST_F(GCMServiceMultipleInstanceTest, MessageReceived) {
|
| TestGCMServiceWrapper::WAIT);
|
|
|
| // Trigger an incoming message for an app in one instance.
|
| - GCMClient::IncomingMessage message;
|
| + IncomingMessage message;
|
| message.data["key1"] = "value1";
|
| message.data["key2"] = "value2";
|
| message.sender_id = "sender";
|
| @@ -1102,7 +1102,7 @@ TEST_F(GCMServiceMultipleInstanceTest, MessageReceived) {
|
| wrapper_->gcm_app_handler()->WaitForNotification();
|
|
|
| // Trigger an incoming message for the same app in another instance.
|
| - GCMClient::IncomingMessage message2;
|
| + IncomingMessage message2;
|
| message2.data["foo"] = "bar";
|
| message2.sender_id = "sender";
|
| wrapper2_->GetGCMClient()->ReceiveMessage(kTestAppID1, message2);
|
| @@ -1121,7 +1121,7 @@ TEST_F(GCMServiceMultipleInstanceTest, MessageReceived) {
|
| EXPECT_EQ("sender", wrapper2_->gcm_app_handler()->message().sender_id);
|
|
|
| // Trigger another incoming message for a different app in another instance.
|
| - GCMClient::IncomingMessage message3;
|
| + IncomingMessage message3;
|
| message3.data["bar1"] = "foo1";
|
| message3.data["bar2"] = "foo2";
|
| message3.sender_id = "sender2";
|
| @@ -1167,14 +1167,14 @@ TEST_F(GCMServiceMultipleInstanceTest, Combined) {
|
|
|
| EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids),
|
| wrapper_->registration_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->registration_result());
|
|
|
| EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids3),
|
| wrapper2_->registration_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper2_->registration_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper2_->registration_result());
|
|
|
| // Send a message from one instance.
|
| - GCMClient::OutgoingMessage out_message;
|
| + OutgoingMessage out_message;
|
| out_message.id = "1";
|
| out_message.data["out1"] = "out_data1";
|
| out_message.data["out1_2"] = "out_data1_2";
|
| @@ -1184,10 +1184,10 @@ TEST_F(GCMServiceMultipleInstanceTest, Combined) {
|
| TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_EQ(out_message.id, wrapper_->send_message_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper_->send_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper_->send_result());
|
|
|
| // Trigger an incoming message for an app in one instance.
|
| - GCMClient::IncomingMessage in_message;
|
| + IncomingMessage in_message;
|
| in_message.data["in1"] = "in_data1";
|
| in_message.data["in1_2"] = "in_data1_2";
|
| in_message.sender_id = "sender1";
|
| @@ -1201,12 +1201,12 @@ TEST_F(GCMServiceMultipleInstanceTest, Combined) {
|
|
|
| // Trigger 2 incoming messages, one for each app respectively, in another
|
| // instance.
|
| - GCMClient::IncomingMessage in_message2;
|
| + IncomingMessage in_message2;
|
| in_message2.data["in2"] = "in_data2";
|
| in_message2.sender_id = "sender3";
|
| wrapper2_->GetGCMClient()->ReceiveMessage(kTestAppID2, in_message2);
|
|
|
| - GCMClient::IncomingMessage in_message3;
|
| + IncomingMessage in_message3;
|
| in_message3.data["in3"] = "in_data3";
|
| in_message3.data["in3_2"] = "in_data3_2";
|
| in_message3.sender_id = "foo";
|
| @@ -1227,7 +1227,7 @@ TEST_F(GCMServiceMultipleInstanceTest, Combined) {
|
| EXPECT_EQ(in_message3.data, wrapper2_->gcm_app_handler()->message().data);
|
|
|
| // Send two messages, one for each app respectively, from another instance.
|
| - GCMClient::OutgoingMessage out_message2;
|
| + OutgoingMessage out_message2;
|
| out_message2.id = "2";
|
| out_message2.data["out2"] = "out_data2";
|
| wrapper2_->Send(kTestAppID1,
|
| @@ -1235,7 +1235,7 @@ TEST_F(GCMServiceMultipleInstanceTest, Combined) {
|
| out_message2,
|
| TestGCMServiceWrapper::WAIT);
|
|
|
| - GCMClient::OutgoingMessage out_message3;
|
| + OutgoingMessage out_message3;
|
| out_message3.id = "3";
|
| out_message3.data["out3"] = "out_data3";
|
| wrapper2_->Send(kTestAppID2,
|
| @@ -1244,12 +1244,12 @@ TEST_F(GCMServiceMultipleInstanceTest, Combined) {
|
| TestGCMServiceWrapper::DO_NOT_WAIT);
|
|
|
| EXPECT_EQ(out_message2.id, wrapper2_->send_message_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper2_->send_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper2_->send_result());
|
|
|
| wrapper2_->WaitForAsyncOperation();
|
|
|
| EXPECT_EQ(out_message3.id, wrapper2_->send_message_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper2_->send_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper2_->send_result());
|
|
|
| // Sign out of one instance.
|
| wrapper_->SignOut();
|
| @@ -1257,14 +1257,14 @@ TEST_F(GCMServiceMultipleInstanceTest, Combined) {
|
| // Register/send stops working for signed-out instance.
|
| wrapper_->Register(kTestAppID1, sender_ids, TestGCMServiceWrapper::WAIT);
|
| EXPECT_TRUE(wrapper_->registration_id().empty());
|
| - EXPECT_EQ(GCMClient::NOT_SIGNED_IN, wrapper_->registration_result());
|
| + EXPECT_EQ(RESULT_NOT_SIGNED_IN, wrapper_->registration_result());
|
|
|
| wrapper_->Send(kTestAppID2,
|
| kUserID2,
|
| out_message3,
|
| TestGCMServiceWrapper::WAIT);
|
| EXPECT_TRUE(wrapper_->send_message_id().empty());
|
| - EXPECT_EQ(GCMClient::NOT_SIGNED_IN, wrapper_->send_result());
|
| + EXPECT_EQ(RESULT_NOT_SIGNED_IN, wrapper_->send_result());
|
|
|
| // Deleted messages event will go through for another signed-in instance.
|
| wrapper2_->GetGCMClient()->DeleteMessages(kTestAppID2);
|
| @@ -1275,7 +1275,7 @@ TEST_F(GCMServiceMultipleInstanceTest, Combined) {
|
| EXPECT_EQ(kTestAppID2, wrapper2_->gcm_app_handler()->app_id());
|
|
|
| // Send error event will go through for another signed-in instance.
|
| - GCMClient::OutgoingMessage out_message4;
|
| + OutgoingMessage out_message4;
|
| out_message4.id = "1@error";
|
| out_message4.data["out4"] = "out_data4";
|
| wrapper2_->Send(kTestAppID1,
|
| @@ -1284,7 +1284,7 @@ TEST_F(GCMServiceMultipleInstanceTest, Combined) {
|
| TestGCMServiceWrapper::WAIT);
|
|
|
| EXPECT_EQ(out_message4.id, wrapper2_->send_message_id());
|
| - EXPECT_EQ(GCMClient::SUCCESS, wrapper2_->send_result());
|
| + EXPECT_EQ(RESULT_SUCCESS, wrapper2_->send_result());
|
|
|
| wrapper2_->gcm_app_handler()->WaitForNotification();
|
| EXPECT_EQ(FakeGCMAppHandler::SEND_ERROR_EVENT,
|
| @@ -1292,7 +1292,7 @@ TEST_F(GCMServiceMultipleInstanceTest, Combined) {
|
| EXPECT_EQ(kTestAppID1, wrapper2_->gcm_app_handler()->app_id());
|
| EXPECT_EQ(out_message4.id,
|
| wrapper2_->gcm_app_handler()->send_error_details().message_id);
|
| - EXPECT_NE(GCMClient::SUCCESS,
|
| + EXPECT_NE(RESULT_SUCCESS,
|
| wrapper2_->gcm_app_handler()->send_error_details().result);
|
| EXPECT_EQ(out_message4.data,
|
| wrapper2_->gcm_app_handler()->send_error_details().additional_data);
|
| @@ -1306,7 +1306,7 @@ TEST_F(GCMServiceMultipleInstanceTest, Combined) {
|
| TestGCMServiceWrapper::WAIT);
|
|
|
| // Incoming message will go through for the new signed-in account.
|
| - GCMClient::IncomingMessage in_message5;
|
| + IncomingMessage in_message5;
|
| in_message5.data["in5"] = "in_data5";
|
| in_message5.sender_id = "sender1";
|
| wrapper_->GetGCMClient()->ReceiveMessage(kTestAppID1, in_message5);
|
|
|