18#include <gtest/gtest.h>
38TEST(CORE_PROPERTY_CLASS, Test_EmptyProperty)
48 ASSERT_EQ(p.
getName(),
nullptr);
58 ASSERT_EQ(p.
getText(),
nullptr);
61 ASSERT_EQ(p.
getBLOB(),
nullptr);
64TEST(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);
159TEST(CORE_PROPERTY_CLASS, DISABLED_Test_Integrity)
188 EXPECT_EQ(p.
getText(),
nullptr);
191 EXPECT_EQ(p.
getBLOB(),
nullptr);
199TEST(CORE_PROPERTY_CLASS, Test_PropertyNumber)
206 p[0].setMinMax(-10, 10);
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);
223 ASSERT_STREQ(p.
getName(),
"property name");
224 ASSERT_STREQ(p.
getLabel(),
"property label");
231 p[0].
setName(
"widget other name");
232 p[0].
setLabel(
"widget other label");
234 p[0].setMinMax(-100, 100);
237 p.
setName(
"property other name");
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);
251 ASSERT_STREQ(p.
getName(),
"property other name");
252 ASSERT_STREQ(p.
getLabel(),
"property other label");
265TEST(CORE_PROPERTY_CLASS, Test_PropertySwitch)
281 ASSERT_STREQ(p[0].getName(),
"widget name");
282 ASSERT_STREQ(p[0].getLabel(),
"widget label");
283 ASSERT_EQ(p[0].getState(),
ISS_ON);
286 ASSERT_STREQ(p.
getName(),
"property name");
287 ASSERT_STREQ(p.
getLabel(),
"property label");
294 p[0].
setName(
"widget other name");
295 p[0].
setLabel(
"widget other label");
299 p.
setName(
"property other name");
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);
311 ASSERT_STREQ(p.
getName(),
"property other name");
312 ASSERT_STREQ(p.
getLabel(),
"property other label");
325TEST(CORE_PROPERTY_CLASS, Test_PropertyText)
331 p[0].setText(
"widget text");
341 ASSERT_STREQ(p[0].getName(),
"widget name");
342 ASSERT_STREQ(p[0].getLabel(),
"widget label");
343 ASSERT_STREQ(p[0].getText(),
"widget text");
346 ASSERT_STREQ(p.
getName(),
"property name");
347 ASSERT_STREQ(p.
getLabel(),
"property label");
354 p[0].
setName(
"widget other name");
355 p[0].
setLabel(
"widget other label");
356 p[0].setText(
"widget other text");
359 p.
setName(
"property other name");
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");
371 ASSERT_STREQ(p.
getName(),
"property other name");
372 ASSERT_STREQ(p.
getLabel(),
"property other label");
385TEST(CORE_PROPERTY_CLASS, Test_PropertyLight)
401 ASSERT_STREQ(p[0].getName(),
"widget name");
402 ASSERT_STREQ(p[0].getLabel(),
"widget label");
403 ASSERT_EQ(p[0].getState(),
IPS_OK);
406 ASSERT_STREQ(p.
getName(),
"property name");
407 ASSERT_STREQ(p.
getLabel(),
"property label");
414 p[0].
setName(
"widget other name");
415 p[0].
setLabel(
"widget other label");
419 p.
setName(
"property other name");
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);
431 ASSERT_STREQ(p.
getName(),
"property other name");
432 ASSERT_STREQ(p.
getLabel(),
"property other label");
445TEST(CORE_PROPERTY_CLASS, Test_PropertyBlob)
451 p[0].setBlob(
nullptr);
454 p[0].setFormat(
"format");
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");
472 ASSERT_STREQ(p.
getName(),
"property name");
473 ASSERT_STREQ(p.
getLabel(),
"property label");
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");
488 p.
setName(
"property other name");
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");
503 ASSERT_STREQ(p.
getName(),
"property other name");
504 ASSERT_STREQ(p.
getLabel(),
"property other label");
Class to provide basic INDI device functionality.
void setDeviceName(const char *name)
void setState(IPState state)
const char * getDeviceName() const
void setName(const char *name)
double getTimeout() const
void setLabel(const char *label)
const char * getName() const
const char * getGroupName() const
const char * getLabel() const
void setPermission(IPerm permission)
void setGroupName(const char *name)
void setTimeout(double timeout)
IPerm getPermission() const
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
struct _INumberVectorProperty INumberVectorProperty
PropertyView< INumber > PropertyViewNumber
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)
TEST(CORE_PROPERTY_CLASS, Test_EmptyProperty)