| 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/jid.h" | 18 #include "webrtc/libjingle/xmpp/jid.h" |
| 18 #include "webrtc/libjingle/xmpp/pubsubclient.h" | 19 #include "webrtc/libjingle/xmpp/pubsubclient.h" |
| 19 #include "webrtc/base/faketaskrunner.h" | 20 #include "webrtc/base/faketaskrunner.h" |
| 20 #include "webrtc/base/gunit.h" | 21 #include "webrtc/base/gunit.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 client->SignalPublishResult.connect( | 97 client->SignalPublishResult.connect( |
| 97 listener.get(), &TestPubSubItemsListener::OnPublishResult); | 98 listener.get(), &TestPubSubItemsListener::OnPublishResult); |
| 98 client->SignalPublishError.connect( | 99 client->SignalPublishError.connect( |
| 99 listener.get(), &TestPubSubItemsListener::OnPublishError); | 100 listener.get(), &TestPubSubItemsListener::OnPublishError); |
| 100 client->SignalRetractResult.connect( | 101 client->SignalRetractResult.connect( |
| 101 listener.get(), &TestPubSubItemsListener::OnRetractResult); | 102 listener.get(), &TestPubSubItemsListener::OnRetractResult); |
| 102 client->SignalRetractError.connect( | 103 client->SignalRetractError.connect( |
| 103 listener.get(), &TestPubSubItemsListener::OnRetractError); | 104 listener.get(), &TestPubSubItemsListener::OnRetractError); |
| 104 } | 105 } |
| 105 | 106 |
| 106 rtc::scoped_ptr<rtc::FakeTaskRunner> runner; | 107 std::unique_ptr<rtc::FakeTaskRunner> runner; |
| 107 // xmpp_client deleted by deleting runner. | 108 // xmpp_client deleted by deleting runner. |
| 108 buzz::FakeXmppClient* xmpp_client; | 109 buzz::FakeXmppClient* xmpp_client; |
| 109 rtc::scoped_ptr<buzz::PubSubClient> client; | 110 std::unique_ptr<buzz::PubSubClient> client; |
| 110 rtc::scoped_ptr<TestPubSubItemsListener> listener; | 111 std::unique_ptr<TestPubSubItemsListener> listener; |
| 111 buzz::Jid pubsubjid; | 112 buzz::Jid pubsubjid; |
| 112 std::string node; | 113 std::string node; |
| 113 std::string itemid; | 114 std::string itemid; |
| 114 }; | 115 }; |
| 115 | 116 |
| 116 TEST_F(PubSubClientTest, TestRequest) { | 117 TEST_F(PubSubClientTest, TestRequest) { |
| 117 client->RequestItems(); | 118 client->RequestItems(); |
| 118 | 119 |
| 119 std::string expected_iq = | 120 std::string expected_iq = |
| 120 "<cli:iq type=\"get\" to=\"room@domain.com\" id=\"0\" " | 121 "<cli:iq type=\"get\" to=\"room@domain.com\" id=\"0\" " |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 "<iq xmlns='jabber:client' id='0' type='error' from='room@domain.com'>" | 270 "<iq xmlns='jabber:client' id='0' type='error' from='room@domain.com'>" |
| 270 " <error type='auth'>" | 271 " <error type='auth'>" |
| 271 " <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" | 272 " <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" |
| 272 " </error>" | 273 " </error>" |
| 273 "</iq>"; | 274 "</iq>"; |
| 274 | 275 |
| 275 xmpp_client->HandleStanza(buzz::XmlElement::ForStr(result_iq)); | 276 xmpp_client->HandleStanza(buzz::XmlElement::ForStr(result_iq)); |
| 276 EXPECT_EQ(1, listener->error_count); | 277 EXPECT_EQ(1, listener->error_count); |
| 277 EXPECT_EQ(task_id, listener->error_task_id); | 278 EXPECT_EQ(task_id, listener->error_task_id); |
| 278 } | 279 } |
| OLD | NEW |