30 #include <gtest/gtest.h> 32 #include <QApplication> 52 std::stringstream input(
"Name: sample\n" 56 "Offset: {X: -1, Y: 1.1, Z: 1.1e3}\n" 58 "Style: loosey goosey\n");
68 EXPECT_EQ(
"loosey goosey", d.
style_->
getValue().toString().toStdString());
71 EXPECT_EQ(-1.
f, offset.x);
72 EXPECT_EQ(1.1
f, offset.y);
73 EXPECT_EQ(1100.
f, offset.z);
74 EXPECT_EQ(
"255; 255; 255", d.
color_->
getValue().toString().toStdString());
75 EXPECT_EQ(
true, d.
getValue().toBool());
80 std::stringstream input(
"Name: root\n" 84 " Class: MockDisplay\n" 90 " Class: DisplayGroup\n" 94 " Class: MockDisplay\n" 99 " Class: BrokenDisplay\n" 111 EXPECT_EQ(
true, g.
getValue().toBool());
115 EXPECT_EQ(
"The class required for this display, 'BrokenDisplay', could not be loaded.",
132 EXPECT_EQ(std::string(
"Class: \"\"\n" 138 "Offset: {X: 1, Y: 2, Z: 3}\n" 139 "Color: 10; 20; 30"),
140 out.toStdString().c_str());
165 EXPECT_EQ(std::string(
"Class: \"\"\n" 175 " Offset: {X: 1, Y: 2, Z: 3}\n" 176 " Color: 10; 20; 30\n" 183 " Offset: {X: 1, Y: 2, Z: 3}\n" 184 " Color: 10; 20; 30"),
185 out.toStdString().c_str());
190 std::stringstream input(
"Displays:\n" 192 " Class: MockDisplay\n");
207 std::stringstream input(
"Displays:\n" 208 " - Class: MissingDisplay\n" 211 " LemurStyle: chunky\n" 233 QString out = writer.writeString(config);
234 EXPECT_EQ(std::string(
"Class: \"\"\n" 238 " - Class: MissingDisplay\n" 239 " LemurStyle: chunky\n" 246 out.toStdString().c_str());
249 int main(
int argc,
char** argv)
252 QApplication
app(argc, argv);
253 testing::InitGoogleTest(&argc, argv);
254 return RUN_ALL_TESTS();
TEST(Display, load_properties)
int numChildren() const override
Return the number of child objects (Property and Display).
void load(const Config &config) override
Load subproperties and the list of displays in this group from the given Config node, which must be a map.
virtual bool setValue(const QVariant &new_value)
Set the new value for this property. Returns true if the new value is different from the old value...
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
QString writeString(const Config &config, const QString &filename="data string")
Write config data to a string, and return it. This potentially changes the return values of error() a...
void readStream(Config &config, std::istream &in, const QString &filename="data stream")
Read config data from a std::istream. This potentially changes the return value sof error()...
void load(const Config &config) override
Load the settings for this display from the given Config node, which must be a map.
virtual Ogre::Vector3 getVector() const
int main(int argc, char **argv)
virtual QString getDescription() const
Return the description.
Configuration data storage class.
virtual Property * subProp(const QString &sub_name)
Return the first child Property with the given name, or the FailureProperty if no child has the name...
void addChild(Property *child, int index=-1) override
Add a child Property or Display.
A Display object which stores other Displays as children.
virtual Display * getDisplayAt(int index) const
Return the index-th Display in this group, or NULL if the index is invalid.
virtual int numChildren() const
Return the number of child objects (Property or otherwise).
void save(Config config) const override
Write this display to the given Config node.
void setName(const QString &name) override
Overridden from Property to set associated widget title to the new name.
virtual QVariant getValue() const
Return the value of this Property as a QVariant. If the value has never been set, an invalid QVariant...
virtual QString getClassId() const
Return the class identifier which was used to create this instance. This version just returns whateve...
void save(Config config) const override
Save subproperties and the list of displays in this group to the given Config node.