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

Unified Diff: jingle/notifier/listener/mediator_thread_unittest.cc

Issue 10398051: [Sync] Replace TalkMediator*/MediatorThread* with PushClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, fix test Created 8 years, 7 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 | « jingle/notifier/listener/mediator_thread_mock.cc ('k') | jingle/notifier/listener/push_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: jingle/notifier/listener/mediator_thread_unittest.cc
diff --git a/jingle/notifier/listener/mediator_thread_unittest.cc b/jingle/notifier/listener/mediator_thread_unittest.cc
deleted file mode 100644
index afb8ce1f73e5589d2207760527b15dd3f87fae6c..0000000000000000000000000000000000000000
--- a/jingle/notifier/listener/mediator_thread_unittest.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "jingle/notifier/listener/mediator_thread_impl.h"
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop.h"
-#include "jingle/notifier/base/fake_base_task.h"
-#include "jingle/notifier/base/notifier_options.h"
-#include "jingle/notifier/listener/notification_defines.h"
-#include "net/base/capturing_net_log.h"
-#include "net/url_request/url_request_context_getter.h"
-#include "net/url_request/url_request_test_util.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace notifier {
-
-namespace {
-
-using ::testing::StrictMock;
-
-class MockObserver : public MediatorThread::Observer {
- public:
- MOCK_METHOD1(OnConnectionStateChange, void(bool));
- MOCK_METHOD1(OnSubscriptionStateChange, void(bool));
- MOCK_METHOD1(OnIncomingNotification, void(const Notification&));
- MOCK_METHOD0(OnOutgoingNotification, void());
-};
-
-} // namespace
-
-class MediatorThreadTest : public testing::Test {
- protected:
- MediatorThreadTest() {
- notifier_options_.request_context_getter =
- new TestURLRequestContextGetter(message_loop_.message_loop_proxy());
- }
-
- virtual ~MediatorThreadTest() {}
-
- virtual void SetUp() {
- mediator_thread_.reset(new MediatorThreadImpl(notifier_options_));
- mediator_thread_->AddObserver(&mock_observer_);
- }
-
- virtual void TearDown() {
- // Clear out any messages posted by MediatorThread's
- // destructor.
- message_loop_.RunAllPending();
- mediator_thread_->RemoveObserver(&mock_observer_);
- mediator_thread_.reset();
- }
-
- MessageLoop message_loop_;
- NotifierOptions notifier_options_;
- StrictMock<MockObserver> mock_observer_;
- scoped_ptr<MediatorThreadImpl> mediator_thread_;
- FakeBaseTask fake_base_task_;
-};
-
-TEST_F(MediatorThreadTest, SendNotificationBasic) {
- EXPECT_CALL(mock_observer_, OnConnectionStateChange(true));
- EXPECT_CALL(mock_observer_, OnOutgoingNotification());
-
- mediator_thread_->TriggerOnConnectForTest(fake_base_task_.AsWeakPtr());
- mediator_thread_->SendNotification(Notification());
- mediator_thread_->Logout();
-
- // Shouldn't trigger.
- mediator_thread_->SendNotification(Notification());
-}
-
-TEST_F(MediatorThreadTest, SendNotificationDelayed) {
- EXPECT_CALL(mock_observer_, OnConnectionStateChange(true));
- EXPECT_CALL(mock_observer_, OnOutgoingNotification()).Times(5);
-
- for (int i = 0; i < 5; ++i) {
- mediator_thread_->SendNotification(Notification());
- }
- mediator_thread_->TriggerOnConnectForTest(fake_base_task_.AsWeakPtr());
-}
-
-TEST_F(MediatorThreadTest, SendNotificationDelayedTwice) {
- EXPECT_CALL(mock_observer_, OnConnectionStateChange(true)).Times(2);
- EXPECT_CALL(mock_observer_, OnOutgoingNotification()).Times(5);
-
- for (int i = 0; i < 5; ++i) {
- mediator_thread_->SendNotification(Notification());
- }
- mediator_thread_->TriggerOnConnectForTest(
- base::WeakPtr<buzz::XmppTaskParentInterface>());
- mediator_thread_->TriggerOnConnectForTest(fake_base_task_.AsWeakPtr());
-}
-
-} // namespace notifier
« no previous file with comments | « jingle/notifier/listener/mediator_thread_mock.cc ('k') | jingle/notifier/listener/push_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698