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

Side by Side Diff: jingle/notifier/base/fake_base_task.cc

Issue 9190029: use push messaging in cache invalidation xmpp channel (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 8 years, 11 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/compiler_specific.h"
5 #include "jingle/notifier/base/fake_base_task.h" 6 #include "jingle/notifier/base/fake_base_task.h"
6 #include "jingle/notifier/base/weak_xmpp_client.h" 7 #include "jingle/notifier/base/weak_xmpp_client.h"
8 #include "talk/xmpp/jid.h"
7 #include "talk/xmpp/asyncsocket.h" 9 #include "talk/xmpp/asyncsocket.h"
8 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
9 11
10 namespace notifier { 12 namespace notifier {
11 13
12 using ::testing::_; 14 using ::testing::_;
13 using ::testing::Return; 15 using ::testing::Return;
14 16
15 class MockAsyncSocket : public buzz::AsyncSocket { 17 class MockAsyncSocket : public buzz::AsyncSocket {
16 public: 18 public:
17 virtual ~MockAsyncSocket() {} 19 virtual ~MockAsyncSocket() {}
18 20
19 MOCK_METHOD0(state, State()); 21 MOCK_METHOD0(state, State());
20 MOCK_METHOD0(error, Error()); 22 MOCK_METHOD0(error, Error());
21 MOCK_METHOD0(GetError, int()); 23 MOCK_METHOD0(GetError, int());
22 MOCK_METHOD1(Connect, bool(const talk_base::SocketAddress&)); 24 MOCK_METHOD1(Connect, bool(const talk_base::SocketAddress&));
23 MOCK_METHOD3(Read, bool(char*, size_t, size_t*)); 25 MOCK_METHOD3(Read, bool(char*, size_t, size_t*));
24 MOCK_METHOD2(Write, bool(const char*, size_t)); 26 MOCK_METHOD2(Write, bool(const char*, size_t));
25 MOCK_METHOD0(Close, bool()); 27 MOCK_METHOD0(Close, bool());
26 MOCK_METHOD1(StartTls, bool(const std::string&)); 28 MOCK_METHOD1(StartTls, bool(const std::string&));
27 }; 29 };
28 30
31 class FakeWeakXmppClient : public notifier::WeakXmppClient {
akalin 2012/01/25 02:45:13 put in anon namespace
akalin 2012/01/25 02:45:13 add comment describing class (i.e. extending it to
ghc 2012/01/25 03:18:28 Done.
ghc 2012/01/25 03:18:28 Done.
32 public:
33 explicit FakeWeakXmppClient(talk_base::TaskParent* parent)
34 : notifier::WeakXmppClient(parent),
35 jid_("test@example.com/testresource") {}
36
37 virtual ~FakeWeakXmppClient() {}
38
39 virtual const buzz::Jid& jid() const OVERRIDE {
40 return jid_;
41 }
42
43 private:
44 buzz::Jid jid_;
45 };
46
29 FakeBaseTask::FakeBaseTask() { 47 FakeBaseTask::FakeBaseTask() {
30 // Owned by |task_pump_|. 48 // Owned by |task_pump_|.
31 notifier::WeakXmppClient* weak_xmpp_client = 49 notifier::FakeWeakXmppClient* weak_xmpp_client =
32 new notifier::WeakXmppClient(&task_pump_); 50 new notifier::FakeWeakXmppClient(&task_pump_);
33 51
34 weak_xmpp_client->Start(); 52 weak_xmpp_client->Start();
35 buzz::XmppClientSettings settings; 53 buzz::XmppClientSettings settings;
36 // Owned by |weak_xmpp_client|. 54 // Owned by |weak_xmpp_client|.
37 MockAsyncSocket* mock_async_socket = new MockAsyncSocket(); 55 MockAsyncSocket* mock_async_socket = new MockAsyncSocket();
38 EXPECT_CALL(*mock_async_socket, Connect(_)).WillOnce(Return(true)); 56 EXPECT_CALL(*mock_async_socket, Connect(_)).WillOnce(Return(true));
39 weak_xmpp_client->Connect(settings, "en", mock_async_socket, NULL); 57 weak_xmpp_client->Connect(settings, "en", mock_async_socket, NULL);
40 // Initialize the XMPP client. 58 // Initialize the XMPP client.
41 task_pump_.RunTasks(); 59 task_pump_.RunTasks();
42 60
43 base_task_ = weak_xmpp_client->AsWeakPtr(); 61 base_task_ = weak_xmpp_client->AsWeakPtr();
44 } 62 }
45 63
46 FakeBaseTask::~FakeBaseTask() {} 64 FakeBaseTask::~FakeBaseTask() {}
47 65
48 base::WeakPtr<buzz::XmppTaskParentInterface> FakeBaseTask::AsWeakPtr() { 66 base::WeakPtr<buzz::XmppTaskParentInterface> FakeBaseTask::AsWeakPtr() {
49 return base_task_; 67 return base_task_;
50 } 68 }
51 69
52 } // namespace notifier 70 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698