-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectionBoxObject_test.cpp
More file actions
94 lines (81 loc) · 2.47 KB
/
SelectionBoxObject_test.cpp
File metadata and controls
94 lines (81 loc) · 2.47 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <gtest/gtest.h>
#include <QApplication>
#include <QCoreApplication>
#include <QThread>
#include "SelectionBoxObject.h"
#include "Manager.h"
#include "GlobalDefinitions.h"
#include "TestHelpers.h"
class SelectionBoxObjectTest : public ::testing::Test
{
protected:
void SetUp() override
{
Manager::kill();
QThread::msleep(50);
app = qobject_cast<QApplication*>(QCoreApplication::instance());
ASSERT_NE(app, nullptr);
if (!tryInitOgre()) {
GTEST_SKIP() << "Skipping: Ogre initialization failed";
}
createStandardOgreMaterials();
}
void TearDown() override
{
Manager::kill();
if (app)
app->processEvents();
QThread::msleep(50);
}
QApplication* app = nullptr;
};
TEST_F(SelectionBoxObjectTest, Construction)
{
SelectionBoxObject box("TestSelBox");
// Constructor should set query flags to 0
EXPECT_EQ(box.getQueryFlags(), 0x00u);
}
TEST_F(SelectionBoxObjectTest, DefaultBoxColour)
{
SelectionBoxObject box("TestSelBoxColour");
Ogre::ColourValue expected(0.8f, 0.8f, 0.8f, 0.8f);
EXPECT_EQ(box.getBoxColour(), expected);
}
TEST_F(SelectionBoxObjectTest, SetBoxColour)
{
SelectionBoxObject box("TestSelBoxSetColour");
Ogre::ColourValue red(1.0f, 0.0f, 0.0f, 1.0f);
box.setBoxColour(red);
EXPECT_EQ(box.getBoxColour(), red);
}
TEST_F(SelectionBoxObjectTest, DrawBox_FloatOverload)
{
SelectionBoxObject box("TestSelBoxDrawFloat");
// drawBox with floats should not crash
box.drawBox(-0.5f, 0.5f, 0.5f, -0.5f);
}
TEST_F(SelectionBoxObjectTest, DrawBox_VectorOverload)
{
SelectionBoxObject box("TestSelBoxDrawVec");
Ogre::Vector2 topLeft(-0.5f, 0.5f);
Ogre::Vector2 bottomRight(0.5f, -0.5f);
// drawBox with Vector2 should not crash
box.drawBox(topLeft, bottomRight);
}
TEST_F(SelectionBoxObjectTest, DrawBox_MultipleCalls)
{
SelectionBoxObject box("TestSelBoxMulti");
// Multiple drawBox calls test that clear() works internally
box.drawBox(-1.0f, 1.0f, 1.0f, -1.0f);
box.drawBox(-0.5f, 0.5f, 0.5f, -0.5f);
box.drawBox(0.0f, 0.0f, 1.0f, -1.0f);
}
TEST_F(SelectionBoxObjectTest, SetBoxColourAffectsSubsequentDraws)
{
SelectionBoxObject box("TestSelBoxColourDraw");
Ogre::ColourValue green(0.0f, 1.0f, 0.0f, 1.0f);
box.setBoxColour(green);
EXPECT_EQ(box.getBoxColour(), green);
// Drawing after colour change should not crash
box.drawBox(-0.2f, 0.2f, 0.2f, -0.2f);
}