test for mutating after copying Package objects

required and mimetype were not working, and this tests to ensure
that doesn't break again
This commit is contained in:
Aaron Seigo 2014-08-08 06:45:38 +02:00
parent 9ee252475f
commit d376a9ac28
3 changed files with 28 additions and 0 deletions

View File

@ -12,6 +12,12 @@ find_package(Qt5Widgets REQUIRED)
# add_definitions( -DKDESRCDIR=${CMAKE_CURRENT_SOURCE_DIR} )
if(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION)
set(PLASMA_NO_KIO TRUE)
set(PLASMA_NO_PACKAGEKIT TRUE)
set(PLASMA_NO_PACKAGE_EXTRADATA TRUE)
endif()
MACRO(PLASMA_UNIT_TESTS)
FOREACH(_testname ${ARGN})
add_executable(${_testname} ${_testname}.cpp)

View File

@ -65,6 +65,27 @@ void PackageStructureTest::copyPerformance()
QVERIFY(t.elapsed() < 400);
}
void PackageStructureTest::mutateAfterCopy()
{
const bool mainscriptRequired = ps.isRequired("mainscript");
const QStringList imageMimeTypes = ps.mimeTypes("images");
Plasma::Package copy(ps);
copy.setRequired("mainscript", !mainscriptRequired);
QVERIFY(ps.isRequired("mainscript") == mainscriptRequired);
QVERIFY(ps.isRequired("mainscript") != copy.isRequired("mainscript"));
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
QVERIFY(!imageMimeTypes.isEmpty());
QStringList copyMimeTypes;
copyMimeTypes << imageMimeTypes.first();
copy.setMimeTypes("images", copyMimeTypes);
QCOMPARE(ps.mimeTypes("images"), imageMimeTypes);
QCOMPARE(copy.mimeTypes("images"), copyMimeTypes);
#endif
}
void PackageStructureTest::emptyContentsPrefix()
{
NoPrefixes package;

View File

@ -30,6 +30,7 @@ class PackageStructureTest : public QObject
private Q_SLOTS:
void initTestCase();
void copyPerformance();
void mutateAfterCopy();
void emptyContentsPrefix();
void multiplePaths();
void directories();