Ejemplo n.º 1
0
void tst_IrcMessage::testNoticeMessage()
{
    QFETCH(bool, valid);
    QFETCH(QByteArray, data);
    QFETCH(QString, target);
    QFETCH(QString, content);
    QFETCH(bool, priv);
    QFETCH(bool, reply);

    IrcConnection connection;
    connection.setNickName("communi");
    IrcMessage* message = IrcMessage::fromData(data, &connection);
    QCOMPARE(message->type(), IrcMessage::Notice);
    QCOMPARE(message->command(), QString("NOTICE"));
    QCOMPARE(message->property("valid").toBool(), valid);
    QCOMPARE(message->property("target").toString(), target);
    QCOMPARE(message->property("content").toString(), content);
    QCOMPARE(message->property("private").toBool(), priv);
    QCOMPARE(message->property("reply").toBool(), reply);

    IrcNoticeMessage* noticeMessage = qobject_cast<IrcNoticeMessage*>(message);
    QVERIFY(noticeMessage);
    QCOMPARE(noticeMessage->isValid(), valid);
    QCOMPARE(noticeMessage->target(), target);
    QCOMPARE(noticeMessage->content(), content);
    QCOMPARE(noticeMessage->isPrivate(), priv);
    QCOMPARE(noticeMessage->isReply(), reply);
}
Ejemplo n.º 2
0
static IrcBufferModel* createBufferModel(QObject* parent)
{
    IrcConnection* connection = new IrcConnection(parent);
    connection->setNickName("communi");
    IrcBufferModel* model = new IrcBufferModel(connection);
    IrcBuffer* server = new Server(model);
    server->setName("Lorem Ipsum");
    server->setSticky(true);
    model->add(server);
    model->add(createChannel("donec", model));
    model->add(createChannel("convallis", model));
    model->add(createChannel("sagittis", model));
    model->add(createChannel("magna", model));
    model->add(createChannel("tincidunt", model));
    model->add(createChannel("phasellus ", model));
    model->add(createChannel("tellus", model));
    model->add(createChannel("fermentum", model));
    model->add(createChannel("pharetra", model));
    model->add(createChannel("vehicula", model));
    model->add(createChannel("aliquam", model));
    model->add(createChannel("bibendum", model));
    model->add(createChannel("semper", model));
    model->add(createChannel("dictum", model));
    model->add(createChannel("rhoncus", model));
    return model;
}
Ejemplo n.º 3
0
void tst_IrcMessage::testPrivateMessage()
{
    QFETCH(bool, valid);
    QFETCH(QString, cap);
    QFETCH(QByteArray, data);
    QFETCH(QString, target);
    QFETCH(QString, content);
    QFETCH(bool, priv);
    QFETCH(bool, action);
    QFETCH(bool, request);
    QFETCH(uint, flags);

    IrcConnection connection;
    connection.setNickName("communi");
    TestProtocol protocol(cap, &connection);
    static_cast<FriendConnection*>(&connection)->setProtocol(&protocol);

    IrcMessage* message = IrcMessage::fromData(data, &connection);
    QCOMPARE(message->type(), IrcMessage::Private);
    QCOMPARE(message->command(), QString("PRIVMSG"));
    QCOMPARE(message->property("valid").toBool(), valid);
    QCOMPARE(message->property("target").toString(), target);
    QCOMPARE(message->property("content").toString(), content);
    QCOMPARE(message->property("private").toBool(), priv);
    QCOMPARE(message->property("action").toBool(), action);
    QCOMPARE(message->property("request").toBool(), request);
    QCOMPARE(message->property("flags").toUInt(), flags);

    IrcPrivateMessage* privateMessage = qobject_cast<IrcPrivateMessage*>(message);
    QVERIFY(privateMessage);
    QCOMPARE(privateMessage->isValid(), valid);
    QCOMPARE(privateMessage->target(), target);
    QCOMPARE(privateMessage->content(), content);
    QCOMPARE(privateMessage->isPrivate(), priv);
    QCOMPARE(privateMessage->isAction(), action);
    QCOMPARE(privateMessage->isRequest(), request);
    QCOMPARE(static_cast<uint>(privateMessage->flags()), flags);
}