diff options
author | Paul Lemire <paul.lemire350@gmail.com> | 2015-06-18 19:27:46 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-06-27 15:15:30 +0000 |
commit | aa35a11b6444d0bc14b5640c636cd6c8cfe931d6 (patch) | |
tree | 6d84e2fe9c567705053b5535d8b492013ed29e92 /tests | |
parent | 2f4ed37c086f1a0e2d152d3a036480c20c0a1c99 (diff) |
Add unit test for VSyncFrameAdvanceService
Change-Id: Ifbdec0345e59e9cde043611609ff383e352e1d3e
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tests')
3 files changed, 99 insertions, 1 deletions
diff --git a/tests/auto/render/render.pro b/tests/auto/render/render.pro index 5393ec79c..7c6ac474e 100644 --- a/tests/auto/render/render.pro +++ b/tests/auto/render/render.pro @@ -10,5 +10,6 @@ contains(QT_CONFIG, private_tests) { renderviewutils \ renderviews \ rendermaterial \ - rendermesh + rendermesh \ + vsyncframeadvanceservice } diff --git a/tests/auto/render/vsyncframeadvanceservice/tst_vsyncframeadvanceservice.cpp b/tests/auto/render/vsyncframeadvanceservice/tst_vsyncframeadvanceservice.cpp new file mode 100644 index 000000000..48b7a2c0e --- /dev/null +++ b/tests/auto/render/vsyncframeadvanceservice/tst_vsyncframeadvanceservice.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Paul Lemire +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <Qt3DRenderer/private/vsyncframeadvanceservice_p.h> + +class FakeRenderThread Q_DECL_FINAL : public QThread +{ +public: + FakeRenderThread(Qt3D::Render::VSyncFrameAdvanceService *tickService) + : m_tickService(tickService) + { + } + + // QThread interface +protected: + void run() Q_DECL_FINAL + { + QThread::msleep(1000); + m_tickService->proceedToNextFrame(); + } + +private: + Qt3D::Render::VSyncFrameAdvanceService *m_tickService; +}; + +class tst_VSyncFrameAdvanceService : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + + void checkSynchronisation() + { + // GIVEN + Qt3D::Render::VSyncFrameAdvanceService tickService; + FakeRenderThread renderThread(&tickService); + QElapsedTimer t; + + // WHEN + t.start(); + renderThread.start(); + tickService.waitForNextFrame(); + + // THEN + QVERIFY(t.elapsed() >= 1000); + } + +}; + +QTEST_MAIN(tst_VSyncFrameAdvanceService) + +#include "tst_vsyncframeadvanceservice.moc" diff --git a/tests/auto/render/vsyncframeadvanceservice/vsyncframeadvanceservice.pro b/tests/auto/render/vsyncframeadvanceservice/vsyncframeadvanceservice.pro new file mode 100644 index 000000000..25d8a70e5 --- /dev/null +++ b/tests/auto/render/vsyncframeadvanceservice/vsyncframeadvanceservice.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +TARGET = tst_vsyncframeadvanceservice + +QT += 3dcore 3dcore-private 3drenderer 3drenderer-private testlib + +CONFIG += testcase + +SOURCES += \ + tst_vsyncframeadvanceservice.cpp |