share-app-0.12~+14.04.20140306/ 0000755 0000152 0177776 00000000000 12306030101 016070 5 ustar pbuser nogroup 0000000 0000000 share-app-0.12~+14.04.20140306/ShareApp/ 0000755 0000152 0177776 00000000000 12306030101 017573 5 ustar pbuser nogroup 0000000 0000000 share-app-0.12~+14.04.20140306/ShareApp/notifyqml.cpp 0000644 0000152 0177776 00000004146 12306027656 022353 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
#include
#include
#include
#include "notifyqml.h"
Notify::Notify(QObject *parent)
{
}
Notify::~Notify()
{
notify_uninit();
}
QString Notify::appName() const
{
return (!notify_is_initted()) ? "" : QString::fromUtf8(notify_get_app_name());
}
void Notify::setAppName(const QString &appName)
{
if (!notify_is_initted()) {
QByteArray data = appName.toUtf8();
notify_init(data.data());
Q_EMIT appNameChanged();
} else {
if (appName != QString::fromUtf8(notify_get_app_name())) {
QByteArray data = appName.toUtf8();
notify_set_app_name(data.data());
Q_EMIT appNameChanged();
}
}
}
void Notify::notify(const QString &title, const QString &message, const QString &icon)
{
QByteArray titleData = title.toUtf8();
QByteArray messageData = message.toUtf8();
QByteArray iconData = icon.toUtf8();
NotifyNotification* notification = notify_notification_new(titleData.data(), messageData.data(), iconData.data());
notify_notification_show(notification, NULL);
g_object_unref(notification);
}
bool Notify::sendDelayedNotification(const QString& title, const QString& icon, int delay)
{
QStringList arguments;
QString notifyCmd("sleep %1; /usr/bin/notify-send --icon=%2 '%3'");
arguments.append("-c");
arguments.append(notifyCmd.arg(delay).arg(icon).arg(title));
return QProcess::startDetached("/bin/sh", arguments);
}
share-app-0.12~+14.04.20140306/ShareApp/accounts.cpp 0000644 0000152 0177776 00000002175 12306027656 022150 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 "accounts.h"
#include
FacebookAccount::FacebookAccount(QObject *parent) :
QObject(parent),
m_accountId(-1)
{
Accounts::Manager manager;
Accounts::AccountIdList list = manager.accountList();
Q_FOREACH(unsigned int accountId, list) {
Accounts::Account* account = manager.account(accountId);
if (account->providerName() == "facebook") {
m_accountId = accountId;
m_accountName = account->displayName();
return;
}
}
}
share-app-0.12~+14.04.20140306/ShareApp/notifyqml.h 0000644 0000152 0177776 00000002334 12306027656 022015 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 .
*/
#ifndef NOTIFYQML_H
#define NOTIFYQML_H
#include
class Notify : public QObject
{
Q_OBJECT
Q_PROPERTY(QString appName READ appName WRITE setAppName NOTIFY appNameChanged)
public:
explicit Notify(QObject *parent = 0);
~Notify();
QString appName() const;
void setAppName(const QString& appName);
public Q_SLOTS:
bool sendDelayedNotification(const QString& title, const QString& icon, int delay);
Q_SIGNALS:
void appNameChanged();
public Q_SLOTS:
void notify(const QString& title, const QString& message, const QString& icon = QString());
};
#endif // NOTIFYQML_H
share-app-0.12~+14.04.20140306/ShareApp/accounts.h 0000644 0000152 0177776 00000002134 12306027656 021610 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 .
*/
#ifndef ACCOUNTSQML_H
#define ACCOUNTSQML_H
#include
#include
#include
class FacebookAccount : public QObject
{
Q_OBJECT
Q_PROPERTY(int id READ id)
Q_PROPERTY(QString name READ name)
public:
explicit FacebookAccount(QObject *parent = 0);
int id() const { return m_accountId; }
QString name() const { return m_accountName; }
private:
int m_accountId;
QString m_accountName;
};
#endif // ACCOUNTSQML_H
share-app-0.12~+14.04.20140306/ShareApp/CMakeLists.txt 0000644 0000152 0177776 00000002320 12306027656 022355 0 ustar pbuser nogroup 0000000 0000000 # QML plugin
set(plugin_SRCS
components.cpp
accounts.cpp
notifyqml.cpp
imagefilehack.cpp
imageresizer.cpp
)
set(plugin_HDRS
components.h
accounts.h
notifyqml.h
imagefilehack.h
imageresizer.h
)
add_library(share-qml SHARED ${plugin_SRCS} ${plugin_HDRS})
qt5_use_modules(share-qml Qml Quick Xml)
include_directories(
${ACCOUNTSQT_INCLUDE_DIRS}
${NOTIFY_INCLUDE_DIRS}
)
target_link_libraries(share-qml
${Qt5Qml_LIBRARIES}
${Qt5Quick_LIBRARIES}
${Qt5Xml_LIBRARIES}
${ACCOUNTSQT_LIBRARIES}
${NOTIFY_LIBRARIES}
)
# Qt5's cmake does not export QT_IMPORTS_DIR, lets query qmake on our own for now
get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION)
function(QUERY_QMAKE VAR RESULT)
exec_program(${QMAKE_EXECUTABLE} ARGS "-query ${VAR}" RETURN_VALUE return_code OUTPUT_VARIABLE output )
if(NOT return_code)
file(TO_CMAKE_PATH "${output}" output)
set(${RESULT} ${output} PARENT_SCOPE)
endif(NOT return_code)
endfunction(QUERY_QMAKE)
query_qmake(QT_INSTALL_QML QT_IMPORTS_DIR)
set(PLUGIN_DIR ${QT_IMPORTS_DIR}/ShareApp)
install(TARGETS share-qml DESTINATION ${PLUGIN_DIR})
install(FILES qmldir DESTINATION ${PLUGIN_DIR})
share-app-0.12~+14.04.20140306/ShareApp/components.cpp 0000644 0000152 0177776 00000002352 12306027656 022513 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2012 Canonical, Ltd.
*
* Authors:
* Ugo Riboni
*
* 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
#include "components.h"
#include "accounts.h"
#include "notifyqml.h"
#include "imagefilehack.h"
#include "imageresizer.h"
void Components::registerTypes(const char *uri)
{
qmlRegisterType(uri, 0, 1, "FacebookAccount");
qmlRegisterType(uri, 0, 1, "Notify");
qmlRegisterType(uri, 0, 1, "ImageFileHack");
qmlRegisterType(uri, 0, 1, "ImageResizer");
}
void Components::initializeEngine(QQmlEngine *engine, const char *uri)
{
QQmlExtensionPlugin::initializeEngine(engine, uri);
}
share-app-0.12~+14.04.20140306/ShareApp/imageresizer.cpp 0000644 0000152 0177776 00000006157 12306027656 023023 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
#include
ImageResizer::ImageResizer(QObject *parent) :
QObject(parent),
m_resizedImage(NULL),
m_largestSide(2048),
m_quality(85)
{
}
QString ImageResizer::file() const
{
return m_file;
}
QString ImageResizer::resizedFile() const
{
return (m_resizedImage) ? m_resizedImage->fileName() : "";
}
int ImageResizer::largestSide() const
{
return m_largestSide;
}
int ImageResizer::quality() const
{
return m_quality;
}
void ImageResizer::setFile(const QString& file)
{
if (m_file != file) {
m_file = file;
Q_EMIT fileChanged();
resizeImage();
}
}
void ImageResizer::setLargestSide(int largestSide)
{
if (largestSide <= 0) {
largestSide = 1;
}
if (m_largestSide != largestSide) {
m_largestSide = largestSide;
Q_EMIT largestSideChanged();
resizeImage();
}
}
void ImageResizer::setQuality(int quality)
{
if (quality < 0) {
quality = 0;
} else if (quality > 100) {
quality = 100;
}
if (m_quality != quality) {
m_quality = quality;
Q_EMIT qualityChanged();
resizeImage();
}
}
void ImageResizer::resizeImage()
{
QImage image;
QFileInfo source(m_file);
if (m_file.isEmpty() || m_largestSide <= 0 ||
!source.exists() || !image.load(m_file)) {
if (m_resizedImage) {
delete m_resizedImage;
m_resizedImage = NULL;
}
Q_EMIT resizedFileChanged();
return;
}
QImage scaledImage;
if (image.height() > image.width()) {
if (m_largestSide > image.height()) {
scaledImage = image;
} else {
scaledImage = image.scaledToHeight(m_largestSide);
}
} else {
if (m_largestSide >= image.width()) {
scaledImage = image;
} else {
scaledImage = image.scaledToWidth(m_largestSide);
}
}
QString resizedFilePath = QDir::tempPath() + QDir::separator() +
"share-app.resized.XXXXXX." + source.suffix();
if (m_resizedImage) {
delete m_resizedImage;
m_resizedImage = NULL;
}
m_resizedImage = new QTemporaryFile(resizedFilePath, this);
m_resizedImage->open();
QImageWriter writer(m_resizedImage, source.suffix().toLatin1());
writer.write(scaledImage);
writer.setQuality(m_quality);
m_resizedImage->close();
Q_EMIT resizedFileChanged();
}
share-app-0.12~+14.04.20140306/ShareApp/imagefilehack.cpp 0000644 0000152 0177776 00000003213 12306027656 023074 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 "imagefilehack.h"
#include
#include
#include
#include
#include
ImageFileHack::ImageFileHack(QObject *parent) :
QObject(parent)
{
QString m_account;
QString m_path;
}
void ImageFileHack::read()
{
QFileInfo imageFilePath(QDir::tempPath() + QDir::separator() + "sharelocation");
if (imageFilePath.isFile()) {
QFile imageFile(imageFilePath.absoluteFilePath());
if (imageFile.open(QIODevice::ReadOnly)) {
QTextStream stream(&imageFile);
m_account = stream.readLine();
qDebug () << "ACCOUNT: " << m_account;
m_path = stream.readLine();
qDebug () << "PATH: " << m_path;
Q_EMIT accountChanged();
Q_EMIT pathChanged();
} else {
qWarning() << "Failed to open share path file for reading: " << imageFilePath.absoluteFilePath();
}
} else {
qWarning() << "Share path file doesn't exist: " << imageFilePath.absoluteFilePath();
}
}
share-app-0.12~+14.04.20140306/ShareApp/imagefilehack.h 0000644 0000152 0177776 00000002255 12306027656 022546 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 .
*/
#ifndef IMAGEFILEHACK_H
#define IMAGEFILEHACK_H
#include
class ImageFileHack : public QObject
{
Q_OBJECT
Q_PROPERTY(QString account READ account NOTIFY accountChanged)
Q_PROPERTY(QString path READ path NOTIFY pathChanged)
public:
explicit ImageFileHack(QObject *parent = 0);
QString account() { return m_account; }
QString path() { return m_path; }
public Q_SLOTS:
void read();
Q_SIGNALS:
void accountChanged();
void pathChanged();
private:
QString m_account;
QString m_path;
};
#endif // IMAGEFILEHACK_H
share-app-0.12~+14.04.20140306/ShareApp/qmldir 0000644 0000152 0177776 00000000021 12306027656 021024 0 ustar pbuser nogroup 0000000 0000000 plugin share-qml
share-app-0.12~+14.04.20140306/ShareApp/components.h 0000644 0000152 0177776 00000002041 12306027656 022153 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2012 Canonical, Ltd.
*
* Authors:
* Ugo Riboni
*
* 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 .
*/
#ifndef COMPONENTS_H
#define COMPONENTS_H
#include
#include
class Components : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
void registerTypes(const char *uri);
void initializeEngine(QQmlEngine *engine, const char *uri);
};
#endif // COMPONENTS_H
share-app-0.12~+14.04.20140306/ShareApp/imageresizer.h 0000644 0000152 0177776 00000004305 12306027656 022461 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 .
*/
#ifndef IMAGERESIZER_H
#define IMAGERESIZER_H
#include
#include
/**
* @brief Create a temporary rescaled copy of an image
*
* Create a temporary copy of the image in \a file. If \a largestSide
* is smaller than the larger side of the image, then the image is
* scaled down preserving aspect ratio so that the largest side matches.
* Quality of the copy will be 85 unless you specify another \a quality
* value (clamped to the 0-100 range).
*
* The path of the copy can be found in \a resizedFile. The copy is
* automatically deleted when the \a ImageResizer object is destroyed, or
* when any of the parameters change.
*/
class ImageResizer : public QObject
{
Q_OBJECT
Q_PROPERTY(QString file READ file WRITE setFile NOTIFY fileChanged)
Q_PROPERTY(QString resizedFile READ resizedFile NOTIFY resizedFileChanged)
Q_PROPERTY(int largestSide READ largestSide WRITE setLargestSide NOTIFY largestSideChanged)
Q_PROPERTY(int quality READ quality WRITE setQuality NOTIFY qualityChanged)
public:
explicit ImageResizer(QObject *parent = 0);
QString file() const;
QString resizedFile() const;
int largestSide() const;
int quality() const;
void setFile(const QString& file);
void setLargestSide(int largestSide);
void setQuality(int quality);
Q_SIGNALS:
void fileChanged();
void resizedFileChanged();
void largestSideChanged();
void qualityChanged();
private:
void resizeImage();
QString m_file;
QTemporaryFile* m_resizedImage;
int m_largestSide;
int m_quality;
};
#endif // IMAGERESIZER_H
share-app-0.12~+14.04.20140306/cmake/ 0000755 0000152 0177776 00000000000 12306030101 017150 5 ustar pbuser nogroup 0000000 0000000 share-app-0.12~+14.04.20140306/cmake/modules/ 0000755 0000152 0177776 00000000000 12306030101 020620 5 ustar pbuser nogroup 0000000 0000000 share-app-0.12~+14.04.20140306/cmake/modules/Findgcovr.cmake 0000644 0000152 0177776 00000001702 12306027656 023570 0 ustar pbuser nogroup 0000000 0000000 # - Find gcovr scrip
# Will define:
#
# GCOVR_EXECUTABLE - the gcovr script
#
# Uses:
#
# GCOVR_ROOT - root to search for the script
#
# Copyright (C) 2011 by Johannes Wienke
#
# 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;
# either version 2, or (at your option)
# any later version.
#
# 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.
#
INCLUDE(FindPackageHandleStandardArgs)
FIND_PROGRAM(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(gcovr DEFAULT_MSG GCOVR_EXECUTABLE)
# only visible in advanced view
MARK_AS_ADVANCED(GCOVR_EXECUTABLE)
share-app-0.12~+14.04.20140306/cmake/modules/ParseArguments.cmake 0000644 0000152 0177776 00000003406 12306027656 024612 0 ustar pbuser nogroup 0000000 0000000 # Parse arguments passed to a function into several lists separated by
# upper-case identifiers and options that do not have an associated list e.g.:
#
# SET(arguments
# hello OPTION3 world
# LIST3 foo bar
# OPTION2
# LIST1 fuz baz
# )
# PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments})
#
# results in 7 distinct variables:
# * ARG_DEFAULT_ARGS: hello;world
# * ARG_LIST1: fuz;baz
# * ARG_LIST2:
# * ARG_LIST3: foo;bar
# * ARG_OPTION1: FALSE
# * ARG_OPTION2: TRUE
# * ARG_OPTION3: TRUE
#
# taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
SET(larg_names ${arg_names})
LIST(FIND larg_names "${arg}" is_arg_name)
IF (is_arg_name GREATER -1)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name GREATER -1)
SET(loption_names ${option_names})
LIST(FIND loption_names "${arg}" is_option)
IF (is_option GREATER -1)
SET(${prefix}_${arg} TRUE)
ELSE (is_option GREATER -1)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option GREATER -1)
ENDIF (is_arg_name GREATER -1)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO(PARSE_ARGUMENTS)
share-app-0.12~+14.04.20140306/cmake/modules/FindLcov.cmake 0000644 0000152 0177776 00000001720 12306027656 023353 0 ustar pbuser nogroup 0000000 0000000 # - Find lcov
# Will define:
#
# LCOV_EXECUTABLE - the lcov binary
# GENHTML_EXECUTABLE - the genhtml executable
#
# Copyright (C) 2010 by Johannes Wienke
#
# 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;
# either version 2, or (at your option)
# any later version.
#
# 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.
#
INCLUDE(FindPackageHandleStandardArgs)
FIND_PROGRAM(LCOV_EXECUTABLE lcov)
FIND_PROGRAM(GENHTML_EXECUTABLE genhtml)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lcov DEFAULT_MSG LCOV_EXECUTABLE GENHTML_EXECUTABLE)
# only visible in advanced view
MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
share-app-0.12~+14.04.20140306/cmake/modules/EnableCoverageReport.cmake 0000644 0000152 0177776 00000015311 12306027656 025706 0 ustar pbuser nogroup 0000000 0000000 # - Creates a special coverage build type and target on GCC.
#
# Defines a function ENABLE_COVERAGE_REPORT which generates the coverage target
# for selected targets. Optional arguments to this function are used to filter
# unwanted results using globbing expressions. Moreover targets with tests for
# the source code can be specified to trigger regenerating the report if the
# test has changed
#
# ENABLE_COVERAGE_REPORT(TARGETS target... [FILTER filter...] [TESTS test targets...])
#
# To generate a coverage report first build the project with
# CMAKE_BUILD_TYPE=coverage, then call make test and afterwards make coverage.
#
# The coverage report is based on gcov. Depending on the availability of lcov
# a HTML report will be generated and/or an XML report of gcovr is found.
# The generated coverage target executes all found solutions. Special targets
# exist to create e.g. only the xml report: coverage-xml.
#
# Copyright (C) 2010 by Johannes Wienke
#
# 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;
# either version 2, or (at your option)
# any later version.
#
# 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.
#
INCLUDE(ParseArguments)
FIND_PACKAGE(Lcov)
FIND_PACKAGE(gcovr)
FUNCTION(ENABLE_COVERAGE_REPORT)
# argument parsing
PARSE_ARGUMENTS(ARG "FILTER;TARGETS;TESTS" "" ${ARGN})
SET(COVERAGE_RAW_FILE "${CMAKE_BINARY_DIR}/coverage.raw.info")
SET(COVERAGE_FILTERED_FILE "${CMAKE_BINARY_DIR}/coverage.info")
SET(COVERAGE_REPORT_DIR "${CMAKE_BINARY_DIR}/coveragereport")
SET(COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml")
SET(COVERAGE_XML_COMMAND_FILE "${CMAKE_BINARY_DIR}/coverage-xml.cmake")
# decide if there is any tool to create coverage data
SET(TOOL_FOUND FALSE)
IF(LCOV_FOUND OR GCOVR_FOUND)
SET(TOOL_FOUND TRUE)
ENDIF()
IF(NOT TOOL_FOUND)
MESSAGE(STATUS "Cannot enable coverage targets because neither lcov nor gcovr are found.")
ENDIF()
STRING(TOLOWER "${CMAKE_BUILD_TYPE}" COVERAGE_BUILD_TYPE)
IF(CMAKE_COMPILER_IS_GNUCXX AND TOOL_FOUND AND "${COVERAGE_BUILD_TYPE}" MATCHES "coverage")
MESSAGE(STATUS "Coverage support enabled for targets: ${ARG_TARGETS}")
# create coverage build type
SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE)
SET(CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} PARENT_SCOPE)
SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} coverage PARENT_SCOPE)
# instrument targets
SET_TARGET_PROPERTIES(${ARG_TARGETS} PROPERTIES COMPILE_FLAGS --coverage
LINK_FLAGS --coverage)
# html report
IF (LCOV_FOUND)
MESSAGE(STATUS "Enabling HTML coverage report")
# set up coverage target
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_RAW_FILE}
COMMAND ${LCOV_EXECUTABLE} -c -d ${CMAKE_BINARY_DIR} -o ${COVERAGE_RAW_FILE}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Collecting coverage data"
DEPENDS ${ARG_TARGETS} ${ARG_TESTS}
VERBATIM)
# filter unwanted stuff
LIST(LENGTH ARG_FILTER FILTER_LENGTH)
IF(${FILTER_LENGTH} GREATER 0)
SET(FILTER COMMAND ${LCOV_EXECUTABLE})
FOREACH(F ${ARG_FILTER})
SET(FILTER ${FILTER} -r ${COVERAGE_FILTERED_FILE} ${F})
ENDFOREACH()
SET(FILTER ${FILTER} -o ${COVERAGE_FILTERED_FILE})
ELSE()
SET(FILTER "")
ENDIF()
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_FILTERED_FILE}
COMMAND ${LCOV_EXECUTABLE} -e ${COVERAGE_RAW_FILE} "${CMAKE_SOURCE_DIR}*" -o ${COVERAGE_FILTERED_FILE}
${FILTER}
DEPENDS ${COVERAGE_RAW_FILE}
COMMENT "Filtering recorded coverage data for project-relevant entries"
VERBATIM)
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_REPORT_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_REPORT_DIR}
COMMAND ${GENHTML_EXECUTABLE} --legend --show-details -t "${PROJECT_NAME} test coverage" -o ${COVERAGE_REPORT_DIR} ${COVERAGE_FILTERED_FILE}
DEPENDS ${COVERAGE_FILTERED_FILE}
COMMENT "Generating HTML coverage report in ${COVERAGE_REPORT_DIR}"
VERBATIM)
ADD_CUSTOM_TARGET(coverage-html
DEPENDS ${COVERAGE_REPORT_DIR})
ENDIF()
# xml coverage report
IF(GCOVR_FOUND)
MESSAGE(STATUS "Enabling XML coverage report")
# gcovr cannot write directly to a file so the execution needs to
# be wrapped in a cmake file that generates the file output
FILE(WRITE ${COVERAGE_XML_COMMAND_FILE}
"SET(ENV{LANG} en)\n")
FILE(APPEND ${COVERAGE_XML_COMMAND_FILE}
"EXECUTE_PROCESS(COMMAND \"${GCOVR_EXECUTABLE}\" -x -r \"${CMAKE_SOURCE_DIR}\" OUTPUT_FILE \"${COVERAGE_XML_FILE}\" WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}\")\n")
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_XML_FILE}
COMMAND ${CMAKE_COMMAND} ARGS -P ${COVERAGE_XML_COMMAND_FILE}
COMMENT "Generating coverage XML report"
VERBATIM)
ADD_CUSTOM_TARGET(coverage-xml
DEPENDS ${COVERAGE_XML_FILE})
ENDIF()
# provide a global coverage target executing both steps if available
SET(GLOBAL_DEPENDS "")
IF(LCOV_FOUND)
LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_REPORT_DIR})
ENDIF()
IF(GCOVR_FOUND)
LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_XML_FILE})
ENDIF()
IF(LCOV_FOUND OR GCOVR_FOUND)
ADD_CUSTOM_TARGET(coverage
DEPENDS ${GLOBAL_DEPENDS})
ENDIF()
ENDIF()
ENDFUNCTION()
share-app-0.12~+14.04.20140306/tests/ 0000755 0000152 0177776 00000000000 12306030101 017232 5 ustar pbuser nogroup 0000000 0000000 share-app-0.12~+14.04.20140306/tests/autopilot/ 0000755 0000152 0177776 00000000000 12306030101 021252 5 ustar pbuser nogroup 0000000 0000000 share-app-0.12~+14.04.20140306/tests/autopilot/share_app/ 0000755 0000152 0177776 00000000000 12306030101 023214 5 ustar pbuser nogroup 0000000 0000000 share-app-0.12~+14.04.20140306/tests/autopilot/share_app/__init__.py 0000644 0000152 0177776 00000000560 12306027656 025353 0 ustar pbuser nogroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2012 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
"""proof of concept Qt5 autopilot tests and emulators - top level package."""
share-app-0.12~+14.04.20140306/tests/autopilot/share_app/tests/ 0000755 0000152 0177776 00000000000 12306030101 024356 5 ustar pbuser nogroup 0000000 0000000 share-app-0.12~+14.04.20140306/tests/autopilot/share_app/tests/__init__.py 0000644 0000152 0177776 00000003353 12306027656 026520 0 ustar pbuser nogroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2012 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
"""Share-app autopilot tests."""
import os
from autopilot.input import Mouse, Touch, Pointer
from autopilot.platform import model
from autopilot.testcase import AutopilotTestCase
from share_app.emulators.main_window import MainWindow
class ShareAppTestCase(AutopilotTestCase):
"""A common test case class that provides several useful methods for tests."""
if model() == 'Desktop':
scenarios = [
('with mouse', dict(input_device_class=Mouse)),
]
else:
scenarios = [
('with touch', dict(input_device_class=Touch)),
]
local_location = "../../share-app"
def setUp(self):
self.pointing_device = Pointer(self.input_device_class.create())
super(ShareAppTestCase, self).setUp()
if os.path.exists(self.local_location):
self.launch_test_local()
else:
self.launch_test_installed()
def launch_test_local(self):
self.app = self.launch_test_application(
"../../share-app")
def launch_test_installed(self):
if model() == 'Desktop':
self.app = self.launch_test_application(
"share-app"
)
else:
self.app = self.launch_test_application(
"share-app",
"--desktop_file_hint=/usr/share/applications/share-app.desktop",
app_type='qt')
@property
def main_window(self):
return MainWindow(self.app)
share-app-0.12~+14.04.20140306/tests/autopilot/share_app/tests/test_share.py 0000644 0000152 0177776 00000002643 12306027656 027123 0 ustar pbuser nogroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2012 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
"""Tests for the Share app"""
from __future__ import absolute_import
from autopilot.matchers import Eventually
from testtools.matchers import Equals
from share_app.tests import ShareAppTestCase
class TestShare(ShareAppTestCase):
"""Tests the main buttons"""
""" This is needed to wait for the application to start.
In the testfarm, the application may take some time to show up."""
def setUp(self):
super(TestShare, self).setUp()
self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
def tearDown(self):
super(TestShare, self).tearDown()
def test_cancel(self):
"""Tests the cancel button"""
cancelButton = self.main_window.get_cancel_button()
self.assertThat(True, Equals(True))
self.pointing_device.move_to_object(cancelButton)
self.pointing_device.click()
def test_message_area_typing(self):
"""Tests typing in the message area."""
# TODO Use OSK inputting text through evdev doesn't work
# as maliit takes the focus
#message_area = self.main_window.get_message_area()
pass
share-app-0.12~+14.04.20140306/tests/autopilot/share_app/emulators/ 0000755 0000152 0177776 00000000000 12306030101 025227 5 ustar pbuser nogroup 0000000 0000000 share-app-0.12~+14.04.20140306/tests/autopilot/share_app/emulators/__init__.py 0000644 0000152 0177776 00000000441 12306027656 027364 0 ustar pbuser nogroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2012 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
share-app-0.12~+14.04.20140306/tests/autopilot/share_app/emulators/main_window.py 0000644 0000152 0177776 00000002363 12306027656 030145 0 ustar pbuser nogroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2012 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
class MainWindow(object):
"""An emulator class that makes it easy to interact with the app."""
def __init__(self, app):
self.app = app
def get_qml_view(self):
"""Get the main QML view"""
return self.app.select_single("MainView")
def get_root(self):
"""Returns the root item of the scene."""
return self.app.select_single("MainView", objectName="shareApp")
def get_cancel_button(self):
"""Returns the cancel button."""
return self.app.select_single("Button",
objectName="cancelButton")
def get_post_button(self):
"""Returns the post button."""
return self.app.select_single("Button",
objectName="postButton")
def get_message_area(self):
"""Returns the message area."""
return self.app.select_single("UbuntuShape",
objectName="messageArea")
share-app-0.12~+14.04.20140306/tests/autopilot/CMakeLists.txt 0000644 0000152 0177776 00000000443 12306027656 024040 0 ustar pbuser nogroup 0000000 0000000 set(AUTOPILOT_DIR share_app)
execute_process(COMMAND python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
OUTPUT_VARIABLE PYTHON_PACKAGE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
install(DIRECTORY ${AUTOPILOT_DIR}
DESTINATION ${PYTHON_PACKAGE_DIR}
)
share-app-0.12~+14.04.20140306/tests/CMakeLists.txt 0000644 0000152 0177776 00000000070 12306027656 022014 0 ustar pbuser nogroup 0000000 0000000 add_subdirectory(autopilot)
add_subdirectory(unittests)
share-app-0.12~+14.04.20140306/tests/unittests/ 0000755 0000152 0177776 00000000000 12306030101 021274 5 ustar pbuser nogroup 0000000 0000000 share-app-0.12~+14.04.20140306/tests/unittests/CMakeLists.txt 0000644 0000152 0177776 00000001450 12306027656 024061 0 ustar pbuser nogroup 0000000 0000000 include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/ShareApp
)
qt5_add_resources(sampledata_rc_srcs sampledata.qrc)
macro(generate_tests)
foreach(test ${ARGN})
add_executable(${test}
${test}.cpp
../../ShareApp/imageresizer.cpp
${sampledata_rc_srcs}
)
qt5_use_modules(${test} Core Qml Quick Test)
target_link_libraries(${test}
${TPL_QT5_LIBRARIES}
)
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_ImageResizer
)
share-app-0.12~+14.04.20140306/tests/unittests/tst_ImageResizer.cpp 0000644 0000152 0177776 00000010130 12306027656 025300 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 ImageResizerTest: public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void testProperties();
void testResizeImage();
void testInvalidFilename();
void testInvalidSide();
void testInvalidQuality();
void cleanupTestCase();
private:
ImageResizer *m_resizer;
};
void ImageResizerTest::initTestCase()
{
m_resizer = new ImageResizer(this);
}
void ImageResizerTest::cleanupTestCase()
{
delete m_resizer;
}
void ImageResizerTest::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 ImageResizerTest::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 ImageResizerTest::testInvalidFilename()
{
QSignalSpy resizedFileSpy(m_resizer, SIGNAL(resizedFileChanged()));
m_resizer->setFile(testFile + QLatin1String("invalid"));
QVERIFY(m_resizer->resizedFile().isEmpty());
}
void ImageResizerTest::testInvalidSide()
{
QSignalSpy largestSideSpy(m_resizer, SIGNAL(largestSideChanged()));
m_resizer->setLargestSide(-100);
QVERIFY(m_resizer->largestSide() == 1);
}
void ImageResizerTest::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(ImageResizerTest)
#include "tst_ImageResizer.moc"
share-app-0.12~+14.04.20140306/tests/unittests/assets/ 0000755 0000152 0177776 00000000000 12306030101 022576 5 ustar pbuser nogroup 0000000 0000000 share-app-0.12~+14.04.20140306/tests/unittests/assets/testfile_portrait.jpg 0000644 0000152 0177776 00001210706 12306027656 027077 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#