~ubuntu-branches/ubuntu/wily/thumbnailer/wily

« back to all changes in this revision

Viewing changes to tests/qml/qml_test.cpp

  • Committer: Package Import Robot
  • Author(s): CI Train Bot, James Henstridge, Michi Henning, CI Train Bot
  • Date: 2015-07-15 02:03:28 UTC
  • mfrom: (1.1.29)
  • Revision ID: package-import@ubuntu.com-20150715020328-p98z3qkq2kdr0lnt
Tags: 2.1+15.10.20150715-0ubuntu1
[ James Henstridge ]
* Expose more settings for the thumbnailer daemon via GSettings.
* Change the security policy implementation to use aa_query_label()
  for file access checks rather than relying on file descriptor
  passing.  This avoids the file descriptor exhaustion bugs with the
  previous implementation. (LP: #1381713)

[ Michi Henning ]
* Add thumbnailer-admin tool, which can be used to check the status
  of the cache and generate thumbnails via the command line.
* Add time stamps to log messages.
* Reduce the memory footprint of small caches, which in turn reduces
  the footprint of thumbnailer-service.
* Don't implicitly compact the cache on service shutdown, as this
  can take some time.
* Persist the cache stats over restarts of thumbnailer-service.
* Don't save JPEG thumbnails at quality=100, since the quality
  improvement isn't justified by the extra storage.
* Don't retry downloads when we have a hit from the failure cache.
* Warn if an app requests an unsized thumbnail.

[ CI Train Bot ]
* New rebuild forced.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2015 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: James Henstridge <james.henstridge@canonical.com>
 
17
 */
 
18
 
 
19
#include <memory>
 
20
#include <stdexcept>
 
21
#include <string>
 
22
#include <unistd.h>
 
23
 
 
24
#include <QGuiApplication>
 
25
#include <QtQml>
 
26
#include <QtQuickTest/quicktest.h>
 
27
#include <QTemporaryDir>
 
28
 
 
29
#include <testsetup.h>
 
30
#include "utils/artserver.h"
 
31
#include "utils/dbusserver.h"
 
32
 
 
33
class TestFixture
 
34
{
 
35
public:
 
36
    TestFixture()
 
37
    {
 
38
        cachedir_.reset(new QTemporaryDir(TESTBINDIR "/qml-test.XXXXXX"));
 
39
        setenv("XDG_CACHE_HOME", cachedir_->path().toUtf8().constData(), true);
 
40
 
 
41
        dbus_server_.reset(new DBusServer());
 
42
    }
 
43
 
 
44
    ~TestFixture()
 
45
    {
 
46
        dbus_server_.reset();
 
47
        cachedir_.reset();
 
48
    }
 
49
 
 
50
private:
 
51
    std::unique_ptr<QTemporaryDir> cachedir_;
 
52
    std::unique_ptr<DBusServer> dbus_server_;
 
53
    ArtServer fake_art_server_;
 
54
};
 
55
 
 
56
// Expose static test configuration to QML
 
57
QJSValue make_test_config(QQmlEngine*, QJSEngine* scriptEngine)
 
58
{
 
59
    QJSValue config = scriptEngine->newObject();
 
60
    config.setProperty("sourceDir", TESTSRCDIR);
 
61
    config.setProperty("buildDir", TESTBINDIR);
 
62
    config.setProperty("mediaDir", TESTDATADIR);
 
63
    return config;
 
64
}
 
65
 
 
66
int main(int argc, char** argv)
 
67
{
 
68
    QGuiApplication app(argc, argv);
 
69
 
 
70
    setenv("GSETTINGS_BACKEND", "memory", true);
 
71
    setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true);
 
72
    setenv("TN_UTILDIR", TESTBINDIR "/../src/vs-thumb", true);
 
73
    qmlRegisterSingletonType("testconfig", 1, 0, "Config", make_test_config);
 
74
    qmlProtectModule("testconfig", 1);
 
75
 
 
76
    TestFixture fixture;
 
77
    return quick_test_main(argc, argv, "Thumbnailer", TESTSRCDIR "/qml");
 
78
}