I am testing a few processes I have created in my application via DUnit (http://docwiki.embarcadero.com/RADStudi ... t_Overview).
The following is the skeleton of the source of the project I want to test:
Code: Select all
unit MyUnit;
interface
{$I cef.inc}
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
uCEFWindowParent,
uCEFChromiumWindow,
uCEFChromium,
Vcl.ExtCtrls,
Vcl.StdCtrls;
type
TForm1 = class(TForm)
ChromiumWindow1: TChromiumWindow;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ChromiumWindow1AfterCreated(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
procedure WMMove(var aMessage: TWMMove); message WM_MOVE;
procedure WMMoving(var aMessage: TMessage); message WM_MOVING;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ChromiumWindow1AfterCreated(Sender: TObject);
begin
ChromiumWindow1.LoadURL('https://www.google.com');
end;
procedure TForm1.FormShow(Sender: TObject);
begin
if not (ChromiumWindow1.CreateBrowser) then
Timer1.Enabled := True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not (ChromiumWindow1.CreateBrowser) and not (ChromiumWindow1.Initialized) then
Timer1.Enabled := True
end;
procedure TForm1.WMMove(var aMessage: TWMMove);
begin
inherited;
if (ChromiumWindow1 <> nil) then
ChromiumWindow1.NotifyMoveOrResizeStarted;
end;
procedure TForm1.WMMoving(var aMessage: TMessage);
begin
inherited;
if (ChromiumWindow1 <> nil) then
ChromiumWindow1.NotifyMoveOrResizeStarted;
end;
end.
Code: Select all
unit myTest;
interface
uses
TestFramework,
System.SysUtils,
Vcl.Graphics,
uCEFChromium,
Winapi.Windows,
System.Variants,
uCEFChromiumWindow,
Vcl.Dialogs,
Vcl.Controls,
uCEFWindowParent,
Vcl.Forms,
Winapi.Messages,
System.Classes;
type
// Test methods for class TForm1
TestTForm1 = class(TTestCase)
strict private
FForm1: TForm1;
public
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestFormA;
end;
implementation
procedure TestTForm1.SetUp;
begin
Form1 := TForm1.Create(nil);
end;
procedure TestTForm1.TearDown;
begin
FForm1.Free;
FForm1 := nil;
end;
procedure TestTForm1.TestFormA;
begin
FForm1.ShowModal;//Chromium shows correctly but because the form is modal the application does not perform the tests
FForm1.Show;//The application seems to freeze
{test to be performed are placed here}
end;
initialization
// Register any test cases with the test runner
RegisterTest(TestTForm1.Suite);
end.
Why isn't the page loaded with .Show ? How can perform my test ?
Many thanks
Alberto