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")); }
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; }
void tst_IrcBuffer::testDebug() { QString str; QDebug dbg(&str); dbg << static_cast<IrcBuffer*>(0); QCOMPARE(str.trimmed(), QString::fromLatin1("IrcBuffer(0x0)")); str.clear(); IrcBuffer buffer; dbg << &buffer; QVERIFY(QRegExp("IrcBuffer\\(0x[0-9A-Fa-f]+\\) ").exactMatch(str)); str.clear(); buffer.setObjectName("obj"); dbg << &buffer; QVERIFY(QRegExp("IrcBuffer\\(0x[0-9A-Fa-f]+, name=obj\\) ").exactMatch(str)); str.clear(); buffer.setName("buf"); dbg << &buffer; QVERIFY(QRegExp("IrcBuffer\\(0x[0-9A-Fa-f]+, name=obj, title=buf\\) ").exactMatch(str)); str.clear(); }