32 #include <gtest/gtest.h>
34 #ifdef RVIZ_DEPRECATE_QT4_SLOTS
35 #undef RVIZ_DEPRECATE_QT4_SLOTS
52 EXPECT_EQ(
"chub", p.
getName().toStdString());
66 EXPECT_EQ(199, p.
getValue().toInt());
72 Property p(
"", 1,
"",
nullptr, SLOT(changed()), &r);
73 p.
connect(&p, SIGNAL(aboutToChange()), &r, SLOT(aboutToChange()));
75 EXPECT_EQ(
" aboutToChange, v=1 changed, v=17", r.
result.toStdString());
79 Property p2(
"", 2,
"", &p, SIGNAL(changed()));
80 p2.
connect(&p2, SIGNAL(aboutToChange()), &r, SLOT(aboutToChange()));
82 EXPECT_EQ(
" aboutToChange, v=2 changed, v=17", r.
result.toStdString());
86 Property p3(
"", 3,
"", &p, SIGNAL(changed()));
87 p3.
connect(&p3, SIGNAL(aboutToChange()), &r, SLOT(aboutToChange()));
89 EXPECT_EQ(
" aboutToChange, v=3 changed, v=17", r.
result.toStdString());
96 "", 1,
"",
nullptr, [&r] { r.
changed(); }, &r);
99 EXPECT_EQ(
" aboutToChange, v=1 changed, v=17", r.
result.toStdString());
105 r.
result +=
" free lambda";
109 EXPECT_EQ(
" aboutToChange, v=2 free lambda", r.
result.toStdString());
114 "", 3,
"", &p, [&r] { r.
changed(); }, &r);
117 EXPECT_EQ(
" aboutToChange, v=3 changed, v=37", r.
result.toStdString());
127 EXPECT_EQ(
" aboutToChange, v=1 changed, v=17", r.
result.toStdString());
134 EXPECT_EQ(
" aboutToChange, v=2 changed, v=17", r.
result.toStdString());
141 EXPECT_EQ(
" aboutToChange, v=3 changed, v=37", r.
result.toStdString());
144 #if 0 // This should fail to compile due to receiver type mismatching slot
152 EXPECT_EQ(
"", r.
result.toStdString());
159 new Property(
"Alpha", 0.5,
"The amount of transparency to apply to the grid lines.", display);
161 new Property(
"Beta Band", 10,
"The number of betas to apply to the grid lines.", display);
162 new Property(
"Gamma Topic",
"chubby",
"The topic on which to listen for Gamma messages.", display);
163 Property* position =
new Property(
"Position", QVariant(),
"Position of the chub.", display);
164 new Property(
"X", 1.1
f,
"X component of the position of the chub.", position);
165 new Property(
"Y", 0.717
f,
"Y component of the position of the chub.", position);
177 EXPECT_EQ(0.717
f, y);
180 printf(
"Next line should say 'ERROR' but not crash.\n");
196 Ogre::Vector3 vec(1, 2, 3);
200 EXPECT_EQ(1, vec2.x);
201 EXPECT_EQ(2, vec2.y);
202 EXPECT_EQ(3, vec2.z);
231 EXPECT_EQ(0.9
f, vec.x);
232 EXPECT_EQ(1.1
f, vec.y);
233 EXPECT_EQ(1.3
f, vec.z);
247 VectorProperty p(
"", Ogre::Vector3::ZERO,
"",
nullptr, SLOT(changed()), &r);
248 p.
connect(&p, SIGNAL(aboutToChange()), &r, SLOT(aboutToChange()));
250 p.
setVector(Ogre::Vector3(.1, .0001, 1000));
251 EXPECT_EQ(
" aboutToChange, v=0; 0; 0 changed, v=0.1; 0.0001; 1000", r.
result.toStdString());
255 EXPECT_EQ(
" aboutToChange, v=0.1; 0.0001; 1000 changed, v=0.1; 0.0001; 2.1", r.
result.toStdString());
262 EXPECT_EQ(0, quat.x);
263 EXPECT_EQ(0, quat.y);
264 EXPECT_EQ(0, quat.z);
265 EXPECT_EQ(1, quat.w);
271 Ogre::Quaternion quat(4, 1, 2, 3);
275 EXPECT_EQ(1, quat2.x);
276 EXPECT_EQ(2, quat2.y);
277 EXPECT_EQ(3, quat2.z);
278 EXPECT_EQ(4, quat2.w);
287 EXPECT_EQ(1, quat.x);
288 EXPECT_EQ(2, quat.y);
289 EXPECT_EQ(3, quat.z);
290 EXPECT_EQ(4, quat.w);
295 EXPECT_EQ(1, quat.x);
296 EXPECT_EQ(2, quat.y);
297 EXPECT_EQ(3, quat.z);
298 EXPECT_EQ(4, quat.w);
310 EXPECT_EQ(0.9
f, quat.x);
311 EXPECT_EQ(1.1
f, quat.y);
312 EXPECT_EQ(1.3
f, quat.z);
313 EXPECT_EQ(1.5
f, quat.w);
328 QuaternionProperty p(
"", Ogre::Quaternion::IDENTITY,
"",
nullptr, SLOT(changed()), &r);
329 p.
connect(&p, SIGNAL(aboutToChange()), &r, SLOT(aboutToChange()));
332 EXPECT_EQ(
" aboutToChange, v=0; 0; 0; 1 changed, v=0.1; 0.0001; 1000; 1", r.
result.toStdString());
336 EXPECT_EQ(
" aboutToChange, v=0.1; 0.0001; 1000; 1 changed, v=0.1; 0.0001; 2.1; 1",
344 EXPECT_EQ(0, color.red());
345 EXPECT_EQ(0, color.green());
346 EXPECT_EQ(0, color.blue());
352 QColor color(1, 2, 3);
356 EXPECT_EQ(1, color2.red());
357 EXPECT_EQ(2, color2.green());
358 EXPECT_EQ(3, color2.blue());
367 EXPECT_EQ(1, color.red());
368 EXPECT_EQ(2, color.green());
369 EXPECT_EQ(3, color.blue());
374 EXPECT_EQ(1, color.red());
375 EXPECT_EQ(2, color.green());
376 EXPECT_EQ(3, color.blue());
385 EXPECT_EQ(0, color.red());
386 EXPECT_EQ(255, color.green());
387 EXPECT_EQ(3, color.blue());
393 ColorProperty p(
"", QColor(0, 0, 0),
"",
nullptr, SLOT(changed()), &r);
394 p.
connect(&p, SIGNAL(aboutToChange()), &r, SLOT(aboutToChange()));
397 EXPECT_EQ(
" aboutToChange, v=0; 0; 0 changed, v=1; 2; 3", r.
result.toStdString());
419 int main(
int argc,
char** argv)
421 testing::InitGoogleTest(&argc, argv);
422 return RUN_ALL_TESTS();