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

« back to all changes in this revision

Viewing changes to tests/ft_exampleplugin/ft_exampleplugin.cpp

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2013-01-31 13:26:48 UTC
  • Revision ID: package-import@ubuntu.com-20130131132648-w1u9d2279tppxcft
Tags: upstream-0.94.1
ImportĀ upstreamĀ versionĀ 0.94.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* * This file is part of Maliit framework *
 
2
 *
 
3
 * Copyright (C) 2011 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 "ft_exampleplugin.h"
 
16
#include "core-utils.h"
 
17
#include "gui-utils.h"
 
18
 
 
19
#include <minputmethodhost.h>
 
20
#include <maliit/plugins/inputmethodplugin.h>
 
21
#include <minputcontextconnection.h>
 
22
 
 
23
#include <QtCore>
 
24
#include <QtGui>
 
25
 
 
26
class MIndicatorServiceClient
 
27
{};
 
28
 
 
29
void Ft_ExamplePlugin::initTestCase()
 
30
{
 
31
}
 
32
 
 
33
void Ft_ExamplePlugin::cleanupTestCase()
 
34
{
 
35
}
 
36
 
 
37
void Ft_ExamplePlugin::init()
 
38
{}
 
39
 
 
40
void Ft_ExamplePlugin::cleanup()
 
41
{}
 
42
 
 
43
 
 
44
void Ft_ExamplePlugin::testFunction_data()
 
45
{
 
46
    QTest::addColumn<QString>("testPluginPath");
 
47
    QTest::newRow("Hello world")
 
48
        << "helloworld/libcxxhelloworldplugin.so";
 
49
    QTest::newRow("Override")
 
50
        << "override/libcxxoverrideplugin.so";
 
51
}
 
52
 
 
53
void Ft_ExamplePlugin::testFunction()
 
54
{
 
55
    QFETCH(QString, testPluginPath);
 
56
 
 
57
    MIndicatorServiceClient fakeService;
 
58
 
 
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));
 
64
 
 
65
    QPluginLoader loader(pluginPath);
 
66
    QObject *pluginInstance = loader.instance();
 
67
    QVERIFY(pluginInstance != 0);
 
68
 
 
69
    Maliit::Plugins::InputMethodPlugin *plugin =  qobject_cast<Maliit::Plugins::InputMethodPlugin *>(pluginInstance);
 
70
    QVERIFY(plugin != 0);
 
71
 
 
72
    MaliitTestUtils::TestInputMethodHost host(fakeService, pluginId, plugin->name());
 
73
    plugin->createInputMethod(&host);
 
74
 
 
75
    QCOMPARE(host.lastCommit, QString("Maliit"));
 
76
    QCOMPARE(host.sendCommitCount, 1);
 
77
    QCOMPARE(host.lastPreedit, QString("Mali"));
 
78
    QCOMPARE(host.sendPreeditCount, 1);
 
79
}
 
80
 
 
81
QTEST_MAIN(Ft_ExamplePlugin)