1
/* * This file is part of Maliit framework *
3
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6
* Contact: maliit-discuss@lists.maliit.org
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
15
#include "ut_minputcontextplugin.h"
17
#include "core-utils.h"
18
#include "gui-utils.h"
19
#include "minputcontextplugin.h"
20
#include "mimsettings.h"
22
#include <QInputContext>
23
#include <QApplication>
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";
31
void Ut_MInputContextPlugin::initTestCase()
33
MImSettings::setPreferredSettingsType(MImSettings::TemporarySettings);
36
void Ut_MInputContextPlugin::cleanupTestCase()
40
void Ut_MInputContextPlugin::init()
42
subject = new MInputContextPlugin(0);
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);
53
void Ut_MInputContextPlugin::cleanup()
58
void Ut_MInputContextPlugin::testCreate()
60
QStringList keys = subject->keys();
61
QInputContext *ctx = NULL;
63
Q_FOREACH(QString key, keys) {
64
ctx = subject->create(key);
66
QCOMPARE(ctx->identifierName(), key);
71
// Null key should fail
72
ctx = subject->create(QString());
76
void Ut_MInputContextPlugin::testOther()
78
// This is a dont-crash test for simple API functions.
80
QString key = subject->keys().first();
82
QString description(subject->description(key));
83
QString displayName(subject->displayName(key));
84
QStringList languages(subject->languages(key));
86
qDebug() << "description: " << description;
87
qDebug() << "display name: " << displayName;
88
Q_FOREACH(QString lang, languages) {
89
qDebug() << "language: " << lang;
93
void disableImLoading()
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
98
if (MaliitTestUtils::isTestingInSandbox())
99
QCoreApplication::setLibraryPaths(QStringList("/tmp"));
102
MALIIT_TESTUTILS_GUI_MAIN_WITH_SETUP(Ut_MInputContextPlugin, disableImLoading)