| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 | 13 |
| 13 #include "webrtc/libjingle/xmllite/qname.h" | 14 #include "webrtc/libjingle/xmllite/qname.h" |
| 14 #include "webrtc/libjingle/xmllite/xmlelement.h" | 15 #include "webrtc/libjingle/xmllite/xmlelement.h" |
| 15 #include "webrtc/libjingle/xmpp/constants.h" | 16 #include "webrtc/libjingle/xmpp/constants.h" |
| 16 #include "webrtc/libjingle/xmpp/fakexmppclient.h" | 17 #include "webrtc/libjingle/xmpp/fakexmppclient.h" |
| 17 #include "webrtc/libjingle/xmpp/iqtask.h" | 18 #include "webrtc/libjingle/xmpp/iqtask.h" |
| 18 #include "webrtc/libjingle/xmpp/jid.h" | 19 #include "webrtc/libjingle/xmpp/jid.h" |
| 19 #include "webrtc/libjingle/xmpp/pubsubtasks.h" | 20 #include "webrtc/libjingle/xmpp/pubsubtasks.h" |
| 20 #include "webrtc/base/faketaskrunner.h" | 21 #include "webrtc/base/faketaskrunner.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 public: | 74 public: |
| 74 PubSubTasksTest() : | 75 PubSubTasksTest() : |
| 75 pubsubjid("room@domain.com"), | 76 pubsubjid("room@domain.com"), |
| 76 node("topic"), | 77 node("topic"), |
| 77 itemid("key") { | 78 itemid("key") { |
| 78 runner.reset(new rtc::FakeTaskRunner()); | 79 runner.reset(new rtc::FakeTaskRunner()); |
| 79 client = new buzz::FakeXmppClient(runner.get()); | 80 client = new buzz::FakeXmppClient(runner.get()); |
| 80 listener.reset(new TestPubSubTasksListener()); | 81 listener.reset(new TestPubSubTasksListener()); |
| 81 } | 82 } |
| 82 | 83 |
| 83 rtc::scoped_ptr<rtc::FakeTaskRunner> runner; | 84 std::unique_ptr<rtc::FakeTaskRunner> runner; |
| 84 // Client deleted by deleting runner. | 85 // Client deleted by deleting runner. |
| 85 buzz::FakeXmppClient* client; | 86 buzz::FakeXmppClient* client; |
| 86 rtc::scoped_ptr<TestPubSubTasksListener> listener; | 87 std::unique_ptr<TestPubSubTasksListener> listener; |
| 87 buzz::Jid pubsubjid; | 88 buzz::Jid pubsubjid; |
| 88 std::string node; | 89 std::string node; |
| 89 std::string itemid; | 90 std::string itemid; |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 TEST_F(PubSubTasksTest, TestRequest) { | 93 TEST_F(PubSubTasksTest, TestRequest) { |
| 93 buzz::PubSubRequestTask* task = | 94 buzz::PubSubRequestTask* task = |
| 94 new buzz::PubSubRequestTask(client, pubsubjid, node); | 95 new buzz::PubSubRequestTask(client, pubsubjid, node); |
| 95 task->SignalResult.connect( | 96 task->SignalResult.connect( |
| 96 listener.get(), &TestPubSubTasksListener::OnRequestResult); | 97 listener.get(), &TestPubSubTasksListener::OnRequestResult); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 EXPECT_EQ(expected_iq, client->sent_stanzas()[0]->Str()); | 272 EXPECT_EQ(expected_iq, client->sent_stanzas()[0]->Str()); |
| 272 | 273 |
| 273 std::string result_iq = | 274 std::string result_iq = |
| 274 "<iq xmlns='jabber:client' id='0' type='result' from='room@domain.com'/>"; | 275 "<iq xmlns='jabber:client' id='0' type='result' from='room@domain.com'/>"; |
| 275 | 276 |
| 276 client->HandleStanza(buzz::XmlElement::ForStr(result_iq)); | 277 client->HandleStanza(buzz::XmlElement::ForStr(result_iq)); |
| 277 | 278 |
| 278 EXPECT_EQ(1, listener->result_count); | 279 EXPECT_EQ(1, listener->result_count); |
| 279 EXPECT_EQ(0, listener->error_count); | 280 EXPECT_EQ(0, listener->error_count); |
| 280 } | 281 } |
| OLD | NEW |