MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / TEST

Function TEST

Engine/source/console/test/runtimeClassRepTest.cpp:52–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52TEST(Console, RuntimeClassRep)
53{
54 // First test to make sure that the test class is not registered (don't
55 // know how it could be, but that's programming for you). Stop the test if
56 // it is.
57 ASSERT_TRUE(!RuntimeRegisteredSimObject::dynRTClassRep.isRegistered())
58 << "RuntimeRegisteredSimObject class was already registered with the console";
59
60 // This should not be able to find the class, and return null (this may
61 // AssertWarn as well).
62 ConsoleObject *conobj = ConsoleObject::create("RuntimeRegisteredSimObject");
63 EXPECT_TRUE(conobj == NULL)
64 << "Unregistered AbstractClassRep returned non-NULL value! That is really bad!";
65
66 // Register with console system.
67 RuntimeRegisteredSimObject::dynRTClassRep.consoleRegister();
68
69 // Make sure that the object knows it's registered.
70 EXPECT_TRUE(RuntimeRegisteredSimObject::dynRTClassRep.isRegistered())
71 << "RuntimeRegisteredSimObject class failed console registration";
72
73 // Now try again to create the instance.
74 conobj = ConsoleObject::create("RuntimeRegisteredSimObject");
75 EXPECT_TRUE(conobj != NULL)
76 << "AbstractClassRep::create method failed!";
77
78 // Cast the instance, and test it.
79 RuntimeRegisteredSimObject *rtinst =
80 dynamic_cast<RuntimeRegisteredSimObject *>(conobj);
81 EXPECT_TRUE(rtinst != NULL)
82 << "Casting failed for some reason";
83
84 // Register it with a name.
85 rtinst->registerObject("_utRRTestObject");
86 EXPECT_TRUE(rtinst->isProperlyAdded())
87 << "registerObject failed on test object";
88
89 // Now execute some script on it.
90 Con::evaluate("_utRRTestObject.fooField = true;");
91
92 // Test to make sure field worked.
93 EXPECT_TRUE(dAtob(rtinst->getDataField(StringTable->insert("fooField"), NULL)))
94 << "Set property failed on instance.";
95
96 // BALETED
97 rtinst->deleteObject();
98
99 // Unregister the type.
100 RuntimeRegisteredSimObject::dynRTClassRep.consoleUnRegister();
101
102 // And make sure we can't create another one.
103 conobj = ConsoleObject::create("RuntimeRegisteredSimObject");
104 EXPECT_TRUE(conobj == NULL)
105 << "Unregistration of type failed";
106}
107
108#endif

Callers

nothing calls this directly

Calls 10

evaluateFunction · 0.85
consoleRegisterMethod · 0.80
isProperlyAddedMethod · 0.80
getDataFieldMethod · 0.80
consoleUnRegisterMethod · 0.80
dAtobFunction · 0.50
isRegisteredMethod · 0.45
registerObjectMethod · 0.45
insertMethod · 0.45
deleteObjectMethod · 0.45

Tested by

no test coverage detected