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

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

Issue 9234053: Revert 119171 - Maybe introduced a static initializer - or may be 119173 (Closed) Base URL: svn://svn.chromium.org/chrome/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
Property Changes:
Deleted: svn:eol-style
- LF
OLDNEW
1 // Copyright (c) 2012 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"
6 #include "jingle/notifier/base/fake_base_task.h" 5 #include "jingle/notifier/base/fake_base_task.h"
7 #include "jingle/notifier/base/weak_xmpp_client.h" 6 #include "jingle/notifier/base/weak_xmpp_client.h"
8 #include "talk/xmpp/jid.h"
9 #include "talk/xmpp/asyncsocket.h" 7 #include "talk/xmpp/asyncsocket.h"
10 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
11 9
12 namespace notifier { 10 namespace notifier {
13 11
14 using ::testing::_; 12 using ::testing::_;
15 using ::testing::Return; 13 using ::testing::Return;
16 14
17 class MockAsyncSocket : public buzz::AsyncSocket { 15 class MockAsyncSocket : public buzz::AsyncSocket {
18 public: 16 public:
19 virtual ~MockAsyncSocket() {} 17 virtual ~MockAsyncSocket() {}
20 18
21 MOCK_METHOD0(state, State()); 19 MOCK_METHOD0(state, State());
22 MOCK_METHOD0(error, Error()); 20 MOCK_METHOD0(error, Error());
23 MOCK_METHOD0(GetError, int()); 21 MOCK_METHOD0(GetError, int());
24 MOCK_METHOD1(Connect, bool(const talk_base::SocketAddress&)); 22 MOCK_METHOD1(Connect, bool(const talk_base::SocketAddress&));
25 MOCK_METHOD3(Read, bool(char*, size_t, size_t*)); 23 MOCK_METHOD3(Read, bool(char*, size_t, size_t*));
26 MOCK_METHOD2(Write, bool(const char*, size_t)); 24 MOCK_METHOD2(Write, bool(const char*, size_t));
27 MOCK_METHOD0(Close, bool()); 25 MOCK_METHOD0(Close, bool());
28 MOCK_METHOD1(StartTls, bool(const std::string&)); 26 MOCK_METHOD1(StartTls, bool(const std::string&));
29 }; 27 };
30 28
31 } // namespace notifier
32
33 // Extends WeakXmppClient to make jid() return a full jid, as required by
34 // PushNotificationsSubscribeTask.
35 class FakeWeakXmppClient : public notifier::WeakXmppClient {
36 public:
37 explicit FakeWeakXmppClient(talk_base::TaskParent* parent)
38 : notifier::WeakXmppClient(parent),
39 jid_("test@example.com/testresource") {}
40
41 virtual ~FakeWeakXmppClient() {}
42
43 virtual const buzz::Jid& jid() const OVERRIDE {
44 return jid_;
45 }
46
47 private:
48 buzz::Jid jid_;
49 };
50
51 namespace notifier {
52
53 FakeBaseTask::FakeBaseTask() { 29 FakeBaseTask::FakeBaseTask() {
54 // Owned by |task_pump_|. 30 // Owned by |task_pump_|.
55 FakeWeakXmppClient* weak_xmpp_client = 31 notifier::WeakXmppClient* weak_xmpp_client =
56 new FakeWeakXmppClient(&task_pump_); 32 new notifier::WeakXmppClient(&task_pump_);
57 33
58 weak_xmpp_client->Start(); 34 weak_xmpp_client->Start();
59 buzz::XmppClientSettings settings; 35 buzz::XmppClientSettings settings;
60 // Owned by |weak_xmpp_client|. 36 // Owned by |weak_xmpp_client|.
61 MockAsyncSocket* mock_async_socket = new MockAsyncSocket(); 37 MockAsyncSocket* mock_async_socket = new MockAsyncSocket();
62 EXPECT_CALL(*mock_async_socket, Connect(_)).WillOnce(Return(true)); 38 EXPECT_CALL(*mock_async_socket, Connect(_)).WillOnce(Return(true));
63 weak_xmpp_client->Connect(settings, "en", mock_async_socket, NULL); 39 weak_xmpp_client->Connect(settings, "en", mock_async_socket, NULL);
64 // Initialize the XMPP client. 40 // Initialize the XMPP client.
65 task_pump_.RunTasks(); 41 task_pump_.RunTasks();
66 42
67 base_task_ = weak_xmpp_client->AsWeakPtr(); 43 base_task_ = weak_xmpp_client->AsWeakPtr();
68 } 44 }
69 45
70 FakeBaseTask::~FakeBaseTask() {} 46 FakeBaseTask::~FakeBaseTask() {}
71 47
72 base::WeakPtr<buzz::XmppTaskParentInterface> FakeBaseTask::AsWeakPtr() { 48 base::WeakPtr<buzz::XmppTaskParentInterface> FakeBaseTask::AsWeakPtr() {
73 return base_task_; 49 return base_task_;
74 } 50 }
75 51
76 } // namespace notifier 52 } // namespace notifier
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/chrome_system_resources.cc ('k') | jingle/notifier/listener/notification_defines.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698