//==========================================================================// // File: gauge.tst // // Project: MUNGA Brick: Gauge module // // Contents: Test code for gauge classes // //--------------------------------------------------------------------------// // Date Who Modification // // -------- --- ----------------------------------------------------------// // 02/10/95 CPB Initial coding. // //--------------------------------------------------------------------------// // Copyright (C) 1995, Virtual World Entertainment, Inc. // // All Rights reserved worldwide // // This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL // //==========================================================================// class FakeGauge : public Gauge { public: FakeGauge(GaugeRenderer *renderer, unsigned int owner_ID); ~FakeGauge(); void Execute(); Scalar myScalar; }; FakeGauge::FakeGauge(GaugeRenderer *renderer, unsigned int owner_ID) : Gauge((GaugeRate) gaugeRate_A, (ModeMask) -1L, renderer, owner_ID) { myScalar = 0.0f; } FakeGauge::~FakeGauge() { } void FakeGauge::Execute() { myScalar = 2.0f; } // //########################################################################### //########################################################################### // Logical Gauge::TestClass() { #if 0 Tell("Starting Gauge test...\n"); unsigned int fakeOwnerID(1); // //-------------------------------------------------------- // Test GaugeConnectionDirectOf... //-------------------------------------------------------- // { Scalar scalar1(0.0); Scalar scalar2(1.5f); // // Create a GaugeConnection // GaugeConnectionDirectOf *instance1; instance1 = new GaugeConnectionDirectOf(0, &scalar2, &scalar1); Check(instance1); Register_Object(instance1); // // Try it out // instance1->Update(); Test(scalar2 == 0.0f); // // Destroy it // Unregister_Object(instance1); delete instance1; } // //-------------------------------------------------------- // Test Gauge //-------------------------------------------------------- // { Scalar source(1.5f); // // Create a gauge // FakeGauge testGauge(NULL, fakeOwnerID); Check(&testGauge); Register_Object(&testGauge); // // Create a connection and add it to the gauge // GaugeConnectionDirectOf *instance1; instance1 = new GaugeConnectionDirectOf( 0, &testGauge.myScalar, &source ); Check(instance1); Register_Object(instance1); testGauge.AddConnection(instance1); #if 0 // // See if the connection works // Test(testGauge.myScalar == 0.0f); testGauge.UpdateParameters(); Test(testGauge.myScalar == 1.5f); // // See if Execute() occurs // testGauge.Execute(); Test(testGauge.myScalar == 2.0f); // // Remove the connection, and ensure that the value doesn't change // testGauge.RemoveConnection(0); source = 3.0f; testGauge.UpdateParameters(); Test(testGauge.myScalar == 2.0f); #endif // // Everything seems ok! Unregister the gauge and delete it // Note that RemoveConnection should have deleted the GaugeConnection. // If it didn't, we'll hear about it when we check the // remaining registered objects. // Unregister_Object(&testGauge); } // //-------------------------------------------------------- // Return test result //-------------------------------------------------------- // #endif return True; }