mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 12:39:24 +02:00
* Added test for TDataset.EnableControls
* Adapted test for CalculateFields for fix of bug #11027 git-svn-id: trunk@10523 -
This commit is contained in:
parent
62e66d2a56
commit
d7e393f2c3
@ -33,6 +33,7 @@ type
|
|||||||
procedure TestCalcFirstRecord1;
|
procedure TestCalcFirstRecord1;
|
||||||
procedure TestRefreshLookupList;
|
procedure TestRefreshLookupList;
|
||||||
procedure TestCalculateFields;
|
procedure TestCalculateFields;
|
||||||
|
procedure TestEnableControls;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -571,7 +572,7 @@ var ds, lkpDs : TDataset;
|
|||||||
StoreValue : Variant;
|
StoreValue : Variant;
|
||||||
Buffer: pchar;
|
Buffer: pchar;
|
||||||
begin
|
begin
|
||||||
ds := DBConnector.GetTraceDataset(False);
|
ds := DBConnector.GetTraceDataset(True);
|
||||||
lkpDs := DBConnector.GetNDataset(5);
|
lkpDs := DBConnector.GetNDataset(5);
|
||||||
with ds do
|
with ds do
|
||||||
begin
|
begin
|
||||||
@ -618,14 +619,77 @@ begin
|
|||||||
THackDataset(ds).SetUniDirectional(False);
|
THackDataset(ds).SetUniDirectional(False);
|
||||||
|
|
||||||
// Else, the value of all the lookup fields should get calculated
|
// Else, the value of all the lookup fields should get calculated
|
||||||
|
edit;
|
||||||
|
FieldByName('name').asstring := 'TestName3';
|
||||||
|
post;
|
||||||
DataEvents:='';
|
DataEvents:='';
|
||||||
THackDataset(ds).CalculateFields(Buffer);
|
THackDataset(ds).CalculateFields(Buffer);
|
||||||
AssertEquals('CalculateFields;ClearCalcFields;DatasetNotifyEvent;',DataEvents);
|
AssertEquals('CalculateFields;ClearCalcFields;DatasetNotifyEvent;',DataEvents);
|
||||||
// This assertion fails because of bug 11027
|
AssertEquals('3',VarToStr(AFld3.Value));
|
||||||
//AssertEquals('1',VarToStr(StoreValue));
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestDatasources.TestEnableControls;
|
||||||
|
var ds: TDataset;
|
||||||
|
ADataLink : TTestDataLink;
|
||||||
|
ADataSource : TDataSource;
|
||||||
|
begin
|
||||||
|
ds := DBConnector.GetTraceDataset(False);
|
||||||
|
ADatasource := TDataSource.Create(nil);
|
||||||
|
ADatalink := TTestDataLink.Create;
|
||||||
|
ADatalink.DataSource := aDatasource;
|
||||||
|
ADataSource.DataSet := ds;
|
||||||
|
with ds do
|
||||||
|
begin
|
||||||
|
Open;
|
||||||
|
|
||||||
|
// If DisableControls isn't called, nothing should happen.
|
||||||
|
DataEvents:='';
|
||||||
|
EnableControls;
|
||||||
|
AssertEquals('',DataEvents);
|
||||||
|
|
||||||
|
DisableControls;
|
||||||
|
DisableControls;
|
||||||
|
// DisableControls is called twice. Ie: first call to enablecontrols should
|
||||||
|
// still do nothing.
|
||||||
|
DataEvents:='';
|
||||||
|
EnableControls;
|
||||||
|
AssertEquals('',DataEvents);
|
||||||
|
|
||||||
|
// On this call to Enablecontrols, the controls should get enabled again:
|
||||||
|
DataEvents:='';
|
||||||
|
EnableControls;
|
||||||
|
AssertEquals('SetCurrentRecord;deDataSetChange:0;',DataEvents);
|
||||||
|
|
||||||
|
// If the state of the dataset has been changed while the controls were
|
||||||
|
// disabled, then an deUpdateState event should be raised
|
||||||
|
DisableControls;
|
||||||
|
THackDataset(ds).SetState(dsSetKey);
|
||||||
|
DataEvents:='';
|
||||||
|
EnableControls;
|
||||||
|
AssertEquals('deUpdateState:0;SetCurrentRecord;deDataSetChange:0;',DataEvents);
|
||||||
|
THackDataset(ds).SetState(dsBrowse);
|
||||||
|
|
||||||
|
// If the dataset is closed while the controls were disabled, then only
|
||||||
|
// an deUpdateState event should occur.
|
||||||
|
DisableControls;
|
||||||
|
Close;
|
||||||
|
DataEvents:='';
|
||||||
|
EnableControls;
|
||||||
|
AssertEquals('deUpdateState:0;',DataEvents);
|
||||||
|
|
||||||
|
// And the same happens if the dataset was opened
|
||||||
|
DisableControls;
|
||||||
|
Open;
|
||||||
|
DataEvents:='';
|
||||||
|
EnableControls;
|
||||||
|
AssertEquals('deUpdateState:0;',DataEvents);
|
||||||
|
close;
|
||||||
|
end;
|
||||||
|
ADataLink.Free;
|
||||||
|
ADataSource.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
if uppercase(dbconnectorname)='DBF' then RegisterTest(TTestDatasources);
|
if uppercase(dbconnectorname)='DBF' then RegisterTest(TTestDatasources);
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user