1
/* * This file is part of Maliit framework *
3
* Copyright (C) 2011 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 "ft_exampleplugin.h"
16
#include "core-utils.h"
17
#include "gui-utils.h"
19
#include <minputmethodhost.h>
20
#include <maliit/plugins/inputmethodplugin.h>
21
#include <minputcontextconnection.h>
26
class MIndicatorServiceClient
29
void Ft_ExamplePlugin::initTestCase()
33
void Ft_ExamplePlugin::cleanupTestCase()
37
void Ft_ExamplePlugin::init()
40
void Ft_ExamplePlugin::cleanup()
44
void Ft_ExamplePlugin::testFunction_data()
46
QTest::addColumn<QString>("testPluginPath");
47
QTest::newRow("Hello world")
48
<< "helloworld/libcxxhelloworldplugin.so";
49
QTest::newRow("Override")
50
<< "override/libcxxoverrideplugin.so";
53
void Ft_ExamplePlugin::testFunction()
55
QFETCH(QString, testPluginPath);
57
MIndicatorServiceClient fakeService;
59
const QDir pluginDir = MaliitTestUtils::isTestingInSandbox() ?
60
QDir(IN_TREE_TEST_PLUGIN_DIR"/cxx") : QDir(MALIIT_TEST_PLUGINS_DIR"/examples/cxx");
61
const QString pluginPath = pluginDir.absoluteFilePath(testPluginPath);
62
const QString pluginId = QFileInfo(testPluginPath).baseName();
63
QVERIFY(pluginDir.exists(pluginPath));
65
QPluginLoader loader(pluginPath);
66
QObject *pluginInstance = loader.instance();
67
QVERIFY(pluginInstance != 0);
69
Maliit::Plugins::InputMethodPlugin *plugin = qobject_cast<Maliit::Plugins::InputMethodPlugin *>(pluginInstance);
72
MaliitTestUtils::TestInputMethodHost host(fakeService, pluginId, plugin->name());
73
plugin->createInputMethod(&host);
75
QCOMPARE(host.lastCommit, QString("Maliit"));
76
QCOMPARE(host.sendCommitCount, 1);
77
QCOMPARE(host.lastPreedit, QString("Mali"));
78
QCOMPARE(host.sendPreeditCount, 1);
81
QTEST_MAIN(Ft_ExamplePlugin)