| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "jingle/notifier/listener/non_blocking_push_client.h" | 5 #include "jingle/notifier/listener/non_blocking_push_client.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/thread_task_runner_handle.h" |
| 12 #include "jingle/notifier/base/fake_base_task.h" | 13 #include "jingle/notifier/base/fake_base_task.h" |
| 13 #include "jingle/notifier/listener/fake_push_client.h" | 14 #include "jingle/notifier/listener/fake_push_client.h" |
| 14 #include "jingle/notifier/listener/fake_push_client_observer.h" | 15 #include "jingle/notifier/listener/fake_push_client_observer.h" |
| 15 #include "jingle/notifier/listener/push_client_observer.h" | 16 #include "jingle/notifier/listener/push_client_observer.h" |
| 16 #include "net/url_request/url_request_test_util.h" | 17 #include "net/url_request/url_request_test_util.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace notifier { | 20 namespace notifier { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 class NonBlockingPushClientTest : public testing::Test { | 24 class NonBlockingPushClientTest : public testing::Test { |
| 24 protected: | 25 protected: |
| 25 NonBlockingPushClientTest() : fake_push_client_(NULL) {} | 26 NonBlockingPushClientTest() : fake_push_client_(NULL) {} |
| 26 | 27 |
| 27 ~NonBlockingPushClientTest() override {} | 28 ~NonBlockingPushClientTest() override {} |
| 28 | 29 |
| 29 void SetUp() override { | 30 void SetUp() override { |
| 30 push_client_.reset( | 31 push_client_.reset( |
| 31 new NonBlockingPushClient( | 32 new NonBlockingPushClient( |
| 32 base::MessageLoopProxy::current(), | 33 base::ThreadTaskRunnerHandle::Get(), |
| 33 base::Bind(&NonBlockingPushClientTest::CreateFakePushClient, | 34 base::Bind(&NonBlockingPushClientTest::CreateFakePushClient, |
| 34 base::Unretained(this)))); | 35 base::Unretained(this)))); |
| 35 push_client_->AddObserver(&fake_observer_); | 36 push_client_->AddObserver(&fake_observer_); |
| 36 // Pump message loop to run CreateFakePushClient. | 37 // Pump message loop to run CreateFakePushClient. |
| 37 message_loop_.RunUntilIdle(); | 38 message_loop_.RunUntilIdle(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void TearDown() override { | 41 void TearDown() override { |
| 41 // Clear out any pending notifications before removing observers. | 42 // Clear out any pending notifications before removing observers. |
| 42 message_loop_.RunUntilIdle(); | 43 message_loop_.RunUntilIdle(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 143 |
| 143 fake_push_client_->SimulateIncomingNotification(notification); | 144 fake_push_client_->SimulateIncomingNotification(notification); |
| 144 message_loop_.RunUntilIdle(); | 145 message_loop_.RunUntilIdle(); |
| 145 EXPECT_TRUE( | 146 EXPECT_TRUE( |
| 146 fake_observer_.last_incoming_notification().Equals(notification)); | 147 fake_observer_.last_incoming_notification().Equals(notification)); |
| 147 } | 148 } |
| 148 | 149 |
| 149 } // namespace | 150 } // namespace |
| 150 | 151 |
| 151 } // namespace notifier | 152 } // namespace notifier |
| OLD | NEW |