summaryrefslogtreecommitdiffstats
path: root/tests/manual/widgets/inputmethods/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/widgets/inputmethods/main.cpp')
-rw-r--r--tests/manual/widgets/inputmethods/main.cpp83
1 files changed, 39 insertions, 44 deletions
diff --git a/tests/manual/widgets/inputmethods/main.cpp b/tests/manual/widgets/inputmethods/main.cpp
index a96deb83a..2378e95ae 100644
--- a/tests/manual/widgets/inputmethods/main.cpp
+++ b/tests/manual/widgets/inputmethods/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QApplication>
#include <QFormLayout>
@@ -49,7 +24,12 @@ class MainWindow : public QMainWindow
public:
explicit MainWindow(QWidget *parent = 0);
+private slots:
+ void sendInputMethodEvents();
+
private:
+ void closeEvent(QCloseEvent *event) override;
+
ControlView *m_controlView;
ReferenceView *m_referenceView;
WebView *m_webView;
@@ -109,29 +89,44 @@ MainWindow::MainWindow(QWidget *parent)
centralLayout->addLayout(leftLayout);
centralLayout->addWidget(m_testView);
- connect(m_testView, &TestView::sendInputMethodData, m_controlView, &ControlView::receiveInputMethodData);
- connect(m_testView, &TestView::requestInputMethodEvent, m_controlView, &ControlView::createAndSendInputMethodEvent);
-
- connect(m_controlView, &ControlView::sendInputMethodEvent, [=](QInputMethodEvent im) {
- bool processed;
- QString resultText;
-
- processed = QApplication::sendEvent(m_referenceView->referenceInput(), &im);
- resultText = processed ? QStringLiteral("<font color='green'>TRUE</font>")
- : QStringLiteral("<font color='red'>FALSE</font>");
- m_referenceProcessed->setText(resultText);
-
- processed = QApplication::sendEvent(m_webView->focusProxy(), &im);
- resultText = processed ? QStringLiteral("<font color='green'>TRUE</font>")
- : QStringLiteral("<font color='red'>FALSE</font>");
- m_webProcessed->setText(resultText);
- });
+ connect(m_testView, &TestView::sendInputMethodData, m_controlView,
+ &ControlView::receiveInputMethodData);
+ connect(m_testView, &TestView::requestInputMethodEvent, this,
+ &MainWindow::sendInputMethodEvents);
+ connect(m_controlView, &ControlView::requestInputMethodEvent, this,
+ &MainWindow::sendInputMethodEvents);
centralWidget->setLayout(centralLayout);
setCentralWidget(centralWidget);
setWindowTitle(tr("Input Methods Format Manual Test"));
}
+void MainWindow::sendInputMethodEvents()
+{
+ bool processed;
+ QString resultText;
+
+ QString text = m_controlView->getText();
+ QList<QInputMethodEvent::Attribute> attrs = m_controlView->getAtrributes();
+ QInputMethodEvent im(text, attrs);
+
+ processed = QApplication::sendEvent(m_referenceView->referenceInput(), &im);
+ resultText = processed ? QStringLiteral("<font color='green'>TRUE</font>")
+ : QStringLiteral("<font color='red'>FALSE</font>");
+ m_referenceProcessed->setText(resultText);
+
+ processed = QApplication::sendEvent(m_webView->focusProxy(), &im);
+ resultText = processed ? QStringLiteral("<font color='green'>TRUE</font>")
+ : QStringLiteral("<font color='red'>FALSE</font>");
+ m_webProcessed->setText(resultText);
+}
+
+void MainWindow::closeEvent(QCloseEvent *event)
+{
+ m_testView->cancelTest();
+ QMainWindow::closeEvent(event);
+}
+
int main(int argc, char *argv[])
{
QApplication a(argc, argv);