~timo-jyrinki/ubuntu/trusty/maliit-framework/fix_qt52

« back to all changes in this revision

Viewing changes to tests/ut_minputcontextplugin/ut_minputcontextplugin.cpp

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Sergio Schvezov, Ricardo Salveti de Araujo
  • Date: 2013-07-23 19:47:04 UTC
  • mfrom: (1.1.2) (1.2.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130723194704-1lsy1kmlda069cea
Tags: 0.99.0+git20130615+97e8335-0ubuntu1
[ Sergio Schvezov ]
* New build from HEAD 97e8335.
* Packaging import from lp:phablet-extras/maliit-framework.

[ Ricardo Salveti de Araujo ]
* debian/control: adding vcs and fixing dependencies
* General package cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* * This file is part of Maliit framework *
2
 
 *
3
 
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
 
 * All rights reserved.
5
 
 *
6
 
 * Contact: maliit-discuss@lists.maliit.org
7
 
 *
8
 
 * This library is free software; you can redistribute it and/or
9
 
 * modify it under the terms of the GNU Lesser General Public
10
 
 * License version 2.1 as published by the Free Software Foundation
11
 
 * and appearing in the file LICENSE.LGPL included in the packaging
12
 
 * of this file.
13
 
 */
14
 
 
15
 
#include "ut_minputcontextplugin.h"
16
 
 
17
 
#include "core-utils.h"
18
 
#include "gui-utils.h"
19
 
#include "minputcontextplugin.h"
20
 
#include "mimsettings.h"
21
 
 
22
 
#include <QInputContext>
23
 
#include <QApplication>
24
 
 
25
 
namespace {
26
 
    const QString EnabledPluginsKey = MALIIT_CONFIG_ROOT"onscreen/enabled";
27
 
    const QStringList DefaultEnabledPlugins = QStringList() << "libdummyimplugin.so" ":" "dummyimsv1";
28
 
    const QString MImPluginPaths = MALIIT_CONFIG_ROOT"paths";
29
 
}
30
 
 
31
 
void Ut_MInputContextPlugin::initTestCase()
32
 
{
33
 
    MImSettings::setPreferredSettingsType(MImSettings::TemporarySettings);
34
 
}
35
 
 
36
 
void Ut_MInputContextPlugin::cleanupTestCase()
37
 
{
38
 
}
39
 
 
40
 
void Ut_MInputContextPlugin::init()
41
 
{
42
 
    subject = new MInputContextPlugin(0);
43
 
    QVERIFY(subject);
44
 
 
45
 
    // Make sure that for the direct IC case (maliit server embedded in application)
46
 
    // We don't try to use any plugins outside of our control
47
 
    MImSettings pathConf(MImPluginPaths);
48
 
    pathConf.set(MaliitTestUtils::getTestPluginPath());
49
 
    MImSettings enabledPluginsSettings(EnabledPluginsKey);
50
 
    enabledPluginsSettings.set(DefaultEnabledPlugins);
51
 
}
52
 
 
53
 
void Ut_MInputContextPlugin::cleanup()
54
 
{
55
 
    delete subject;
56
 
}
57
 
 
58
 
void Ut_MInputContextPlugin::testCreate()
59
 
{
60
 
    QStringList keys = subject->keys();
61
 
    QInputContext *ctx = NULL;
62
 
 
63
 
    Q_FOREACH(QString key, keys) {
64
 
        ctx = subject->create(key);
65
 
        QVERIFY(ctx);
66
 
        QCOMPARE(ctx->identifierName(), key);
67
 
        delete ctx;
68
 
        ctx = NULL;
69
 
    }
70
 
 
71
 
    // Null key should fail
72
 
    ctx = subject->create(QString());
73
 
    QVERIFY(!ctx);
74
 
}
75
 
 
76
 
void Ut_MInputContextPlugin::testOther()
77
 
{
78
 
    // This is a dont-crash test for simple API functions.
79
 
 
80
 
    QString key = subject->keys().first();
81
 
 
82
 
    QString description(subject->description(key));
83
 
    QString displayName(subject->displayName(key));
84
 
    QStringList languages(subject->languages(key));
85
 
 
86
 
    qDebug() << "description: " << description;
87
 
    qDebug() << "display name: " << displayName;
88
 
    Q_FOREACH(QString lang, languages) {
89
 
        qDebug() << "language: " << lang;
90
 
    }
91
 
}
92
 
 
93
 
void disableImLoading()
94
 
{
95
 
    // This is a hack to prevent Qt from loading the plugin from
96
 
    // /usr/lib/qt4/plugins/inputmethods/ when we are testing in a
97
 
    // sandbox.
98
 
    if (MaliitTestUtils::isTestingInSandbox())
99
 
        QCoreApplication::setLibraryPaths(QStringList("/tmp"));
100
 
}
101
 
 
102
 
MALIIT_TESTUTILS_GUI_MAIN_WITH_SETUP(Ut_MInputContextPlugin, disableImLoading)