File: ut_minputmethodquickplugin.cpp

package info (click to toggle)
maliit-framework 2.3.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,244 kB
  • sloc: cpp: 13,146; ansic: 2,506; xml: 299; makefile: 46; sh: 34; sed: 4
file content (70 lines) | stat: -rw-r--r-- 2,254 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* * This file is part of Maliit framework *
 *
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 *
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation
 * and appearing in the file LICENSE.LGPL included in the packaging
 * of this file.
 */

#include "ut_minputmethodquickplugin.h"
#include "core-utils.h"
#include "gui-utils.h"

#include <quick/inputmethodquickplugin.h>
#include <quick/inputmethodquick.h>
#include <minputmethodhost.h>
#include <QtCore>
#include <QtGui>

class MIndicatorServiceClient
{};

void Ut_MInputMethodQuickPlugin::initTestCase()
{
}

void Ut_MInputMethodQuickPlugin::cleanupTestCase()
{
}

void Ut_MInputMethodQuickPlugin::init()
{}

void Ut_MInputMethodQuickPlugin::cleanup()
{}

void Ut_MInputMethodQuickPlugin::testQmlSetup()
{
    QString testPlugin("helloworld.qml");
    const QDir pluginDir = MaliitTestUtils::isTestingInSandbox()
            ? QDir(MaliitTestUtils::getTestDataPath() + "/qmlplugin")
            : QDir(MALIIT_TEST_PLUGINS_DIR"/qml/helloworld");
    const QString pluginPath = pluginDir.absoluteFilePath(testPlugin);
    const QString pluginId = QFileInfo(testPlugin).baseName();
    QVERIFY(pluginDir.exists(pluginPath));

    Maliit::Plugins::InputMethodPlugin *plugin
            = new Maliit::InputMethodQuickPlugin(pluginPath,
                                                 QSharedPointer<Maliit::AbstractPlatform>(new Maliit::UnknownPlatform));

    MaliitTestUtils::TestInputMethodHost host(pluginId, plugin->name());
    Maliit::InputMethodQuick *testee = static_cast<Maliit::InputMethodQuick *>(
        plugin->createInputMethod(&host));

    QVERIFY(not testee->inputMethodArea().isEmpty());
    QCOMPARE(testee->inputMethodArea(),
             QRectF(0, qRound(testee->screenHeight() * 0.5),
                    testee->screenWidth(), qRound(testee->screenHeight() * 0.5)));

    QCOMPARE(host.lastCommit, QString("Maliit"));
    QCOMPARE(host.sendCommitCount, 1);
    QCOMPARE(host.lastPreedit, QString("Maliit"));
    QCOMPARE(host.sendPreeditCount, 1);
}

QTEST_MAIN(Ut_MInputMethodQuickPlugin)