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(
85 " Class: MockDisplay\n" 91 " Class: DisplayGroup\n" 95 " Class: MockDisplay\n" 100 " Class: BrokenDisplay\n" 113 EXPECT_EQ(
true, g.
getValue().toBool() );
117 EXPECT_EQ(
"The class required for this display, 'BrokenDisplay', could not be loaded.",
134 EXPECT_EQ( std::string(
141 "Offset: {X: 1, Y: 2, Z: 3}\n" 144 , out.toStdString().c_str() );
169 EXPECT_EQ( std::string(
180 " Offset: {X: 1, Y: 2, Z: 3}\n" 181 " Color: 10; 20; 30\n" 188 " Offset: {X: 1, Y: 2, Z: 3}\n" 191 , out.toStdString().c_str() );
196 std::stringstream input(
199 " Class: MockDisplay\n" 215 std::stringstream input(
217 " - Class: MissingDisplay\n" 220 " LemurStyle: chunky\n" 243 QString out = writer.writeString(config);
244 EXPECT_EQ( std::string(
249 " - Class: MissingDisplay\n" 250 " LemurStyle: chunky\n" 258 , out.toStdString().c_str() );
261 int main(
int argc,
char **argv ) {
263 QApplication
app(argc, argv);
264 testing::InitGoogleTest( &argc, argv );
265 return RUN_ALL_TESTS();
virtual void save(Config config) const
Save subproperties and the list of displays in this group to the given Config node.
TEST(Display, load_properties)
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...
virtual void load(const Config &config)
Load subproperties and the list of displays in this group from the given Config node, which must be a map.
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()...
int main(int argc, char **argv)
virtual int numChildren() const
Return the number of child objects (Property or otherwise).
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...
virtual int numChildren() const
Return the number of child objects (Property and Display).
virtual QString getClassId() const
Return the class identifier which was used to create this instance. This version just returns whateve...
A Display object which stores other Displays as children.
virtual void save(Config config) const
Write this display to the given Config node.
virtual Display * getDisplayAt(int index) const
Return the index-th Display in this group, or NULL if the index is invalid.
virtual Ogre::Vector3 getVector() const
virtual void load(const Config &config)
Load the settings for this display from the given Config node, which must be a map.
void setName(const QString &name)
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 getDescription() const
Return the description.
virtual void addChild(Property *child, int index=-1)
Add a child Property or Display.