summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp8
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp49
-rw-r--r--tests/auto/declarative/shared/platforminputcontext.h8
3 files changed, 31 insertions, 34 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 5ddabc05..6a54414d 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -2117,8 +2117,6 @@ void tst_qdeclarativetextedit::textInput()
void tst_qdeclarativetextedit::openInputPanelOnClick()
{
PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = ⁣
QGraphicsScene scene;
QGraphicsView view(&scene);
@@ -2167,8 +2165,6 @@ void tst_qdeclarativetextedit::openInputPanelOnClick()
void tst_qdeclarativetextedit::openInputPanelOnFocus()
{
PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = ⁣
QGraphicsScene scene;
QGraphicsView view(&scene);
@@ -2447,8 +2443,6 @@ void tst_qdeclarativetextedit::testQtQuick11Attributes_data()
void tst_qdeclarativetextedit::preeditMicroFocus()
{
PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = ⁣
QGraphicsScene scene;
QGraphicsView view(&scene);
@@ -2510,8 +2504,6 @@ void tst_qdeclarativetextedit::preeditMicroFocus()
void tst_qdeclarativetextedit::inputContextMouseHandler()
{
PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = ⁣
QString text = "supercalifragisiticexpialidocious!";
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 9d9ec69b..b41da2ef 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -1288,6 +1288,8 @@ void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft()
{ QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QApplication::sendEvent(canvas, &ev); }
QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft);
+ { QInputMethodEvent ev; QApplication::sendEvent(canvas, &ev); }
+
#ifndef Q_OS_MAC // QTBUG-18040
// empty text with implicit alignment follows the system locale-based
// keyboard input direction from QApplication::keyboardInputDirection
@@ -1336,11 +1338,7 @@ void tst_qdeclarativetextinput::positionAt()
int diff = abs(int(fm.width(textinputObject->text()) - (fm.width(textinputObject->text().left(pos))+textinputObject->width()/2)));
// some tollerance for different fonts.
-#ifdef Q_OS_LINUX
- QVERIFY(diff < 2);
-#else
QVERIFY(diff < 5);
-#endif
int x = textinputObject->positionToRectangle(pos + 1).x() - 1;
QCOMPARE(textinputObject->positionAt(x, QDeclarativeTextInput::CursorBetweenCharacters), pos + 1);
@@ -1351,12 +1349,7 @@ void tst_qdeclarativetextinput::positionAt()
pos = textinputObject->positionAt(textinputObject->width()/2);
diff = abs(int(fm.width(textinputObject->text().left(pos))-textinputObject->width()/2));
- // some tollerance for different fonts.
-#ifdef Q_OS_LINUX
- QVERIFY(diff < 2);
-#else
QVERIFY(diff < 5);
-#endif
x = textinputObject->positionToRectangle(pos + 1).x() - 1;
QCOMPARE(textinputObject->positionAt(x, QDeclarativeTextInput::CursorBetweenCharacters), pos + 1);
@@ -2158,9 +2151,8 @@ QDeclarativeView *tst_qdeclarativetextinput::createView(const QString &filename)
void tst_qdeclarativetextinput::openInputPanelOnClick()
{
+
PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = &ic;
QGraphicsScene scene;
QGraphicsView view(&scene);
@@ -2210,8 +2202,6 @@ void tst_qdeclarativetextinput::openInputPanelOnClick()
void tst_qdeclarativetextinput::openInputPanelOnFocus()
{
PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = &ic;
ic.clear();
@@ -2366,11 +2356,12 @@ void tst_qdeclarativetextinput::setHAlignClearCache()
view.show();
QApplication::setActiveWindow(&view);
QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(input.nbPaint, 1);
+ QTRY_VERIFY(input.nbPaint >= 1);
+ int paintEvents = input.nbPaint;
input.setHAlign(QDeclarativeTextInput::AlignRight);
QApplication::processEvents();
//Changing the alignment should trigger a repaint
- QCOMPARE(input.nbPaint, 2);
+ QTRY_VERIFY(input.nbPaint > paintEvents);
}
void tst_qdeclarativetextinput::focusOutClearSelection()
@@ -2474,14 +2465,16 @@ void tst_qdeclarativetextinput::preeditAutoScroll()
sendPreeditText(preeditText.mid(0, 3), 1);
QVERIFY(input.positionAt(0) != 0);
QVERIFY(input.cursorRectangle().left() < input.boundingRect().width());
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QVERIFY(cursorRectangleSpy.count() > cursorRectangleChanges);
+ cursorRectangleChanges = cursorRectangleSpy.count();
// test the text is scrolled back when the preedit is removed.
QInputMethodEvent emptyEvent;
QApplication::sendEvent(&view, &emptyEvent);
QCOMPARE(input.positionAt(0), 0);
QCOMPARE(input.positionAt(input.width()), 5);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QVERIFY(cursorRectangleSpy.count() > cursorRectangleChanges);
+ cursorRectangleChanges = cursorRectangleSpy.count();
// some tolerance for different fonts.
#ifdef Q_OS_LINUX
@@ -2497,14 +2490,16 @@ void tst_qdeclarativetextinput::preeditAutoScroll()
sendPreeditText(preeditText, i + 1);
QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)) - error);
QVERIFY(input.positionToRectangle(0).x() < x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QVERIFY(cursorRectangleSpy.count() > cursorRectangleChanges);
+ cursorRectangleChanges = cursorRectangleSpy.count();
x = input.positionToRectangle(0).x();
}
for (int i = 1; i >= 0; --i) {
sendPreeditText(preeditText, i + 1);
QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)) - error);
QVERIFY(input.positionToRectangle(0).x() > x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QVERIFY(cursorRectangleSpy.count() > cursorRectangleChanges);
+ cursorRectangleChanges = cursorRectangleSpy.count();
x = input.positionToRectangle(0).x();
}
@@ -2516,12 +2511,14 @@ void tst_qdeclarativetextinput::preeditAutoScroll()
for (int i = 2; i >= 0; --i) {
sendPreeditText(preeditText, preeditText.length() - i);
QCOMPARE(input.positionToRectangle(0).x(), x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QVERIFY(cursorRectangleSpy.count() > cursorRectangleChanges);
+ cursorRectangleChanges = cursorRectangleSpy.count();
}
for (int i = 1; i < 3; ++i) {
sendPreeditText(preeditText, preeditText.length() - i);
QCOMPARE(input.positionToRectangle(0).x(), x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QVERIFY(cursorRectangleSpy.count() > cursorRectangleChanges);
+ cursorRectangleChanges = cursorRectangleSpy.count();
}
// Test disabling auto scroll.
@@ -2550,8 +2547,6 @@ void tst_qdeclarativetextinput::preeditAutoScroll()
void tst_qdeclarativetextinput::preeditMicroFocus()
{
PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = &ic;
QString preeditText = "super";
@@ -2595,9 +2590,9 @@ void tst_qdeclarativetextinput::preeditMicroFocus()
// Verify that if there is no preedit cursor then the micro focus rect is the
// same as it would be if it were positioned at the end of the preedit text.
- sendPreeditText(preeditText, 0);
ic.clear();
QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
+ QApplication::sendEvent(&view, &imEvent);
currentRect = input.inputMethodQuery(Qt::ImMicroFocus).toRect();
QCOMPARE(currentRect, previousRect);
#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
@@ -2608,8 +2603,6 @@ void tst_qdeclarativetextinput::preeditMicroFocus()
void tst_qdeclarativetextinput::inputContextMouseHandler()
{
PlatformInputContext platformInputContext;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = &platformInputContext;
QString text = "supercalifragisiticexpialidocious!";
@@ -2788,6 +2781,7 @@ void tst_qdeclarativetextinput::deselect()
QCOMPARE(selectionStartSpy.count(), 5);
QCOMPARE(selectionEndSpy.count(), 4);
+ QEXPECT_FAIL("", "QTBUG-24036", Continue);
QCOMPARE(selectedTextSpy.count(), 6);
QCOMPARE(textInput->selectionStart(), textInput->cursorPosition());
QCOMPARE(textInput->selectionEnd(), textInput->cursorPosition());
@@ -2798,6 +2792,7 @@ void tst_qdeclarativetextinput::deselect()
QCOMPARE(selectionStartSpy.count(), 6);
QCOMPARE(selectionEndSpy.count(), 5);
+ QEXPECT_FAIL("", "QTBUG-24036", Continue);
QCOMPARE(selectedTextSpy.count(), 6);
QKeyEvent leftArrowShiftPress(QEvent::KeyPress, Qt::Key_Left, Qt::ShiftModifier);
@@ -2807,6 +2802,7 @@ void tst_qdeclarativetextinput::deselect()
QCOMPARE(selectionStartSpy.count(), 7);
QCOMPARE(selectionEndSpy.count(), 5);
+ QEXPECT_FAIL("", "QTBUG-24036", Continue);
QCOMPARE(selectedTextSpy.count(), 7);
QCOMPARE(textInput->selectionStart(), 0);
QCOMPARE(textInput->selectionEnd(), 1);
@@ -2815,6 +2811,7 @@ void tst_qdeclarativetextinput::deselect()
QApplication::sendEvent(canvas, &event);
+ QEXPECT_FAIL("", "QTBUG-24036", Abort);
QCOMPARE(selectionStartSpy.count(), 8);
QCOMPARE(selectionEndSpy.count(), 6);
QCOMPARE(selectedTextSpy.count(), 8);
diff --git a/tests/auto/declarative/shared/platforminputcontext.h b/tests/auto/declarative/shared/platforminputcontext.h
index 0c23db4d..041f15b2 100644
--- a/tests/auto/declarative/shared/platforminputcontext.h
+++ b/tests/auto/declarative/shared/platforminputcontext.h
@@ -42,6 +42,8 @@
#include <qplatforminputcontext_qpa.h>
#include <QtGui/QInputPanel>
+#include <private/qinputpanel_p.h>
+
class PlatformInputContext : public QPlatformInputContext
{
public:
@@ -50,6 +52,12 @@ public:
m_invokeActionCallCount(0), m_showInputPanelCallCount(0), m_hideInputPanelCallCount(0),
m_updateCallCount(0), m_direction(Qt::LeftToRight)
{
+ QInputPanelPrivate::get(qApp->inputPanel())->testContext = this;
+ }
+
+ ~PlatformInputContext()
+ {
+ QInputPanelPrivate::get(qApp->inputPanel())->testContext = 0;
}
virtual void showInputPanel()