File: testsimulation.cpp

package info (click to toggle)
wiredpanda 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,560 kB
  • sloc: cpp: 16,024; sh: 232; ansic: 52; xml: 8; makefile: 5; javascript: 1
file content (50 lines) | stat: -rw-r--r-- 1,411 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2015 - 2025, GIBIS-UNIFESP and the wiRedPanda contributors
// SPDX-License-Identifier: GPL-3.0-or-later

#include "testsimulation.h"

#include "and.h"
#include "common.h"
#include "inputbutton.h"
#include "led.h"
#include "qneconnection.h"
#include "scene.h"
#include "workspace.h"

#include <QTest>

void TestSimulation::testCase1()
{
    WorkSpace workspace;

    InputButton button1;
    InputButton button2;
    And andItem;
    Led led;
    QNEConnection connection1;
    QNEConnection connection2;
    QNEConnection connection3;

    auto *scene = workspace.scene();
    scene->addItem(&led);
    scene->addItem(&andItem);
    scene->addItem(&button1);
    scene->addItem(&button2);
    scene->addItem(&connection1);
    scene->addItem(&connection2);
    scene->addItem(&connection3);

    connection1.setStartPort(button1.outputPort());
    connection1.setEndPort(andItem.inputPort(0));
    connection2.setStartPort(button2.outputPort());
    connection2.setEndPort(andItem.inputPort(1));
    connection3.setStartPort(andItem.outputPort());
    connection3.setEndPort(led.inputPort());

    const auto elements(Common::sortGraphicElements(scene->elements()));

    QVERIFY((elements.at(0) == &button1) || (elements.at(1) == &button1));
    QVERIFY((elements.at(0) == &button2) || (elements.at(1) == &button2));
    QVERIFY(elements.at(2) == &andItem);
    QVERIFY(elements.at(3) == &led);
}