test update

master
Denes Matetelki 14 years ago
parent c55079ddbc
commit 4136447e73

@ -1,26 +1,25 @@
QT += core gui svg QT += core gui svg xml
CONFIG += qtestlib CONFIG += qtestlib
TARGET = qtmindmap_test TARGET = qtmindmap_test
SOURCES += mainwindow.cpp \ SOURCES += src/mainwindow.cpp \
aboutdialog.cpp \ src/graphwidget.cpp \
graphwidget.cpp \ src/node.cpp \
node.cpp \ src/edge.cpp \
edge.cpp \ src/systemtray.cpp \
systemtray.cpp \ src/argumentparser.cpp \
argumentparser.cpp \ test/algorithmtests.cpp
algorithmtests.cpp
HEADERS += mainwindow.h \ HEADERS += include/mainwindow.h \
aboutdialog.h \ include/graphwidget.h \
graphwidget.h \ include/node.h \
node.h \ include/edge.h \
edge.h \ include/systemtray.h \
systemtray.h \ include/argumentparser.h \
argumentparser.h \ test/algorithmtests.h
algorithmtests.h
FORMS += mainwindow.ui \ FORMS += ui/mainwindow.ui
aboutdialog.ui
RESOURCES = images/qtmindmap.qrc

@ -4,9 +4,10 @@
#include <QDebug> #include <QDebug>
#include "node.h" #include "include/mainwindow.h"
#include "include/graphwidget.h"
#include "edge.h" #include "include/node.h"
#include "include/edge.h"
static const double Pi = 3.14159265358979323846264338327950288419717; static const double Pi = 3.14159265358979323846264338327950288419717;
@ -30,14 +31,18 @@ double angleOfPoints(const QPointF &a, const QPointF &b)
void AlgorithmTests::calculateBiggestAngle() void AlgorithmTests::calculateBiggestAngle()
{ {
MainWindow *mainWindow = new MainWindow;
GraphWidget *graphWidget = new GraphWidget(mainWindow);
// no edges // no edges
Node *node1 = new Node(); Node *node1 = new Node(graphWidget);
node1->setPos(0,0); node1->setPos(0,0);
QCOMPARE(node1->calculateBiggestAngle(), Pi * 1.5); QCOMPARE(node1->calculateBiggestAngle(), Pi * 1.5);
// one egde // one egde
// 1 // 1
Node *node2 = new Node(); Node *node2 = new Node(graphWidget);
node2->setPos(30,0); node2->setPos(30,0);
Edge *edge1 = new Edge(node1, node2); Edge *edge1 = new Edge(node1, node2);
@ -60,12 +65,12 @@ void AlgorithmTests::calculateBiggestAngle()
node2->setPos(30,0); node2->setPos(30,0);
edge1->m_angle = angleOfPoints(node1->pos(), node2->pos()); edge1->m_angle = angleOfPoints(node1->pos(), node2->pos());
Node *node3 = new Node(); Node *node3 = new Node(graphWidget);
node3->setPos(-30,0); node3->setPos(-30,0);
Edge *edge2 = new Edge(node1, node3); Edge *edge2 = new Edge(node1, node3);
edge2->m_angle = angleOfPoints(node1->pos(), node3->pos()); edge2->m_angle = angleOfPoints(node1->pos(), node3->pos());
Node *node4 = new Node(); Node *node4 = new Node(graphWidget);
node4->setPos(0, -30); node4->setPos(0, -30);
Edge *edge3 = new Edge(node1, node4); Edge *edge3 = new Edge(node1, node4);
edge3->m_angle = angleOfPoints(node1->pos(), node4->pos()); edge3->m_angle = angleOfPoints(node1->pos(), node4->pos());
@ -78,6 +83,10 @@ void AlgorithmTests::calculateBiggestAngle()
delete node1; delete node1;
delete node2; delete node2;
delete node3; delete node3;
delete node4;
delete graphWidget;
delete mainWindow;
} }

Loading…
Cancel
Save