18 #include <gtest/gtest.h>
38 TEST(CORE_PROPERTY_CLASS, Test_EmptyProperty)
48 ASSERT_EQ(p.
getName(),
nullptr);
58 ASSERT_EQ(p.
getText(),
nullptr);
61 ASSERT_EQ(p.
getBLOB(),
nullptr);
64 TEST(CORE_PROPERTY_CLASS, Test_PropertySetters)
88 ASSERT_EQ(p.
getName(),
nullptr);
102 ASSERT_EQ(p.
getText(),
nullptr);
105 ASSERT_EQ(p.
getBLOB(),
nullptr);
115 ASSERT_STREQ(p.
getName(),
"name field");
116 ASSERT_STREQ(p.
getLabel(),
"label field");
127 ASSERT_EQ(p.
getText(),
nullptr);
130 ASSERT_EQ(p.
getBLOB(),
nullptr);
139 ASSERT_EQ(p.
getName(),
nullptr);
153 ASSERT_EQ(p.
getText(),
nullptr);
156 ASSERT_EQ(p.
getBLOB(),
nullptr);
159 TEST(CORE_PROPERTY_CLASS, DISABLED_Test_Integrity)
188 EXPECT_EQ(p.
getText(),
nullptr);
191 EXPECT_EQ(p.
getBLOB(),
nullptr);
199 TEST(CORE_PROPERTY_CLASS, Test_PropertyNumber)
204 p[0].setLabel(
"widget label");
206 p[0].setMinMax(-10, 10);
208 p.setDeviceName(
"property device");
209 p.setName(
"property name");
210 p.setLabel(
"property label");
211 p.setGroupName(
"property group");
212 p.setPermission(
IP_RW);
216 ASSERT_STREQ(p[0].getName(),
"widget name");
217 ASSERT_STREQ(p[0].getLabel(),
"widget label");
218 ASSERT_EQ(p[0].getValue(), 4);
219 ASSERT_EQ(p[0].getMin(), -10);
220 ASSERT_EQ(p[0].getMax(), 10);
222 ASSERT_STREQ(p.getDeviceName(),
"property device");
223 ASSERT_STREQ(p.getName(),
"property name");
224 ASSERT_STREQ(p.getLabel(),
"property label");
225 ASSERT_STREQ(p.getGroupName(),
"property group");
226 ASSERT_EQ(p.getPermission(),
IP_RW);
227 ASSERT_EQ(p.getTimeout(), 1000);
228 ASSERT_EQ(p.getState(),
IPS_OK);
231 p[0].setName(
"widget other name");
232 p[0].setLabel(
"widget other label");
234 p[0].setMinMax(-100, 100);
236 p.setDeviceName(
"property other device");
237 p.setName(
"property other name");
238 p.setLabel(
"property other label");
239 p.setGroupName(
"property other group");
240 p.setPermission(
IP_RO);
244 ASSERT_STREQ(p[0].getName(),
"widget other name");
245 ASSERT_STREQ(p[0].getLabel(),
"widget other label");
246 ASSERT_EQ(p[0].getValue(), 40);
247 ASSERT_EQ(p[0].getMin(), -100);
248 ASSERT_EQ(p[0].getMax(), 100);
250 ASSERT_STREQ(p.getDeviceName(),
"property other device");
251 ASSERT_STREQ(p.getName(),
"property other name");
252 ASSERT_STREQ(p.getLabel(),
"property other label");
253 ASSERT_STREQ(p.getGroupName(),
"property other group");
254 ASSERT_EQ(p.getPermission(),
IP_RO);
255 ASSERT_EQ(p.getTimeout(), 500);
265 TEST(CORE_PROPERTY_CLASS, Test_PropertySwitch)
270 p[0].setLabel(
"widget label");
273 p.setDeviceName(
"property device");
274 p.setName(
"property name");
275 p.setLabel(
"property label");
276 p.setGroupName(
"property group");
277 p.setPermission(
IP_RW);
281 ASSERT_STREQ(p[0].getName(),
"widget name");
282 ASSERT_STREQ(p[0].getLabel(),
"widget label");
283 ASSERT_EQ(p[0].getState(),
IPS_OK);
285 ASSERT_STREQ(p.getDeviceName(),
"property device");
286 ASSERT_STREQ(p.getName(),
"property name");
287 ASSERT_STREQ(p.getLabel(),
"property label");
288 ASSERT_STREQ(p.getGroupName(),
"property group");
289 ASSERT_EQ(p.getPermission(),
IP_RW);
290 ASSERT_EQ(p.getTimeout(), 1000);
291 ASSERT_EQ(p.getState(),
IPS_OK);
294 p[0].setName(
"widget other name");
295 p[0].setLabel(
"widget other label");
298 p.setDeviceName(
"property other device");
299 p.setName(
"property other name");
300 p.setLabel(
"property other label");
301 p.setGroupName(
"property other group");
302 p.setPermission(
IP_RO);
306 ASSERT_STREQ(p[0].getName(),
"widget other name");
307 ASSERT_STREQ(p[0].getLabel(),
"widget other label");
308 ASSERT_EQ(p[0].getState(),
ISS_OFF);
310 ASSERT_STREQ(p.getDeviceName(),
"property other device");
311 ASSERT_STREQ(p.getName(),
"property other name");
312 ASSERT_STREQ(p.getLabel(),
"property other label");
313 ASSERT_STREQ(p.getGroupName(),
"property other group");
314 ASSERT_EQ(p.getPermission(),
IP_RO);
315 ASSERT_EQ(p.getTimeout(), 500);
325 TEST(CORE_PROPERTY_CLASS, Test_PropertyText)
330 p[0].setLabel(
"widget label");
331 p[0].setText(
"widget text");
333 p.setDeviceName(
"property device");
334 p.setName(
"property name");
335 p.setLabel(
"property label");
336 p.setGroupName(
"property group");
337 p.setPermission(
IP_RW);
341 ASSERT_STREQ(p[0].getName(),
"widget name");
342 ASSERT_STREQ(p[0].getLabel(),
"widget label");
343 ASSERT_STREQ(p[0].getText(),
"widget text");
345 ASSERT_STREQ(p.getDeviceName(),
"property device");
346 ASSERT_STREQ(p.getName(),
"property name");
347 ASSERT_STREQ(p.getLabel(),
"property label");
348 ASSERT_STREQ(p.getGroupName(),
"property group");
349 ASSERT_EQ(p.getPermission(),
IP_RW);
350 ASSERT_EQ(p.getTimeout(), 1000);
351 ASSERT_EQ(p.getState(),
IPS_OK);
354 p[0].setName(
"widget other name");
355 p[0].setLabel(
"widget other label");
356 p[0].setText(
"widget other text");
358 p.setDeviceName(
"property other device");
359 p.setName(
"property other name");
360 p.setLabel(
"property other label");
361 p.setGroupName(
"property other group");
362 p.setPermission(
IP_RO);
366 ASSERT_STREQ(p[0].getName(),
"widget other name");
367 ASSERT_STREQ(p[0].getLabel(),
"widget other label");
368 ASSERT_STREQ(p[0].getText(),
"widget other text");
370 ASSERT_STREQ(p.getDeviceName(),
"property other device");
371 ASSERT_STREQ(p.getName(),
"property other name");
372 ASSERT_STREQ(p.getLabel(),
"property other label");
373 ASSERT_STREQ(p.getGroupName(),
"property other group");
374 ASSERT_EQ(p.getPermission(),
IP_RO);
375 ASSERT_EQ(p.getTimeout(), 500);
385 TEST(CORE_PROPERTY_CLASS, Test_PropertyLight)
390 p[0].setLabel(
"widget label");
393 p.setDeviceName(
"property device");
394 p.setName(
"property name");
395 p.setLabel(
"property label");
396 p.setGroupName(
"property group");
397 p.setPermission(
IP_RW);
401 ASSERT_STREQ(p[0].getName(),
"widget name");
402 ASSERT_STREQ(p[0].getLabel(),
"widget label");
403 ASSERT_EQ(p[0].getState(),
IPS_OK);
405 ASSERT_STREQ(p.getDeviceName(),
"property device");
406 ASSERT_STREQ(p.getName(),
"property name");
407 ASSERT_STREQ(p.getLabel(),
"property label");
408 ASSERT_STREQ(p.getGroupName(),
"property group");
409 ASSERT_EQ(p.getPermission(),
IP_RO);
410 ASSERT_EQ(p.getTimeout(), 0);
411 ASSERT_EQ(p.getState(),
IPS_OK);
414 p[0].setName(
"widget other name");
415 p[0].setLabel(
"widget other label");
418 p.setDeviceName(
"property other device");
419 p.setName(
"property other name");
420 p.setLabel(
"property other label");
421 p.setGroupName(
"property other group");
422 p.setPermission(
IP_RO);
426 ASSERT_STREQ(p[0].getName(),
"widget other name");
427 ASSERT_STREQ(p[0].getLabel(),
"widget other label");
428 ASSERT_EQ(p[0].getState(),
IPS_OK);
430 ASSERT_STREQ(p.getDeviceName(),
"property other device");
431 ASSERT_STREQ(p.getName(),
"property other name");
432 ASSERT_STREQ(p.getLabel(),
"property other label");
433 ASSERT_STREQ(p.getGroupName(),
"property other group");
434 ASSERT_EQ(p.getPermission(),
IP_RO);
435 ASSERT_EQ(p.getTimeout(), 0);
445 TEST(CORE_PROPERTY_CLASS, Test_PropertyBlob)
450 p[0].setLabel(
"widget label");
451 p[0].setBlob(
nullptr);
454 p[0].setFormat(
"format");
456 p.setDeviceName(
"property device");
457 p.setName(
"property name");
458 p.setLabel(
"property label");
459 p.setGroupName(
"property group");
460 p.setPermission(
IP_RW);
464 ASSERT_STREQ(p[0].getName(),
"widget name");
465 ASSERT_STREQ(p[0].getLabel(),
"widget label");
466 ASSERT_EQ(p[0].getBlob(),
nullptr);
467 ASSERT_EQ(p[0].getBlobLen(), 8);
468 ASSERT_EQ(p[0].getSize(), 16);
469 ASSERT_STREQ(p[0].getFormat(),
"format");
471 ASSERT_STREQ(p.getDeviceName(),
"property device");
472 ASSERT_STREQ(p.getName(),
"property name");
473 ASSERT_STREQ(p.getLabel(),
"property label");
474 ASSERT_STREQ(p.getGroupName(),
"property group");
475 ASSERT_EQ(p.getPermission(),
IP_RW);
476 ASSERT_EQ(p.getTimeout(), 1000);
477 ASSERT_EQ(p.getState(),
IPS_OK);
480 p[0].setName(
"widget other name");
481 p[0].setLabel(
"widget other label");
482 p[0].setBlob(
reinterpret_cast<void*
>(0x10));
485 p[0].setFormat(
"format 2");
487 p.setDeviceName(
"property other device");
488 p.setName(
"property other name");
489 p.setLabel(
"property other label");
490 p.setGroupName(
"property other group");
491 p.setPermission(
IP_RO);
495 ASSERT_STREQ(p[0].getName(),
"widget other name");
496 ASSERT_STREQ(p[0].getLabel(),
"widget other label");
497 ASSERT_EQ(p[0].getBlob(),
reinterpret_cast<void*
>(0x10));
498 ASSERT_EQ(p[0].getBlobLen(), 16);
499 ASSERT_EQ(p[0].getSize(), 32);
500 ASSERT_STREQ(p[0].getFormat(),
"format 2");
502 ASSERT_STREQ(p.getDeviceName(),
"property other device");
503 ASSERT_STREQ(p.getName(),
"property other name");
504 ASSERT_STREQ(p.getLabel(),
"property other label");
505 ASSERT_STREQ(p.getGroupName(),
"property other group");
506 ASSERT_EQ(p.getPermission(),
IP_RO);
507 ASSERT_EQ(p.getTimeout(), 500);
Class to provide basic INDI device functionality.
void setName(const char *name)
Provides generic container for INDI properties.
INDI::PropertyViewSwitch * getSwitch() const
const char * getGroupName() const
INDI::PropertyViewBlob * getBLOB() const
INDI::PropertyViewText * getText() const
const char * getDeviceName() const
INDI::PropertyViewNumber * getNumber() const
const char * getName() const
INDI::PropertyViewLight * getLight() const
IPerm getPermission() const
void setType(INDI_PROPERTY_TYPE t)
void * getProperty() const
BaseDevice getBaseDevice() const
const char * getLabel() const
void setBaseDevice(BaseDevice *idp)
bool getRegistered() const
INDI_PROPERTY_TYPE getType() const
const char * getTimestamp() const
Provides decorator for Low-Level IXXXVectorProperty/IXXX.
void setTimestamp(const char *timestamp)
void setDeviceName(const char *name)
void setName(const char *name)
void setTimeout(double timeout)
void setPermission(IPerm permission)
void setState(IPState state)
void setGroupName(const char *name)
void setLabel(const char *label)
void setWidgets(WidgetType *w, size_t count)
Number vector property descriptor.
TEST(CORE_PROPERTY_CLASS, Test_EmptyProperty)