1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#include "TestCases.hxx"
#include "ProcFeatSeveralControls.hxx"
#include "ProcessingController.hxx"
#include "FakeCompositeControlWidget.hxx"
#include <Assert.hxx>
namespace CLAMDraft
{
using CLAMVM::ProcessingController;
void TestBindingProcessingAdapter()
{
ProcFeatSeveralControls proc;
ProcFeatSeveralControlsConfig procCfg;
ProcessingController modCont;
proc.Configure( procCfg );
CLAM_ASSERT( modCont.BindTo( proc ), "Binding has failed!");
}
void TestAttachPresentationAdapter( )
{
ProcFeatSeveralControls proc;
ProcFeatSeveralControlsConfig procCfg;
ProcessingController modCont;
FakeCompositeControlWidget compoWidget;
proc.Configure( procCfg );
modCont.BindTo( proc );
compoWidget.AttachTo( modCont );
}
bool AssertTimesCalled( ProcFeatSeveralControls& stubProc, int expectedTimes )
{
if ( stubProc.GetControlTimesCalled( 0 ) != expectedTimes ) return false;
if ( stubProc.GetControlTimesCalled( 1 ) != expectedTimes ) return false;
if ( stubProc.GetControlTimesCalled( 2 ) != expectedTimes ) return false;
if ( stubProc.GetControlTimesCalled( 3 ) != expectedTimes ) return false;
if ( stubProc.GetControlTimesCalled( 4 ) != expectedTimes ) return false;
if ( stubProc.GetControlTimesCalled( 5 ) != expectedTimes ) return false;
return true;
}
bool AssertValuesReceived( ProcFeatSeveralControls& stubProc,
std::vector<float>& values )
{
if ( stubProc.GetControlLastValue( 0 ) != values[0] ) return false;
if ( stubProc.GetControlLastValue( 1 ) != values[1] ) return false;
if ( stubProc.GetControlLastValue( 2 ) != values[2] ) return false;
if ( stubProc.GetControlLastValue( 3 ) != values[3] ) return false;
if ( stubProc.GetControlLastValue( 4 ) != values[4] ) return false;
if ( stubProc.GetControlLastValue( 5 ) != values[5] ) return false;
return true;
}
void TestControlUpdating()
{
ProcFeatSeveralControls proc;
ProcFeatSeveralControlsConfig procCfg;
ProcessingController modCont;
FakeCompositeControlWidget compoWidget;
modCont.BindTo( proc );
compoWidget.AttachTo( modCont );
std::vector<float> values;
values.resize( 6 );
values[0] = 33.0f;
values[1] = 21.0f;
values[2] = 15.0f;
values[3] = 100.0f;
values[4] = 1000.0f;
values[5] = 10000.0f;
compoWidget.SendTheseValues( values );
modCont.Update();
CLAM_ASSERT( AssertTimesCalled( proc, 1 ), "Times called mismatch!" );
CLAM_ASSERT( AssertValuesReceived( proc, values ), "Values received mismatch!" );
}
void TestSeveralControlsUpdating()
{
ProcFeatSeveralControls proc;
ProcFeatSeveralControlsConfig procCfg;
ProcessingController modCont;
FakeCompositeControlWidget compoWidget;
modCont.BindTo( proc );
compoWidget.AttachTo( modCont );
std::vector<float> values;
values.resize( 6 );
values[0] = 33.0f;
values[1] = 21.0f;
values[2] = 15.0f;
values[3] = 100.0f;
values[4] = 1000.0f;
values[5] = 10000.0f;
for ( int i = 0; i < 11; i++ )
{
values[0]+=i;
values[1]+=i;
values[2]+=i;
values[3]+=i;
values[4]+=i;
values[5]+=i;
compoWidget.SendTheseValues( values );
modCont.Update();
}
CLAM_ASSERT( AssertTimesCalled( proc, 11 ), "Times called mismatch!" );
CLAM_ASSERT( AssertValuesReceived( proc, values ), "Values received mismatch!" );
}
}
|