Skip to content

Commit

Permalink
fixup tests to build with refactor
Browse files Browse the repository at this point in the history
Change-Id: Iab4adc9e19fab67402918bb737fff2fce6c292bd
Reviewed-on: http://codereview.qt-project.org/4545
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
  • Loading branch information
Matthew Cattell authored and Samuel Rødal committed Sep 9, 2011
1 parent d93cc35 commit 4153ee1
Show file tree
Hide file tree
Showing 20 changed files with 146 additions and 177 deletions.
4 changes: 2 additions & 2 deletions tests/auto/auto.pro
@@ -1,7 +1,7 @@
TEMPLATE=subdirs
SUBDIRS=\
declarative \
qtquick1 \
declarative


contains(QT_CONFIG, qmltest): SUBDIRS += qmltest

Expand Down
4 changes: 2 additions & 2 deletions tests/auto/declarative/declarative.pro
Expand Up @@ -73,8 +73,8 @@ SGTESTS = \
qsgpositioners \
qsgrepeater \
qsgtext \
qsgtextedit \
qsgtextinput \
# qsgtextedit \
# qsgtextinput \
qsgvisualdatamodel \


Expand Down
2 changes: 1 addition & 1 deletion tests/auto/declarative/nodes/tst_nodestest.cpp
Expand Up @@ -47,7 +47,7 @@
#include <private/qsgnodeupdater_p.h>

#include <qsgsimplerectnode.h>

#include <QtOpenGL/QGLWidget>
class NodesTest : public QObject
{
Q_OBJECT
Expand Down
Expand Up @@ -79,9 +79,9 @@ void tst_qdeclarativeapplication::active()

// active
view.show();
QApplication::setActiveWindow(&view);
QTest::qWaitForWindowShown(&view);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
view.requestActivateWindow();
QTest::qWait(50);
QTRY_COMPARE(view.status(), QSGView::Ready);
QCOMPARE(item->property("active").toBool(), QApplication::activeWindow() != 0);

// not active again
Expand Down
@@ -1,5 +1,5 @@
load(qttest_p4)
contains(QT_CONFIG,declarative): QT += declarative
contains(QT_CONFIG,declarative): QT += declarative widgets
macx:CONFIG -= app_bundle

SOURCES += tst_qdeclarativeproperty.cpp
Expand Down
Expand Up @@ -44,7 +44,7 @@
#include <QtDeclarative/qdeclarativeproperty.h>
#include <QtDeclarative/private/qdeclarativeproperty_p.h>
#include <private/qdeclarativebinding_p.h>
#include <QtGui/QLineEdit>
#include <QtWidgets/QLineEdit>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdir.h>

Expand Down
13 changes: 7 additions & 6 deletions tests/auto/declarative/qsganimatedimage/tst_qsganimatedimage.cpp
Expand Up @@ -154,9 +154,10 @@ void tst_qsganimatedimage::mirror_running()
int width = anim->property("width").toInt();

QCOMPARE(anim->currentFrame(), 0);
QPixmap frame0 = canvas->renderPixmap();
QPixmap frame0 = QPixmap::fromImage(canvas->grabFrameBuffer());

anim->setCurrentFrame(1);
QPixmap frame1 = canvas->renderPixmap();
QPixmap frame1 = QPixmap::fromImage(canvas->grabFrameBuffer());

anim->setCurrentFrame(0);

Expand All @@ -167,11 +168,11 @@ void tst_qsganimatedimage::mirror_running()
anim->setProperty("mirror", true);

QCOMPARE(anim->currentFrame(), 1);
QPixmap frame1_flipped = canvas->renderPixmap();
QPixmap frame1_flipped = QPixmap::fromImage(canvas->grabFrameBuffer());

QTRY_VERIFY(spy.count() == 1); spy.clear();
QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first
QPixmap frame0_flipped = canvas->renderPixmap();
QPixmap frame0_flipped = QPixmap::fromImage(canvas->grabFrameBuffer());

QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved", SkipSingle);

Expand All @@ -198,7 +199,7 @@ void tst_qsganimatedimage::mirror_notRunning()
QVERIFY(anim);

int width = anim->property("width").toInt();
QPixmap screenshot = canvas->renderPixmap();
QPixmap screenshot = QPixmap::fromImage(canvas->grabFrameBuffer());

QTransform transform;
transform.translate(width, 0).scale(-1, 1.0);
Expand All @@ -209,7 +210,7 @@ void tst_qsganimatedimage::mirror_notRunning()
bool paused = anim->isPlaying();

anim->setProperty("mirror", true);
screenshot = canvas->renderPixmap();
screenshot = QPixmap::fromImage(canvas->grabFrameBuffer());

QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved", SkipSingle);
QCOMPARE(screenshot, expected);
Expand Down
2 changes: 0 additions & 2 deletions tests/auto/declarative/qsgcanvas/tst_qsgcanvas.cpp
Expand Up @@ -231,8 +231,6 @@ void tst_qsgcanvas::touchEvent_basic()
QTest::touchEvent(canvas).press(0, topItem->mapToScene(pos).toPoint(),canvas);
QTest::qWait(50);



QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);

QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
Expand Down
3 changes: 0 additions & 3 deletions tests/auto/declarative/qsgflipable/tst_qsgflipable.cpp
Expand Up @@ -81,9 +81,6 @@ tst_qsgflipable::tst_qsgflipable()
}
void tst_qsgflipable::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("Flipable item needs OpenGL 2.0", SkipAll);
}

void tst_qsgflipable::cleanupTestCase()
Expand Down
46 changes: 22 additions & 24 deletions tests/auto/declarative/qsgfocusscope/tst_qsgfocusscope.cpp
Expand Up @@ -80,9 +80,6 @@ private slots:
};
void tst_qsgfocusscope::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("FocusScope item needs OpenGL 2.0", SkipAll);
}

void tst_qsgfocusscope::cleanupTestCase()
Expand Down Expand Up @@ -127,15 +124,15 @@ void tst_qsgfocusscope::basic()
QVERIFY(item3 != 0);

view->show();
qApp->setActiveWindow(view);
view->requestActivateWindow();
qApp->processEvents();

#ifdef Q_WS_X11
// to be safe and avoid failing setFocus with window managers
qt_x11_wait_for_window_manager(view);
#endif

QVERIFY(view->hasFocus());
QVERIFY(view->isTopLevel());
QVERIFY(item0->hasActiveFocus() == true);
QVERIFY(item1->hasActiveFocus() == true);
QVERIFY(item2->hasActiveFocus() == false);
Expand Down Expand Up @@ -173,15 +170,15 @@ void tst_qsgfocusscope::nested()
QVERIFY(item5 != 0);

view->show();
qApp->setActiveWindow(view);
view->requestActivateWindow();
qApp->processEvents();

#ifdef Q_WS_X11
// to be safe and avoid failing setFocus with window managers
qt_x11_wait_for_window_manager(view);
#endif

QVERIFY(view->hasFocus());
QVERIFY(view->windowState() == Qt::WindowActive);

QVERIFY(item1->hasActiveFocus() == true);
QVERIFY(item2->hasActiveFocus() == true);
Expand All @@ -206,15 +203,15 @@ void tst_qsgfocusscope::noFocus()
QVERIFY(item3 != 0);

view->show();
qApp->setActiveWindow(view);
view->requestActivateWindow();
qApp->processEvents();

#ifdef Q_WS_X11
// to be safe and avoid failing setFocus with window managers
qt_x11_wait_for_window_manager(view);
#endif

QVERIFY(view->hasFocus());
QVERIFY(view->windowState() == Qt::WindowActive);
QVERIFY(item0->hasActiveFocus() == false);
QVERIFY(item1->hasActiveFocus() == false);
QVERIFY(item2->hasActiveFocus() == false);
Expand Down Expand Up @@ -250,15 +247,15 @@ void tst_qsgfocusscope::textEdit()
QVERIFY(item3 != 0);

view->show();
qApp->setActiveWindow(view);
view->requestActivateWindow();
qApp->processEvents();

#ifdef Q_WS_X11
// to be safe and avoid failing setFocus with window managers
qt_x11_wait_for_window_manager(view);
#endif

QVERIFY(view->hasFocus());
QVERIFY(view->windowState() == Qt::WindowActive);
QVERIFY(item0->hasActiveFocus() == true);
QVERIFY(item1->hasActiveFocus() == true);
QVERIFY(item2->hasActiveFocus() == false);
Expand Down Expand Up @@ -308,15 +305,15 @@ void tst_qsgfocusscope::forceFocus()
QVERIFY(item5 != 0);

view->show();
qApp->setActiveWindow(view);
view->requestActivateWindow();
qApp->processEvents();

#ifdef Q_WS_X11
// to be safe and avoid failing setFocus with window managers
qt_x11_wait_for_window_manager(view);
#endif

QVERIFY(view->hasFocus());
QVERIFY(view->windowState() == Qt::WindowActive);
QVERIFY(item0->hasActiveFocus() == true);
QVERIFY(item1->hasActiveFocus() == true);
QVERIFY(item2->hasActiveFocus() == false);
Expand Down Expand Up @@ -350,7 +347,7 @@ void tst_qsgfocusscope::noParentFocus()
QVERIFY(view->rootObject());

view->show();
qApp->setActiveWindow(view);
view->requestActivateWindow();
qApp->processEvents();

#ifdef Q_WS_X11
Expand Down Expand Up @@ -382,7 +379,7 @@ void tst_qsgfocusscope::signalEmission()
QVERIFY(item4 != 0);

view->show();
qApp->setActiveWindow(view);
view->requestActivateWindow();
qApp->processEvents();

#ifdef Q_WS_X11
Expand All @@ -393,7 +390,7 @@ void tst_qsgfocusscope::signalEmission()
QVariant blue(QColor("blue"));
QVariant red(QColor("red"));

QVERIFY(view->hasFocus());
QVERIFY(view->windowState() == Qt::WindowActive);
item1->setFocus(true);
QCOMPARE(item1->property("color"), red);
QCOMPARE(item2->property("color"), blue);
Expand Down Expand Up @@ -434,15 +431,15 @@ void tst_qsgfocusscope::qtBug13380()

view->show();
QVERIFY(view->rootObject());
qApp->setActiveWindow(view);
view->requestActivateWindow();
qApp->processEvents();

#ifdef Q_WS_X11
// to be safe and avoid failing setFocus with window managers
qt_x11_wait_for_window_manager(view);
#endif

QVERIFY(view->hasFocus());
QVERIFY(view->windowState() == Qt::WindowActive);
QVERIFY(view->rootObject()->property("noFocus").toBool());

view->rootObject()->setProperty("showRect", true);
Expand All @@ -457,7 +454,7 @@ void tst_qsgfocusscope::forceActiveFocus()
view->setSource(QUrl::fromLocalFile(SRCDIR "/data/forceActiveFocus.qml"));

view->show();
qApp->setActiveWindow(view);
view->requestActivateWindow();
qApp->processEvents();

#ifdef Q_WS_X11
Expand Down Expand Up @@ -600,7 +597,7 @@ void tst_qsgfocusscope::canvasFocus()
QSignalSpy item2ActiveFocusSpy(item2, SIGNAL(activeFocusChanged(bool)));

// until the canvas widget has gained focus, no one should have active focus
QCOMPARE(view->hasFocus(), false);
QCOMPARE((view->windowState() == Qt::WindowActive), false);
QCOMPARE(rootItem->hasFocus(), false);
QCOMPARE(rootItem->hasActiveFocus(), false);
QCOMPARE(scope1->hasFocus(), true);
Expand All @@ -613,7 +610,7 @@ void tst_qsgfocusscope::canvasFocus()
QCOMPARE(item2->hasActiveFocus(), false);

view->show();
qApp->setActiveWindow(view);
view->requestActivateWindow();
qApp->processEvents();

#ifdef Q_WS_X11
Expand All @@ -622,7 +619,7 @@ void tst_qsgfocusscope::canvasFocus()
#endif

// Now the canvas has focus, active focus given to item1
QTRY_COMPARE(view->hasFocus(), true);
QTRY_COMPARE((view->windowState() == Qt::WindowActive), true);
QCOMPARE(rootItem->hasFocus(), true);
QCOMPARE(rootItem->hasActiveFocus(), true);
QCOMPARE(scope1->hasFocus(), true);
Expand All @@ -640,7 +637,8 @@ void tst_qsgfocusscope::canvasFocus()
QCOMPARE(item1FocusSpy.count(), 0);
QCOMPARE(item1ActiveFocusSpy.count(), 1);

view->clearFocus();

view->setWindowState(Qt::WindowNoState);
QCOMPARE(rootItem->hasFocus(), false);
QCOMPARE(rootItem->hasActiveFocus(), false);
QCOMPARE(scope1->hasFocus(), true);
Expand Down Expand Up @@ -680,7 +678,7 @@ void tst_qsgfocusscope::canvasFocus()
QCOMPARE(item2ActiveFocusSpy.count(), 0);

// give the canvas focus, and item2 will get active focus
view->setFocus();
view->setWindowState(Qt::WindowActive);

QCOMPARE(rootItem->hasFocus(), true);
QCOMPARE(rootItem->hasActiveFocus(), true);
Expand Down

0 comments on commit 4153ee1

Please sign in to comment.