-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestsControllerTestFixture.cpp
More file actions
185 lines (157 loc) · 6.12 KB
/
Copy pathtestsControllerTestFixture.cpp
File metadata and controls
185 lines (157 loc) · 6.12 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// testsControllerTestFixture.cpp
// Test fixture implementation for Controller Core Unit Tests
// Migrated from MinUnit to Google Test
// Oracle: QD3D 1.6 MacOS Classic
#include "testsControllerTestFixture.h"
// ============================================================================
// Static Member Initialization
// ============================================================================
// Controller state
TQ3Boolean ControllerCoreTestFixture::controllerListChanged = kQ3False;
TQ3Uns32 ControllerCoreTestFixture::controllerListSerialNumber = 0;
TQ3ControllerData ControllerCoreTestFixture::ControllerData = {};
TQ3ControllerStateObject ControllerCoreTestFixture::ControllerState = nullptr;
TQ3Status ControllerCoreTestFixture::Status3D = kQ3Failure;
TQ3ControllerRef ControllerCoreTestFixture::tempController = nullptr;
TQ3ControllerRef ControllerCoreTestFixture::ClientController = nullptr;
TQ3ControllerRef ControllerCoreTestFixture::DriverController = nullptr;
TQ3Boolean ControllerCoreTestFixture::controllerActivation = kQ3False;
// Tracker state
TQ3TrackerObject ControllerCoreTestFixture::ClientTracker = nullptr;
TQ3Boolean ControllerCoreTestFixture::trackerActivation = kQ3False;
float ControllerCoreTestFixture::posTresh = 0.0f;
float ControllerCoreTestFixture::oriTresh = 0.0f;
// Working variables
char ControllerCoreTestFixture::tempString[250] = {0};
TQ3Uns32 ControllerCoreTestFixture::tempUns32 = 0;
TQ3Uns32 ControllerCoreTestFixture::TrackerSerNum = 0;
TQ3Uns32 ControllerCoreTestFixture::CtrlSerNum = 0;
TQ3Boolean ControllerCoreTestFixture::tempBool = kQ3False;
TQ3Boolean ControllerCoreTestFixture::changed = kQ3False;
TQ3Point3D ControllerCoreTestFixture::position = {0.0f, 0.0f, 0.0f};
TQ3Vector3D ControllerCoreTestFixture::deltaPos = {0.0f, 0.0f, 0.0f};
TQ3Quaternion ControllerCoreTestFixture::orientation = {0.0f, 0.0f, 0.0f, 1.0f};
TQ3Quaternion ControllerCoreTestFixture::deltaOri = {0.0f, 0.0f, 0.0f, 1.0f};
float ControllerCoreTestFixture::values[2] = {0.0f, 0.0f};
TQ3Uns32 ControllerCoreTestFixture::whatSet = 0;
TQ3Uns32 ControllerCoreTestFixture::whatGet = 0;
TQ3Uns32 ControllerCoreTestFixture::whatSize = 0;
// Callback tracking
TQ3Uns32 ControllerCoreTestFixture::lastsize = 0;
TQ3Uns32 ControllerCoreTestFixture::what0 = 0;
TQ3Uns32 ControllerCoreTestFixture::what1 = 0;
TQ3Uns32 ControllerCoreTestFixture::what_work = 0;
TQ3Uns32 ControllerCoreTestFixture::trackerProcCalled = 0;
TQ3Uns32 ControllerCoreTestFixture::doBeep = 0;
// ============================================================================
// Setup and Teardown
// ============================================================================
void ControllerCoreTestFixture::SetUpTestSuite() {
// Initialize all static members to default values
controllerListChanged = kQ3False;
controllerListSerialNumber = 0;
std::memset(&ControllerData, 0, sizeof(ControllerData));
ControllerState = nullptr;
Status3D = kQ3Failure;
tempController = nullptr;
ClientController = nullptr;
DriverController = nullptr;
controllerActivation = kQ3False;
ClientTracker = nullptr;
trackerActivation = kQ3False;
posTresh = 0.0f;
oriTresh = 0.0f;
std::memset(tempString, 0, sizeof(tempString));
tempUns32 = 0;
TrackerSerNum = 0;
CtrlSerNum = 0;
tempBool = kQ3False;
changed = kQ3False;
position = {0.0f, 0.0f, 0.0f};
deltaPos = {0.0f, 0.0f, 0.0f};
orientation = {0.0f, 0.0f, 0.0f, 1.0f};
deltaOri = {0.0f, 0.0f, 0.0f, 1.0f};
values[0] = 0.0f;
values[1] = 0.0f;
whatSet = 0;
whatGet = 0;
whatSize = 0;
lastsize = 0;
what0 = 0;
what1 = 0;
what_work = 0;
trackerProcCalled = 0;
doBeep = 0;
}
void ControllerCoreTestFixture::TearDownTestSuite() {
// Cleanup any remaining resources
if (ControllerState != nullptr) {
Q3Object_Dispose(ControllerState);
ControllerState = nullptr;
}
if (ClientTracker != nullptr) {
Q3Object_Dispose(ClientTracker);
ClientTracker = nullptr;
}
// Note: Controllers are references, not owned objects
// They should not be disposed here
ClientController = nullptr;
DriverController = nullptr;
tempController = nullptr;
}
// ============================================================================
// Callback Methods
// ============================================================================
TQ3Status ControllerCoreTestFixture::ChannelGetMethod(
TQ3ControllerRef controllerRef,
TQ3Uns32 channel,
void *data,
TQ3Uns32 *dataSize)
{
(void)controllerRef;
if (data == nullptr || dataSize == nullptr) {
return kQ3Failure;
}
// Note: what0 and what1 are intentionally crossed (matches oracle uniBench.c)
TQ3Status status = kQ3Success;
TQ3Uns32 result = 0;
switch (channel) {
case 0: result = what1; break; // crossed!
case 1: result = what0; break; // crossed!
case 2: result = lastsize; break;
case 3: result = what_work; status = kQ3Failure; break;
default: result = 65000; status = kQ3Failure; break;
}
*((TQ3Uns32*)data) = result;
*dataSize = sizeof(TQ3Uns32);
return status;
}
TQ3Status ControllerCoreTestFixture::ChannelSetMethod(
TQ3ControllerRef controllerRef,
TQ3Uns32 channel,
const void *data,
TQ3Uns32 dataSize)
{
(void)controllerRef;
lastsize = dataSize;
switch (channel) {
case 0: what0 = data ? *((const TQ3Uns32*)data) : 0; break;
case 1: what1 = data ? *((const TQ3Uns32*)data) : 0; break;
case 3: what_work = data ? *((const TQ3Uns32*)data) : 0; break;
default: break;
}
return kQ3Success;
}
TQ3Status ControllerCoreTestFixture::TrackerProc(
TQ3TrackerObject trackerObject,
TQ3ControllerRef controllerRef)
{
(void)trackerObject; // Unused parameter
(void)controllerRef; // Unused parameter
// Increment call counter
trackerProcCalled++;
// Simple tracker behavior - just track that we were called
// In a real implementation, this would update tracker state
// based on controller input
return kQ3Success;
}