-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtst_testgui.cpp
More file actions
38 lines (28 loc) · 1.3 KB
/
Copy pathtst_testgui.cpp
File metadata and controls
38 lines (28 loc) · 1.3 KB
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
#include "tst_testgui.h"
#include "drawarea.h"
#include "particle.h"
void MyTestGUI::testCase1() {
// Test the initialization of basic context
QWidget* simulation = new QWidget();
DrawArea *draw_area = new DrawArea(800, 300, simulation);
Particle circle(draw_area->viewToWorld({{ 300, 200 }}), {{ 0.0, 0.0 }}, 15, 1.0);
Object object(Qt::red, circle);
draw_area->context.objects.push_back(std::move(object));
QVERIFY(!draw_area->context.objects.empty());
}
void MyTestGUI::testPlanCollider() {
// Test PlanCollider by creating a physical situation where the associated constraint should be satisfied
QWidget* simulation = new QWidget();
DrawArea *draw_area = new DrawArea(800, 300, simulation);
Particle circle(draw_area->viewToWorld({{ 300, 200 }}), {{ 0.0, 0.0 }}, 15, 1.0);
Object object(Qt::red, circle);
draw_area->context.objects.push_back(std::move(object));
auto collider = std::make_unique<PlanCollider>(
draw_area->worldToView(Vec2{{30.0, 100.0}}), normalize(Vec2{{0.0, 1.0}}));
auto* colliderPtr = collider.get();
draw_area->context.addCollider(std::move(collider));
auto constraint = std::make_unique<StaticConstraint>(*colliderPtr, &circle);
QVERIFY(constraint->isSatisfied());
}
QTEST_MAIN(MyTestGUI)
#include "tst_testgui.moc"