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

Side by Side Diff: webrtc/libjingle/xmpp/rostermodule_unittest.cc

Issue 1935893002: Replace scoped_ptr with unique_ptr in webrtc/libjingle/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « webrtc/libjingle/xmpp/pubsubtasks_unittest.cc ('k') | webrtc/libjingle/xmpp/rostermoduleimpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 <iostream> 11 #include <iostream>
12 #include <memory>
12 #include <sstream> 13 #include <sstream>
13 #include <string> 14 #include <string>
14 15
15 #include "webrtc/libjingle/xmllite/xmlelement.h" 16 #include "webrtc/libjingle/xmllite/xmlelement.h"
16 #include "webrtc/libjingle/xmpp/constants.h" 17 #include "webrtc/libjingle/xmpp/constants.h"
17 #include "webrtc/libjingle/xmpp/rostermodule.h" 18 #include "webrtc/libjingle/xmpp/rostermodule.h"
18 #include "webrtc/libjingle/xmpp/util_unittest.h" 19 #include "webrtc/libjingle/xmpp/util_unittest.h"
19 #include "webrtc/libjingle/xmpp/xmppengine.h" 20 #include "webrtc/libjingle/xmpp/xmppengine.h"
20 #include "webrtc/base/gunit.h" 21 #include "webrtc/base/gunit.h"
21 #include "webrtc/base/scoped_ptr.h"
22 22
23 #define TEST_OK(x) EXPECT_EQ((x),XMPP_RETURN_OK) 23 #define TEST_OK(x) EXPECT_EQ((x),XMPP_RETURN_OK)
24 #define TEST_BADARGUMENT(x) EXPECT_EQ((x),XMPP_RETURN_BADARGUMENT) 24 #define TEST_BADARGUMENT(x) EXPECT_EQ((x),XMPP_RETURN_BADARGUMENT)
25 25
26 26
27 namespace buzz { 27 namespace buzz {
28 28
29 class RosterModuleTest; 29 class RosterModuleTest;
30 30
31 static void 31 static void
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 XmppTestHandler* handler) { 243 XmppTestHandler* handler) {
244 // Needs to be similar to XmppEngineTest::RunLogin 244 // Needs to be similar to XmppEngineTest::RunLogin
245 } 245 }
246 }; 246 };
247 247
248 TEST_F(RosterModuleTest, TestPresence) { 248 TEST_F(RosterModuleTest, TestPresence) {
249 XmlElement* status = new XmlElement(QN_GOOGLE_PSTN_CONFERENCE_STATUS); 249 XmlElement* status = new XmlElement(QN_GOOGLE_PSTN_CONFERENCE_STATUS);
250 status->AddAttr(QN_STATUS, STR_PSTN_CONFERENCE_STATUS_CONNECTING); 250 status->AddAttr(QN_STATUS, STR_PSTN_CONFERENCE_STATUS_CONNECTING);
251 XmlElement presence_xml(QN_PRESENCE); 251 XmlElement presence_xml(QN_PRESENCE);
252 presence_xml.AddElement(status); 252 presence_xml.AddElement(status);
253 rtc::scoped_ptr<XmppPresence> presence(XmppPresence::Create()); 253 std::unique_ptr<XmppPresence> presence(XmppPresence::Create());
254 presence->set_raw_xml(&presence_xml); 254 presence->set_raw_xml(&presence_xml);
255 EXPECT_EQ(presence->connection_status(), XMPP_CONNECTION_STATUS_CONNECTING); 255 EXPECT_EQ(presence->connection_status(), XMPP_CONNECTION_STATUS_CONNECTING);
256 } 256 }
257 257
258 TEST_F(RosterModuleTest, TestOutgoingPresence) { 258 TEST_F(RosterModuleTest, TestOutgoingPresence) {
259 std::stringstream dump; 259 std::stringstream dump;
260 260
261 rtc::scoped_ptr<XmppEngine> engine(XmppEngine::Create()); 261 std::unique_ptr<XmppEngine> engine(XmppEngine::Create());
262 XmppTestHandler handler(engine.get()); 262 XmppTestHandler handler(engine.get());
263 XmppTestRosterHandler roster_handler; 263 XmppTestRosterHandler roster_handler;
264 264
265 rtc::scoped_ptr<XmppRosterModule> roster(XmppRosterModule::Create()); 265 std::unique_ptr<XmppRosterModule> roster(XmppRosterModule::Create());
266 roster->set_roster_handler(&roster_handler); 266 roster->set_roster_handler(&roster_handler);
267 267
268 // Configure the roster module 268 // Configure the roster module
269 roster->RegisterEngine(engine.get()); 269 roster->RegisterEngine(engine.get());
270 270
271 // Set up callbacks 271 // Set up callbacks
272 engine->SetOutputHandler(&handler); 272 engine->SetOutputHandler(&handler);
273 engine->AddStanzaHandler(&handler); 273 engine->AddStanzaHandler(&handler);
274 engine->SetSessionHandler(&handler); 274 engine->SetSessionHandler(&handler);
275 275
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 EXPECT_EQ(roster_handler.StrClear(), ""); 357 EXPECT_EQ(roster_handler.StrClear(), "");
358 EXPECT_EQ(handler.OutputActivity(), 358 EXPECT_EQ(handler.OutputActivity(),
359 "<presence type=\"unavailable\">" 359 "<presence type=\"unavailable\">"
360 "<priority>42</priority>" 360 "<priority>42</priority>"
361 "<status xml:lang=\"es\">Hola Amigos!</status>" 361 "<status xml:lang=\"es\">Hola Amigos!</status>"
362 "<status>Hey there, friend!</status>" 362 "<status>Hey there, friend!</status>"
363 "</presence>"); 363 "</presence>");
364 EXPECT_EQ(handler.SessionActivity(), ""); 364 EXPECT_EQ(handler.SessionActivity(), "");
365 365
366 // Construct a directed presence 366 // Construct a directed presence
367 rtc::scoped_ptr<XmppPresence> directed_presence(XmppPresence::Create()); 367 std::unique_ptr<XmppPresence> directed_presence(XmppPresence::Create());
368 TEST_OK(directed_presence->set_available(XMPP_PRESENCE_AVAILABLE)); 368 TEST_OK(directed_presence->set_available(XMPP_PRESENCE_AVAILABLE));
369 TEST_OK(directed_presence->set_priority(120)); 369 TEST_OK(directed_presence->set_priority(120));
370 TEST_OK(directed_presence->set_status("*very* available")); 370 TEST_OK(directed_presence->set_status("*very* available"));
371 TEST_OK(roster->SendDirectedPresence(directed_presence.get(), 371 TEST_OK(roster->SendDirectedPresence(directed_presence.get(),
372 Jid("myhoney@honey.net"))); 372 Jid("myhoney@honey.net")));
373 373
374 EXPECT_EQ(roster_handler.StrClear(), ""); 374 EXPECT_EQ(roster_handler.StrClear(), "");
375 EXPECT_EQ(handler.OutputActivity(), 375 EXPECT_EQ(handler.OutputActivity(),
376 "<presence to=\"myhoney@honey.net\">" 376 "<presence to=\"myhoney@honey.net\">"
377 "<priority>120</priority>" 377 "<priority>120</priority>"
378 "<status>*very* available</status>" 378 "<status>*very* available</status>"
379 "</presence>"); 379 "</presence>");
380 EXPECT_EQ(handler.SessionActivity(), ""); 380 EXPECT_EQ(handler.SessionActivity(), "");
381 } 381 }
382 382
383 TEST_F(RosterModuleTest, TestIncomingPresence) { 383 TEST_F(RosterModuleTest, TestIncomingPresence) {
384 rtc::scoped_ptr<XmppEngine> engine(XmppEngine::Create()); 384 std::unique_ptr<XmppEngine> engine(XmppEngine::Create());
385 XmppTestHandler handler(engine.get()); 385 XmppTestHandler handler(engine.get());
386 XmppTestRosterHandler roster_handler; 386 XmppTestRosterHandler roster_handler;
387 387
388 rtc::scoped_ptr<XmppRosterModule> roster(XmppRosterModule::Create()); 388 std::unique_ptr<XmppRosterModule> roster(XmppRosterModule::Create());
389 roster->set_roster_handler(&roster_handler); 389 roster->set_roster_handler(&roster_handler);
390 390
391 // Configure the roster module 391 // Configure the roster module
392 roster->RegisterEngine(engine.get()); 392 roster->RegisterEngine(engine.get());
393 393
394 // Set up callbacks 394 // Set up callbacks
395 engine->SetOutputHandler(&handler); 395 engine->SetOutputHandler(&handler);
396 engine->AddStanzaHandler(&handler); 396 engine->AddStanzaHandler(&handler);
397 engine->SetSessionHandler(&handler); 397 engine->SetSessionHandler(&handler);
398 398
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 "to=\"david@my-server/test\" type=\"unavailable\" " 506 "to=\"david@my-server/test\" type=\"unavailable\" "
507 "xmlns:cli=\"jabber:client\">" 507 "xmlns:cli=\"jabber:client\">"
508 "<cli:status>Stealing my rug back</cli:status>" 508 "<cli:status>Stealing my rug back</cli:status>"
509 "<cli:priority>-10</cli:priority>" 509 "<cli:priority>-10</cli:priority>"
510 "</cli:presence>]"); 510 "</cli:presence>]");
511 EXPECT_EQ(handler.OutputActivity(), ""); 511 EXPECT_EQ(handler.OutputActivity(), "");
512 handler.SessionActivity(); // Ignore the session output 512 handler.SessionActivity(); // Ignore the session output
513 } 513 }
514 514
515 TEST_F(RosterModuleTest, TestPresenceSubscription) { 515 TEST_F(RosterModuleTest, TestPresenceSubscription) {
516 rtc::scoped_ptr<XmppEngine> engine(XmppEngine::Create()); 516 std::unique_ptr<XmppEngine> engine(XmppEngine::Create());
517 XmppTestHandler handler(engine.get()); 517 XmppTestHandler handler(engine.get());
518 XmppTestRosterHandler roster_handler; 518 XmppTestRosterHandler roster_handler;
519 519
520 rtc::scoped_ptr<XmppRosterModule> roster(XmppRosterModule::Create()); 520 std::unique_ptr<XmppRosterModule> roster(XmppRosterModule::Create());
521 roster->set_roster_handler(&roster_handler); 521 roster->set_roster_handler(&roster_handler);
522 522
523 // Configure the roster module 523 // Configure the roster module
524 roster->RegisterEngine(engine.get()); 524 roster->RegisterEngine(engine.get());
525 525
526 // Set up callbacks 526 // Set up callbacks
527 engine->SetOutputHandler(&handler); 527 engine->SetOutputHandler(&handler);
528 engine->AddStanzaHandler(&handler); 528 engine->AddStanzaHandler(&handler);
529 engine->SetSessionHandler(&handler); 529 engine->SetSessionHandler(&handler);
530 530
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 EXPECT_EQ(roster_handler.StrClear(), ""); 569 EXPECT_EQ(roster_handler.StrClear(), "");
570 EXPECT_EQ(handler.OutputActivity(), 570 EXPECT_EQ(handler.OutputActivity(),
571 "<presence to=\"maude@example.net\" type=\"subscribe\"/>" 571 "<presence to=\"maude@example.net\" type=\"subscribe\"/>"
572 "<presence to=\"maude@example.net\" type=\"unsubscribe\"/>" 572 "<presence to=\"maude@example.net\" type=\"unsubscribe\"/>"
573 "<presence to=\"maude@example.net\" type=\"subscribed\"/>" 573 "<presence to=\"maude@example.net\" type=\"subscribed\"/>"
574 "<presence to=\"maude@example.net\" type=\"unsubscribed\"/>"); 574 "<presence to=\"maude@example.net\" type=\"unsubscribed\"/>");
575 EXPECT_EQ(handler.SessionActivity(), ""); 575 EXPECT_EQ(handler.SessionActivity(), "");
576 } 576 }
577 577
578 TEST_F(RosterModuleTest, TestRosterReceive) { 578 TEST_F(RosterModuleTest, TestRosterReceive) {
579 rtc::scoped_ptr<XmppEngine> engine(XmppEngine::Create()); 579 std::unique_ptr<XmppEngine> engine(XmppEngine::Create());
580 XmppTestHandler handler(engine.get()); 580 XmppTestHandler handler(engine.get());
581 XmppTestRosterHandler roster_handler; 581 XmppTestRosterHandler roster_handler;
582 582
583 rtc::scoped_ptr<XmppRosterModule> roster(XmppRosterModule::Create()); 583 std::unique_ptr<XmppRosterModule> roster(XmppRosterModule::Create());
584 roster->set_roster_handler(&roster_handler); 584 roster->set_roster_handler(&roster_handler);
585 585
586 // Configure the roster module 586 // Configure the roster module
587 roster->RegisterEngine(engine.get()); 587 roster->RegisterEngine(engine.get());
588 588
589 // Set up callbacks 589 // Set up callbacks
590 engine->SetOutputHandler(&handler); 590 engine->SetOutputHandler(&handler);
591 engine->AddStanzaHandler(&handler); 591 engine->AddStanzaHandler(&handler);
592 engine->SetSessionHandler(&handler); 592 engine->SetSessionHandler(&handler);
593 593
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 "4:[Contact jid:jesus@example.net name:Jesus Quintana " 689 "4:[Contact jid:jesus@example.net name:Jesus Quintana "
690 "subscription_state:from groups:[Bowling League]]" 690 "subscription_state:from groups:[Bowling League]]"
691 "<ros:item jid=\"jesus@example.net\" name=\"Jesus Quintana\" " 691 "<ros:item jid=\"jesus@example.net\" name=\"Jesus Quintana\" "
692 "subscription=\"from\" xmlns:ros=\"jabber:iq:roster\">" 692 "subscription=\"from\" xmlns:ros=\"jabber:iq:roster\">"
693 "<ros:group>Bowling League</ros:group>" 693 "<ros:group>Bowling League</ros:group>"
694 "</ros:item>]"); 694 "</ros:item>]");
695 EXPECT_EQ(handler.OutputActivity(), ""); 695 EXPECT_EQ(handler.OutputActivity(), "");
696 EXPECT_EQ(handler.SessionActivity(), ""); 696 EXPECT_EQ(handler.SessionActivity(), "");
697 697
698 // Request that someone be added 698 // Request that someone be added
699 rtc::scoped_ptr<XmppRosterContact> contact(XmppRosterContact::Create()); 699 std::unique_ptr<XmppRosterContact> contact(XmppRosterContact::Create());
700 TEST_OK(contact->set_jid(Jid("brandt@example.net"))); 700 TEST_OK(contact->set_jid(Jid("brandt@example.net")));
701 TEST_OK(contact->set_name("Brandt")); 701 TEST_OK(contact->set_name("Brandt"));
702 TEST_OK(contact->AddGroup("Business Partners")); 702 TEST_OK(contact->AddGroup("Business Partners"));
703 TEST_OK(contact->AddGroup("Watchers")); 703 TEST_OK(contact->AddGroup("Watchers"));
704 TEST_OK(contact->AddGroup("Friends")); 704 TEST_OK(contact->AddGroup("Friends"));
705 TEST_OK(contact->RemoveGroup("Friends")); // Maybe not... 705 TEST_OK(contact->RemoveGroup("Friends")); // Maybe not...
706 TEST_OK(roster->RequestRosterChange(contact.get())); 706 TEST_OK(roster->RequestRosterChange(contact.get()));
707 707
708 EXPECT_EQ(roster_handler.StrClear(), ""); 708 EXPECT_EQ(roster_handler.StrClear(), "");
709 EXPECT_EQ(handler.OutputActivity(), 709 EXPECT_EQ(handler.OutputActivity(),
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 "subscription=\"from\" " 823 "subscription=\"from\" "
824 "xmlns:ros=\"jabber:iq:roster\">" 824 "xmlns:ros=\"jabber:iq:roster\">"
825 "<ros:group>Bowling League</ros:group>" 825 "<ros:group>Bowling League</ros:group>"
826 "</ros:item> index:4]"); 826 "</ros:item> index:4]");
827 EXPECT_EQ(handler.OutputActivity(), 827 EXPECT_EQ(handler.OutputActivity(),
828 "<iq type=\"result\" id=\"server_3\"/>"); 828 "<iq type=\"result\" id=\"server_3\"/>");
829 EXPECT_EQ(handler.SessionActivity(), ""); 829 EXPECT_EQ(handler.SessionActivity(), "");
830 } 830 }
831 831
832 } 832 }
OLDNEW
« no previous file with comments | « webrtc/libjingle/xmpp/pubsubtasks_unittest.cc ('k') | webrtc/libjingle/xmpp/rostermoduleimpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698