| 50 | } |
| 51 | |
| 52 | TEST(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 |
nothing calls this directly
no test coverage detected