本文整理汇总了C++中Entry::attachments方法的典型用法代码示例。如果您正苦于以下问题:C++ Entry::attachments方法的具体用法?C++ Entry::attachments怎么用?C++ Entry::attachments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entry
的用法示例。
在下文中一共展示了Entry::attachments方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
void TestKeePass2Reader::testFormat200()
{
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/Format200.kdbx");
CompositeKey key;
key.addKey(PasswordKey("a"));
KeePass2Reader reader;
Database* db = reader.readDatabase(filename, key);
QVERIFY(db);
QVERIFY(!reader.hasError());
QCOMPARE(db->rootGroup()->name(), QString("Format200"));
QVERIFY(!db->metadata()->protectTitle());
QVERIFY(db->metadata()->protectUsername());
QVERIFY(!db->metadata()->protectPassword());
QVERIFY(db->metadata()->protectUrl());
QVERIFY(!db->metadata()->protectNotes());
QCOMPARE(db->rootGroup()->entries().size(), 1);
Entry* entry = db->rootGroup()->entries().at(0);
QCOMPARE(entry->title(), QString("Sample Entry"));
QCOMPARE(entry->username(), QString("User Name"));
QCOMPARE(entry->attachments()->keys().size(), 2);
QCOMPARE(entry->attachments()->value("myattach.txt"), QByteArray("abcdefghijk"));
QCOMPARE(entry->attachments()->value("test.txt"), QByteArray("this is a test"));
QCOMPARE(entry->historyItems().size(), 2);
QCOMPARE(entry->historyItems().at(0)->attachments()->keys().size(), 0);
QCOMPARE(entry->historyItems().at(1)->attachments()->keys().size(), 1);
QCOMPARE(entry->historyItems().at(1)->attachments()->value("myattach.txt"), QByteArray("abcdefghijk"));
delete db;
}
示例2: QCOMPARE
void TestKeePass2Writer::testAttachments()
{
Entry* entry = m_dbTest->rootGroup()->entries().at(0);
QCOMPARE(entry->attachments()->keys().size(), 2);
QCOMPARE(entry->attachments()->value("myattach.txt"), QByteArray("this is an attachment"));
QCOMPARE(entry->attachments()->value("aaa.txt"), QByteArray("also an attachment"));
}
示例3: QCOMPARE
void TestKeePass2Format::testKdbxAttachments()
{
Entry* entry = m_kdbxTargetDb->rootGroup()->entries().at(0);
QCOMPARE(entry->attachments()->keys().size(), 2);
QCOMPARE(entry->attachments()->value("myattach.txt"), QByteArray("this is an attachment"));
QCOMPARE(entry->attachments()->value("aaa.txt"), QByteArray("also an attachment"));
}
示例4: Database
void TestKeePass2Writer::initTestCase()
{
Crypto::init();
CompositeKey key;
key.addKey(PasswordKey("test"));
m_dbOrg = new Database();
m_dbOrg->setKey(key);
m_dbOrg->metadata()->setName("TESTDB");
Group* group = m_dbOrg->rootGroup();
group->setUuid(Uuid::random());
group->setNotes("I'm a note!");
Entry* entry = new Entry();
entry->setPassword(QString::fromUtf8("\xc3\xa4\xa3\xb6\xc3\xbc\xe9\x9b\xbb\xe7\xb4\x85"));
entry->setUuid(Uuid::random());
entry->attributes()->set("test", "protectedTest", true);
QVERIFY(entry->attributes()->isProtected("test"));
entry->attachments()->set("myattach.txt", QByteArray("this is an attachment"));
entry->attachments()->set("aaa.txt", QByteArray("also an attachment"));
entry->setGroup(group);
Group* groupNew = new Group();
groupNew->setUuid(Uuid::random());
groupNew->setName("TESTGROUP");
groupNew->setNotes("I'm a sub group note!");
groupNew->setParent(group);
QBuffer buffer;
buffer.open(QBuffer::ReadWrite);
KeePass2Writer writer;
writer.writeDatabase(&buffer, m_dbOrg);
QVERIFY(!writer.error());
buffer.seek(0);
KeePass2Reader reader;
m_dbTest = reader.readDatabase(&buffer, key);
QVERIFY(!reader.hasError());
QVERIFY(m_dbTest);
}
示例5: testHistoryItem
void TestModified::testHistoryItem()
{
Entry* entry = new Entry();
QDateTime created = entry->timeInfo().creationTime();
entry->setUuid(Uuid::random());
entry->setTitle("a");
entry->setTags("a");
EntryAttributes* attributes = new EntryAttributes();
attributes->copyCustomKeysFrom(entry->attributes());
Entry* historyEntry;
int historyItemsSize = 0;
entry->beginUpdate();
entry->setTitle("a");
entry->setTags("a");
entry->setOverrideUrl("");
entry->endUpdate();
QCOMPARE(entry->historyItems().size(), historyItemsSize);
QDateTime modified = entry->timeInfo().lastModificationTime();
QTest::qSleep(10);
entry->beginUpdate();
entry->setTitle("b");
entry->endUpdate();
QCOMPARE(entry->historyItems().size(), ++historyItemsSize);
historyEntry = entry->historyItems().at(historyItemsSize - 1);
QCOMPARE(historyEntry->title(), QString("a"));
QCOMPARE(historyEntry->uuid(), entry->uuid());
QCOMPARE(historyEntry->tags(), entry->tags());
QCOMPARE(historyEntry->overrideUrl(), entry->overrideUrl());
QCOMPARE(historyEntry->timeInfo().creationTime(), created);
QCOMPARE(historyEntry->timeInfo().lastModificationTime(), modified);
QCOMPARE(historyEntry->historyItems().size(), 0);
entry->beginUpdate();
entry->setTags("b");
entry->endUpdate();
QCOMPARE(entry->historyItems().size(), ++historyItemsSize);
QCOMPARE(entry->historyItems().at(historyItemsSize - 1)->tags(), QString("a"));
entry->beginUpdate();
entry->attachments()->set("test", QByteArray("value"));
entry->endUpdate();
QCOMPARE(entry->historyItems().size(), ++historyItemsSize);
QCOMPARE(entry->historyItems().at(historyItemsSize - 1)->attachments()->keys().size(), 0);
attributes->set("k", "myvalue");
entry->beginUpdate();
entry->attributes()->copyCustomKeysFrom(attributes);
entry->endUpdate();
QCOMPARE(entry->historyItems().size(), ++historyItemsSize);
QVERIFY(!entry->historyItems().at(historyItemsSize - 1)->attributes()->keys().contains("k"));
delete attributes;
delete entry;
Database* db = new Database();
Group* root = db->rootGroup();
db->metadata()->setHistoryMaxItems(3);
db->metadata()->setHistoryMaxSize(-1);
Entry* historyEntry2;
Entry* entry2 = new Entry();
entry2->setGroup(root);
entry2->beginUpdate();
entry2->setTitle("1");
entry2->endUpdate();
entry2->beginUpdate();
entry2->setTitle("2");
entry2->endUpdate();
entry2->beginUpdate();
entry2->setTitle("3");
entry2->endUpdate();
QCOMPARE(entry2->historyItems().size(), 3);
entry2->beginUpdate();
entry2->setTitle("4");
entry2->endUpdate();
QCOMPARE(entry2->historyItems().size(), 3);
db->metadata()->setHistoryMaxItems(1);
entry2->beginUpdate();
entry2->setTitle("5");
entry2->endUpdate();
QCOMPARE(entry2->historyItems().size(), 1);
historyEntry2 = entry2->historyItems().at(0);
QCOMPARE(historyEntry2->title(), QString("4"));
db->metadata()->setHistoryMaxItems(-1);
for (int i = 0; i < 20; i++) {
entry2->beginUpdate();
entry2->setTitle("6");
entry2->endUpdate();
entry2->beginUpdate();
//.........这里部分代码省略.........