Verified Commit 6352f8a6 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

[autotests] Fix test regarding Item size

The tests were initially adapted when payload compression was introduce
to count with the Item size actually representing the compressed size
of the payload. When payload compression was later made optional and
disabled by default, the tests were not adapted back.
parent a050d9ae
......@@ -14,6 +14,7 @@
#include "agentmanager.h"
#include "attributefactory.h"
#include "collectionfetchjob.h"
#include "config_p.h"
#include "itemcreatejob.h"
#include "itemdeletejob.h"
#include "itemfetchjob.h"
......@@ -27,6 +28,9 @@ QTEST_AKONADIMAIN(ItemAppendTest)
void ItemAppendTest::initTestCase()
{
// The size checks in the test expects Item payload to not be compressed
QVERIFY(!Config::get().payloadCompression.enabled);
AkonadiTest::checkTestIsIsolated();
Control::start();
AkonadiTest::setAllResourcesOffline();
......@@ -228,9 +232,9 @@ void ItemAppendTest::testItemSize_data()
Item i(QStringLiteral("application/octet-stream"));
i.setPayload(QByteArray("ABCD"));
QTest::newRow("auto size") << i << 56LL;
QTest::newRow("auto size") << i << 4LL;
i.setSize(3);
QTest::newRow("too small") << i << 56LL;
QTest::newRow("too small") << i << 4LL;
i.setSize(100);
QTest::newRow("too large") << i << 100LL;
}
......
......@@ -11,6 +11,7 @@
#include "agentmanager.h"
#include "attributefactory.h"
#include "collectionfetchjob.h"
#include "config_p.h"
#include "control.h"
#include "itemcreatejob.h"
#include "itemdeletejob.h"
......@@ -32,6 +33,9 @@ static Collection res3;
void ItemStoreTest::initTestCase()
{
// The Item size tests expect the payload not to be compressed.
QVERIFY(!Config::get().payloadCompression.enabled);
AkonadiTest::checkTestIsIsolated();
Control::start();
AttributeFactory::registerAttribute<TestAttribute>();
......@@ -104,19 +108,19 @@ void ItemStoreTest::testDataChange_data()
QTest::addColumn<QByteArray>("data");
QTest::addColumn<qint64>("expectedSize");
QTest::newRow("simple") << QByteArray("testbody") << 60LL;
QTest::newRow("simple") << QByteArray("testbody") << 8LL;
QTest::newRow("null") << QByteArray() << 0LL;
QTest::newRow("empty") << QByteArray("") << 0LL;
QTest::newRow("nullbyte") << QByteArray("\0", 1) << 56LL;
QTest::newRow("nullbyte2") << QByteArray("\0X", 2) << 56LL;
QTest::newRow("linebreaks") << QByteArray("line1\nline2\n\rline3\rline4\r\n") << 80LL;
QTest::newRow("linebreaks2") << QByteArray("line1\r\nline2\r\n\r\n") << 68LL;
QTest::newRow("linebreaks3") << QByteArray("line1\nline2") << 64LL;
QTest::newRow("nullbyte") << QByteArray("\0", 1) << 1LL;
QTest::newRow("nullbyte2") << QByteArray("\0X", 2) << 2LL;
QTest::newRow("linebreaks") << QByteArray("line1\nline2\n\rline3\rline4\r\n") << 26LL;
QTest::newRow("linebreaks2") << QByteArray("line1\r\nline2\r\n\r\n") << 16LL;
QTest::newRow("linebreaks3") << QByteArray("line1\nline2") << 11LL;
QByteArray b;
QTest::newRow("big") << b.fill('a', 1 << 20) << 280LL;
QTest::newRow("bignull") << b.fill('\0', 1 << 20) << 280LL;
QTest::newRow("bigcr") << b.fill('\r', 1 << 20) << 280LL;
QTest::newRow("biglf") << b.fill('\n', 1 << 20) << 280LL;
QTest::newRow("big") << b.fill('a', 1 << 20) << (1LL << 20);
QTest::newRow("bignull") << b.fill('\0', 1 << 20) << (1LL << 20);
QTest::newRow("bigcr") << b.fill('\r', 1 << 20) << (1LL << 20);
QTest::newRow("biglf") << b.fill('\n', 1 << 20) << (1LL << 20);
}
void ItemStoreTest::testDataChange()
......
......@@ -5,11 +5,11 @@
#pragma once
#include <memory>
#include "akonaditests_export.h"
namespace Akonadi
{
class Config
class AKONADI_TESTS_EXPORT Config
{
public:
explicit Config();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment