~mterry/qtvideo-node/dont-install-tests

« back to all changes in this revision

Viewing changes to unittests/shadervideonode/tst_shadervideonode.cpp

  • Committer: Tarmac
  • Author(s): Guenter Schwann
  • Date: 2012-11-09 10:57:05 UTC
  • mfrom: (5.1.1 qtvideonode-plugin-tests)
  • Revision ID: tarmac-20121109105705-4i02o2phcmtfowde
* Spliting up code in separate files
* Add a unit test.

Approved by PS Jenkins bot, Michael Zanetti.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Guenter Schwann <guenter.schwann@canonical.com>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; version 3.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include <QtTest/QtTest>
 
21
 
 
22
#include <QImage>
 
23
#include <QVideoFrame>
 
24
#include <QVideoSurfaceFormat>
 
25
 
 
26
#include <shadervideomaterial.h>
 
27
 
 
28
#include "camera_compatibility_layer.h"
 
29
 
 
30
#define private public
 
31
#include "shadervideonode.h"
 
32
 
 
33
class tst_ShaderVideoNode : public QObject
 
34
{
 
35
    Q_OBJECT
 
36
private slots:
 
37
    void testSetCurrentFrame();
 
38
};
 
39
 
 
40
void tst_ShaderVideoNode::testSetCurrentFrame()
 
41
{
 
42
    QVideoSurfaceFormat format;
 
43
    ShaderVideoNode node(format);
 
44
 
 
45
    CameraControl *cc = new CameraControl;
 
46
    QImage img(320, 240, QImage::Format_ARGB32);
 
47
    QVideoFrame frame(img);
 
48
 
 
49
    node.setCurrentFrame(frame);
 
50
    QCOMPARE((int)node.m_material->cameraControl(), 0);
 
51
 
 
52
    frame.setMetaData("CamControl", (int)cc);
 
53
    node.setCurrentFrame(frame);
 
54
    QCOMPARE((int)node.m_material->cameraControl(), (int)cc);
 
55
}
 
56
 
 
57
QTEST_MAIN(tst_ShaderVideoNode)
 
58
 
 
59
#include "tst_shadervideonode.moc"