ubuntu-ui-extras-0.1+14.04.20140331/ 0000755 0000152 0177776 00000000000 12316325546 017214 5 ustar pbuser nogroup 0000000 0000000 ubuntu-ui-extras-0.1+14.04.20140331/ubuntu-ui-extras.qmlproject 0000644 0000152 0177776 00000000335 12316325263 024554 0 ustar pbuser nogroup 0000000 0000000 import QmlProject 1.1
Project {
QmlFiles {
directory: "modules"
}
JavaScriptFiles {
directory: "modules"
}
Files {
filter: ["modules/Ubuntu/Components/Extras/qmldir"]
}
}
ubuntu-ui-extras-0.1+14.04.20140331/tests/ 0000755 0000152 0177776 00000000000 12316325546 020356 5 ustar pbuser nogroup 0000000 0000000 ubuntu-ui-extras-0.1+14.04.20140331/tests/CMakeLists.txt 0000644 0000152 0177776 00000000034 12316325263 023107 0 ustar pbuser nogroup 0000000 0000000 add_subdirectory(unittests)
ubuntu-ui-extras-0.1+14.04.20140331/tests/unittests/ 0000755 0000152 0177776 00000000000 12316325546 022420 5 ustar pbuser nogroup 0000000 0000000 ubuntu-ui-extras-0.1+14.04.20140331/tests/unittests/tst_ExampleDelegate.qml 0000644 0000152 0177776 00000001630 12316325263 027047 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright 2013 Canonical Ltd.
*
* This file is part of ubuntu-ui-extras.
*
* ubuntu-ui-extras is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* ubuntu-ui-extras is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import QtTest 1.0
import Ubuntu.Components.Extras 0.1
TestCase {
name: "ExampleDelegate"
function test_has_three_items() {
compare(example.model.count, 3)
}
Example {
id: example
}
}
ubuntu-ui-extras-0.1+14.04.20140331/tests/unittests/CMakeLists.txt 0000644 0000152 0177776 00000001777 12316325263 025170 0 ustar pbuser nogroup 0000000 0000000 include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/modules/Ubuntu/Components/Extras/plugin/share/
${CMAKE_SOURCE_DIR}/modules/Ubuntu/Components/Extras/plugin/example/
)
qt5_add_resources(sampledata_rc_srcs sampledata.qrc)
macro(generate_tests)
foreach(test ${ARGN})
add_executable(${test}
${test}.cpp
../../modules/Ubuntu/Components/Extras/plugin/share/imageresizer.cpp
${sampledata_rc_srcs}
)
qt5_use_modules(${test} Core Qml Quick Test)
target_link_libraries(${test}
${TPL_QT5_LIBRARIES}
ubuntu-ui-extras-plugin
)
add_test(${test}
${CMAKE_CURRENT_BINARY_DIR}/${test}
-xunitxml -o ${test}.xml
)
set_tests_properties(${test} PROPERTIES
ENVIRONMENT "QT_QPA_PLATFORM=minimal"
)
endforeach(test)
endmacro(generate_tests)
generate_tests(
tst_ShareImageResizer
tst_ExampleModelTests
)
ubuntu-ui-extras-0.1+14.04.20140331/tests/unittests/tst_ShareImageResizer.cpp 0000644 0000152 0177776 00000010214 12316325263 027361 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2012 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "imageresizer.h"
#include
#include
#include
const QString testFile = ":/assets/testfile.jpg";
const QString testFilePortrait = ":/assets/testfile_portrait.jpg";
class ShareImageResizerTest: public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void testProperties();
void testResizeImage();
void testInvalidFilename();
void testInvalidSide();
void testInvalidQuality();
void cleanupTestCase();
private:
ImageResizer *m_resizer;
};
void ShareImageResizerTest::initTestCase()
{
m_resizer = new ImageResizer(this);
}
void ShareImageResizerTest::cleanupTestCase()
{
delete m_resizer;
}
void ShareImageResizerTest::testProperties()
{
QSignalSpy fileSpy(m_resizer, SIGNAL(fileChanged()));
QSignalSpy largestSideSpy(m_resizer, SIGNAL(largestSideChanged()));
QSignalSpy qualitySpy(m_resizer, SIGNAL(qualityChanged()));
QSignalSpy resizedFileSpy(m_resizer, SIGNAL(resizedFileChanged()));
m_resizer->setFile(testFile);
QVERIFY(fileSpy.count() == 1);
QVERIFY(resizedFileSpy.count() == 1);
m_resizer->setLargestSide(1024);
QVERIFY(largestSideSpy.count() == 1);
QVERIFY(resizedFileSpy.count() == 2);
m_resizer->setQuality(110);
QVERIFY(qualitySpy.count() == 1);
QVERIFY(resizedFileSpy.count() == 3);
QVERIFY(m_resizer->file() == testFile);
QVERIFY(m_resizer->largestSide() == 1024);
QVERIFY(m_resizer->quality() == 100);
// Set to the same stuff again
m_resizer->setFile(testFile);
m_resizer->setLargestSide(1024);
m_resizer->setQuality(110);
// Test if all the changed signals are NOT emitted for a second time
QVERIFY(fileSpy.count() == 1);
QVERIFY(largestSideSpy.count() == 1);
QVERIFY(qualitySpy.count() == 1);
}
void ShareImageResizerTest::testResizeImage()
{
QSignalSpy resizedFileSpy(m_resizer, SIGNAL(resizedFileChanged()));
m_resizer->setLargestSide(128);
QVERIFY(resizedFileSpy.count() == 1);
QImage image(m_resizer->resizedFile());
QVERIFY(image.width() == 128);
QVERIFY(image.height() < 128);
m_resizer->setLargestSide(55000);
QImage original(m_resizer->file());
image = QImage(m_resizer->resizedFile());
QVERIFY(image.width() == original.width());
QVERIFY(image.height() == original.height());
m_resizer->setLargestSide(128);
m_resizer->setFile(testFilePortrait);
image = QImage(m_resizer->resizedFile());
QVERIFY(m_resizer->file() == testFilePortrait);
QVERIFY(image.height() == 128);
QVERIFY(image.width() < 128);
m_resizer->setLargestSide(55000);
original = QImage(m_resizer->file());
image = QImage(m_resizer->resizedFile());
QVERIFY(image.width() == original.width());
QVERIFY(image.height() == original.height());
}
void ShareImageResizerTest::testInvalidFilename()
{
QSignalSpy resizedFileSpy(m_resizer, SIGNAL(resizedFileChanged()));
m_resizer->setFile(testFile + QLatin1String("invalid"));
QVERIFY(m_resizer->resizedFile().isEmpty());
}
void ShareImageResizerTest::testInvalidSide()
{
QSignalSpy largestSideSpy(m_resizer, SIGNAL(largestSideChanged()));
m_resizer->setLargestSide(-100);
QVERIFY(m_resizer->largestSide() == 1);
}
void ShareImageResizerTest::testInvalidQuality()
{
QSignalSpy qualitySpy(m_resizer, SIGNAL(qualityChanged()));
m_resizer->setQuality(-100);
QVERIFY(m_resizer->quality() == 0);
m_resizer->setQuality(2000);
QVERIFY(m_resizer->quality() == 100);
}
QTEST_MAIN(ShareImageResizerTest)
#include "tst_ShareImageResizer.moc"
ubuntu-ui-extras-0.1+14.04.20140331/tests/unittests/tst_ExampleModelTests.cpp 0000644 0000152 0177776 00000002277 12316325263 027421 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright 2013 Canonical Ltd.
*
* This file is part of ubuntu-ui-extras.
*
* ubuntu-ui-extras is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* ubuntu-ui-extras is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
// Qt
#include
#include
#include
#include
// local
#include "example-model.h"
class ExampleModelTests : public QObject
{
Q_OBJECT
private:
ExampleModel* model;
private Q_SLOTS:
void init()
{
model = new ExampleModel;
}
void cleanup()
{
delete model;
}
void shouldHaveThreeItems()
{
QCOMPARE(model->rowCount(), 3);
}
};
QTEST_MAIN(ExampleModelTests)
#include "tst_ExampleModelTests.moc"
ubuntu-ui-extras-0.1+14.04.20140331/tests/unittests/assets/ 0000755 0000152 0177776 00000000000 12316325546 023722 5 ustar pbuser nogroup 0000000 0000000 ubuntu-ui-extras-0.1+14.04.20140331/tests/unittests/assets/testfile_portrait.jpg 0000644 0000152 0177776 00001210706 12316325263 030172 0 ustar pbuser nogroup 0000000 0000000 JFIF ` ` C
$ #," '.0,)7(44418=9'.<2432 C
2!!22222222222222222222222222222222222222222222222222
"
} !1AQa"q2#BR$3br
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz
w !1AQaq"2B #3Rbr
$4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ? 8 RsAHK@'␜`c.p?O^) })N:ar8;sJs0CFq;J>p Wi8HqK"Qz′bc
9+9
X^9'('PxzPݩ:B:R#4 qCɥ'.;;Rߊ8L= S{b#( x;tҎO|}iOiю{bcAtǧ41A#