示例#1
0
        void testHandleAckReceived_AcksStanza() {
            std::shared_ptr<StanzaAckRequester> testling(createRequester());
            testling->handleStanzaSent(createMessage("m1"));

            testling->handleAckReceived(1);

            CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(ackedStanzas.size()));
            CPPUNIT_ASSERT_EQUAL(std::string("m1"), ackedStanzas[0]->getID());
        }
		void testHandleAckRequestReceived_AcksStanza() {
			boost::shared_ptr<StanzaAckResponder> testling(createResponder());
			testling->handleStanzaReceived();

			testling->handleAckRequestReceived();

			CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(acks.size()));
			CPPUNIT_ASSERT_EQUAL(1U, acks[0]);
		}
示例#3
0
        void testSetXMPPStatus_Offline() {
            MenuletController testling(menulet);

            testling.setXMPPStatus("You are not connected", MenuletController::Offline);

            size_t i = 0;
            CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("[Offline] You are not connected"), menulet->items[i++]);
        }
示例#4
0
        void testSetUserNames_NoUsers() {
            MenuletController testling(menulet);

            std::vector<std::string> users;
            testling.setUserNames(users);

            size_t i = 0;
            CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
        }
		void testHandleAckRequestReceived_AcksMultipleStanzas() {
			std::auto_ptr<StanzaAckResponder> testling(createResponder());
			testling->handleStanzaReceived();
			testling->handleStanzaReceived();

			testling->handleAckRequestReceived();

			CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(acks.size()));
			CPPUNIT_ASSERT_EQUAL(2U, acks[0]);
		}
		// Handle stanza ack count wrapping, as per the XEP
		void testHandleAckRequestReceived_WrapAround() {
			boost::shared_ptr<StanzaAckResponder> testling(createResponder());
			testling->handledStanzasCount = boost::numeric_cast<unsigned int>((1ULL<<32) - 1);
			testling->handleStanzaReceived();
			testling->handleStanzaReceived();

			testling->handleAckRequestReceived();

			CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(acks.size()));
			CPPUNIT_ASSERT_EQUAL(1U, acks[0]);
		}
示例#7
0
        // Handle stanza ack count wrapping, as per the XEP
        void testHandleAckReceived_WrapAround() {
            std::shared_ptr<StanzaAckRequester> testling(createRequester());
            testling->lastHandledStanzasCount = boost::numeric_cast<unsigned int>((1ULL<<32) - 1);
            testling->handleStanzaSent(createMessage("m1"));
            testling->handleStanzaSent(createMessage("m2"));

            testling->handleAckReceived(1);

            CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(ackedStanzas.size()));
            CPPUNIT_ASSERT_EQUAL(std::string("m1"), ackedStanzas[0]->getID());
            CPPUNIT_ASSERT_EQUAL(std::string("m2"), ackedStanzas[1]->getID());
        }
示例#8
0
        void testHandleAckReceived_AcksMultipleStanzas() {
            std::shared_ptr<StanzaAckRequester> testling(createRequester());
            testling->handleStanzaSent(createIQ("iq1"));
            testling->handleStanzaSent(createPresence("p1"));
            testling->handleStanzaSent(createMessage("m1"));

            testling->handleAckReceived(3);

            CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(ackedStanzas.size()));
            CPPUNIT_ASSERT_EQUAL(std::string("iq1"), ackedStanzas[0]->getID());
            CPPUNIT_ASSERT_EQUAL(std::string("p1"), ackedStanzas[1]->getID());
            CPPUNIT_ASSERT_EQUAL(std::string("m1"), ackedStanzas[2]->getID());
        }
示例#9
0
        void testSetUserNames() {
            MenuletController testling(menulet);

            std::vector<std::string> users;
            users.push_back("Alice In Wonderland");
            users.push_back("The Mad Hatter");
            testling.setUserNames(users);

            size_t i = 0;
            CPPUNIT_ASSERT_EQUAL(std::string("Online users:"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("  Alice In Wonderland"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("  The Mad Hatter"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
        }
示例#10
0
        void testConstructor() {
            MenuletController testling(menulet);

            CPPUNIT_ASSERT_EQUAL(8, static_cast<int>(menulet->items.size()));
            size_t i = 0;
            CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("[Offline] "), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("*About*"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("*Restart*"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("*Exit*"), menulet->items[i++]);
        }
示例#11
0
        void testUpdate() {
            MenuletController testling(menulet);

            testling.setXMPPStatus("You are connected", MenuletController::Online);

            CPPUNIT_ASSERT_EQUAL(8, static_cast<int>(menulet->items.size()));
            size_t i = 0;
            CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("[Online] You are connected"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("*About*"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("*Restart*"), menulet->items[i++]);
            CPPUNIT_ASSERT_EQUAL(std::string("*Exit*"), menulet->items[i++]);
        }
示例#12
0
        void testHandleStanzaSent_PresenceDoesNotRequestAck() {
            std::shared_ptr<StanzaAckRequester> testling(createRequester());
            testling->handleStanzaSent(createPresence("p1"));

            CPPUNIT_ASSERT_EQUAL(0, acksRequested);
        }
示例#13
0
        void testHandleStanzaSent_MessageRequestsAck() {
            std::shared_ptr<StanzaAckRequester> testling(createRequester());
            testling->handleStanzaSent(createMessage("m1"));

            CPPUNIT_ASSERT_EQUAL(1, acksRequested);
        }