Beispiel #1
0
void tst_IrcBuffer::testTitleNamePrefix()
{
    IrcBuffer buffer;

    QSignalSpy titleSpy(&buffer, SIGNAL(titleChanged(QString)));
    QSignalSpy nameSpy(&buffer, SIGNAL(nameChanged(QString)));
    QSignalSpy prefixSpy(&buffer, SIGNAL(prefixChanged(QString)));
    QVERIFY(titleSpy.isValid());
    QVERIFY(nameSpy.isValid());
    QVERIFY(prefixSpy.isValid());

    buffer.setName("name");
    QCOMPARE(buffer.title(), QString("name"));
    QCOMPARE(buffer.name(), QString("name"));
    QCOMPARE(buffer.prefix(), QString());
    QCOMPARE(titleSpy.count(), 1);
    QCOMPARE(titleSpy.last().first().toString(), QString("name"));
    QCOMPARE(nameSpy.count(), 1);
    QCOMPARE(nameSpy.last().first().toString(), QString("name"));
    QCOMPARE(prefixSpy.count(), 0);

    buffer.setPrefix("prefix");
    QCOMPARE(buffer.title(), QString("prefixname"));
    QCOMPARE(buffer.name(), QString("name"));
    QCOMPARE(buffer.prefix(), QString("prefix"));
    QCOMPARE(titleSpy.count(), 2);
    QCOMPARE(titleSpy.last().first().toString(), QString("prefixname"));
    QCOMPARE(nameSpy.count(), 1);
    QCOMPARE(prefixSpy.count(), 1);
    QCOMPARE(prefixSpy.last().first().toString(), QString("prefix"));
}
Beispiel #2
0
void tst_QXYSeries::seriesName()
{
    QSignalSpy nameSpy(m_series, SIGNAL(nameChanged()));
    QCOMPARE(m_series->name(), QString());
    m_series->setName("seriesname");
    QCOMPARE(m_series->name(), QString("seriesname"));
    TRY_COMPARE(nameSpy.count(), 1);
}
Beispiel #3
0
void tst_IrcNetwork::testInfo()
{
    QFETCH(QByteArray, welcome);
    QFETCH(QString, name);
    QFETCH(QString, modes);
    QFETCH(QString, prefixes);
    QFETCH(QString, channelTypes);

    IrcNetwork* network = connection->network();

    QSignalSpy initSpy(network, SIGNAL(initialized()));
    QSignalSpy nameSpy(network, SIGNAL(nameChanged(QString)));
    QSignalSpy modesSpy(network, SIGNAL(modesChanged(QStringList)));
    QSignalSpy prefixesSpy(network, SIGNAL(prefixesChanged(QStringList)));
    QSignalSpy channelTypesSpy(network, SIGNAL(channelTypesChanged(QStringList)));

    QVERIFY(initSpy.isValid());
    QVERIFY(nameSpy.isValid());
    QVERIFY(modesSpy.isValid());
    QVERIFY(prefixesSpy.isValid());
    QVERIFY(channelTypesSpy.isValid());

    connection->open();
    QVERIFY(waitForOpened());
    QVERIFY(waitForWritten(welcome));

    QVERIFY(network->isInitialized());

    QCOMPARE(network->name(), name);
    QCOMPARE(network->modes(), modes.split("", QString::SkipEmptyParts));
    QCOMPARE(network->prefixes(), prefixes.split("", QString::SkipEmptyParts));
    QCOMPARE(network->channelTypes(), channelTypes.split("", QString::SkipEmptyParts));

    QCOMPARE(network->prefixes().count(), network->modes().count());
    for (int i = 0; i < network->prefixes().count(); ++i) {
        QString prefix = network->prefixes().at(i);
        QString mode = network->modes().at(i);
        QCOMPARE(network->prefixToMode(prefix), mode);
        QCOMPARE(network->modeToPrefix(mode), prefix);
    }

    QVERIFY(!network->channelTypes().isEmpty());
    QVERIFY(!network->isChannel("foo"));
    QVERIFY(network->isChannel(network->channelTypes().at(0) + "foo"));

    QVERIFY(!network->channelModes(IrcNetwork::TypeA).isEmpty());
    QVERIFY(!network->channelModes(IrcNetwork::TypeB).isEmpty());
    QVERIFY(!network->channelModes(IrcNetwork::TypeC).isEmpty());
    QVERIFY(!network->channelModes(IrcNetwork::TypeD).isEmpty());

    if (welcome.contains("NICKLEN="))
        QVERIFY(network->numericLimit(IrcNetwork::NickLength) != -1);
    else
        QCOMPARE(network->numericLimit(IrcNetwork::NickLength), -1);
    if (welcome.contains("CHANNELLEN="))
        QVERIFY(network->numericLimit(IrcNetwork::ChannelLength) != -1);
    else
        QCOMPARE(network->numericLimit(IrcNetwork::ChannelLength), -1);
    if (welcome.contains("TOPICLEN="))
        QVERIFY(network->numericLimit(IrcNetwork::TopicLength) != -1);
    else
        QCOMPARE(network->numericLimit(IrcNetwork::TopicLength), -1);
    if (welcome.contains("KICKLEN="))
        QVERIFY(network->numericLimit(IrcNetwork::KickReasonLength) != -1);
    else
        QCOMPARE(network->numericLimit(IrcNetwork::KickReasonLength), -1);
    if (welcome.contains("AWAYLEN="))
        QVERIFY(network->numericLimit(IrcNetwork::AwayReasonLength) != -1);
    else
        QCOMPARE(network->numericLimit(IrcNetwork::AwayReasonLength), -1);
    if (welcome.contains("MODES="))
        QVERIFY(network->numericLimit(IrcNetwork::ModeCount) != -1);
    else
        QCOMPARE(network->numericLimit(IrcNetwork::ModeCount), -1);
    if (welcome.contains("MONITOR="))
        QVERIFY(network->numericLimit(IrcNetwork::MonitorCount) != -1);
    else
        QCOMPARE(network->numericLimit(IrcNetwork::MonitorCount), -1);

    QCOMPARE(network->numericLimit(IrcNetwork::MessageLength), 512); // hard-coded :/

    if (welcome.contains("MAXLIST=")) {
        bool limited = false;
        foreach (const QString& mode, network->modes())
        if (network->modeLimit(mode) != -1)
            limited = true;
        QVERIFY(limited);
    }