/* * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include std::ostream& operator<<(std::ostream& os, const Swift::TableRoster::Index& i); std::ostream& operator<<(std::ostream& os, const Swift::TableRoster::Index& i) { os << "(" << i.section << ", " << i.row << ")"; return os; } #include #include #include #include #include #include #include #include using namespace Swift; class TableRosterTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(TableRosterTest); CPPUNIT_TEST(testAddContact_EmptyRoster); CPPUNIT_TEST_SUITE_END(); public: void setUp() { timerFactory = new DummyTimerFactory(); roster = new Roster(); jid1 = JID("jid1@example.com"); jid2 = JID("jid2@example.com"); } void tearDown() { delete roster; delete timerFactory; } void testAddContact_EmptyRoster() { /* std::shared_ptr tableRoster(createTestling()); addContact(jid1, "1", "group1"); CPPUNIT_ASSERT_EQUAL(4, static_cast(events.size())); CPPUNIT_ASSERT(boost::get(&events[0])); CPPUNIT_ASSERT(boost::get(&events[1])); CPPUNIT_ASSERT_EQUAL(1, static_cast(boost::get(events[1]).sections.size())); CPPUNIT_ASSERT_EQUAL(0, static_cast(boost::get(events[1]).sections[0])); CPPUNIT_ASSERT(boost::get(&events[2])); CPPUNIT_ASSERT_EQUAL(1, static_cast(boost::get(events[2]).rows.size())); CPPUNIT_ASSERT_EQUAL(TableRoster::Index(0, 0), boost::get(events[2]).rows[0]); CPPUNIT_ASSERT(boost::get(&events[3])); CPPUNIT_ASSERT_EQUAL(1, static_cast(tableRoster->getNumberOfSections())); CPPUNIT_ASSERT_EQUAL(std::string("group1"), tableRoster->getSectionTitle(0)); CPPUNIT_ASSERT_EQUAL(1, static_cast(tableRoster->getNumberOfRowsInSection(0))); CPPUNIT_ASSERT_EQUAL(jid1, tableRoster->getItem(TableRoster::Index(0, 0)).jid); */ } private: void addContact(const JID& jid, const std::string& name, const std::string& group) { roster->addContact(jid, JID(), name, group, ""); } TableRoster* createTestling() { TableRoster* result = new TableRoster(roster, timerFactory, 10); result->onUpdate.connect(boost::bind(&TableRosterTest::handleUpdate, this, _1)); return result; } void handleUpdate(const TableRoster::Update& update) { updates.push_back(update); } private: DummyTimerFactory* timerFactory; Roster* roster; JID jid1; JID jid2; std::vector updates; }; CPPUNIT_TEST_SUITE_REGISTRATION(TableRosterTest);