mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-06 04:57:12 +01:00
IDEIntf: rewrote TIDEMenuSection to handle changes in hidden sections, tests: added menuintf tests, IDE: clean up
git-svn-id: trunk@52918 -
This commit is contained in:
parent
8d39f093f0
commit
444a926616
File diff suppressed because it is too large
Load Diff
@ -2753,7 +2753,7 @@ var
|
|||||||
VisibleCnt: Integer;
|
VisibleCnt: Integer;
|
||||||
begin
|
begin
|
||||||
MessagesMenuRoot.MenuItem:=MsgCtrlPopupMenu.Items;
|
MessagesMenuRoot.MenuItem:=MsgCtrlPopupMenu.Items;
|
||||||
MessagesMenuRoot.BeginUpdate;
|
//MessagesMenuRoot.BeginUpdate;
|
||||||
try
|
try
|
||||||
HasText:=false;
|
HasText:=false;
|
||||||
HasFilename:=false;
|
HasFilename:=false;
|
||||||
@ -2891,7 +2891,7 @@ begin
|
|||||||
|
|
||||||
UpdateQuickFixes(Line);
|
UpdateQuickFixes(Line);
|
||||||
finally
|
finally
|
||||||
MessagesMenuRoot.EndUpdate;
|
//MessagesMenuRoot.EndUpdate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -7876,7 +7876,7 @@ var
|
|||||||
begin
|
begin
|
||||||
ToolCount:=ExternalUserTools.Count;
|
ToolCount:=ExternalUserTools.Count;
|
||||||
Section:=itmCustomTools;
|
Section:=itmCustomTools;
|
||||||
Section.BeginUpdate;
|
//Section.BeginUpdate;
|
||||||
try
|
try
|
||||||
// add enough menuitems
|
// add enough menuitems
|
||||||
while Section.Count-1<ToolCount do
|
while Section.Count-1<ToolCount do
|
||||||
@ -7897,7 +7897,7 @@ begin
|
|||||||
CurMenuItem.OnClick:=@mnuExternalUserToolClick;
|
CurMenuItem.OnClick:=@mnuExternalUserToolClick;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
Section.EndUpdate;
|
//Section.EndUpdate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -1748,7 +1748,7 @@ procedure TMainIDEBase.UpdateWindowMenu;
|
|||||||
Result := ASection.Items[Index]
|
Result := ASection.Items[Index]
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Result := RegisterIDEMenuCommand(ASection.GetPath,'Window'+IntToStr(Index)+ASection.Name,'');
|
Result := RegisterIDEMenuCommand(ASection,'Window'+IntToStr(Index)+ASection.Name,'');
|
||||||
Result.CreateMenuItem;
|
Result.CreateMenuItem;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1768,7 +1768,7 @@ var
|
|||||||
EdList: TStringList;
|
EdList: TStringList;
|
||||||
EditorCur: TSourceEditor;
|
EditorCur: TSourceEditor;
|
||||||
P: TIDEPackage;
|
P: TIDEPackage;
|
||||||
M: TIDEMenuSection;
|
aSection: TIDEMenuSection;
|
||||||
s: String;
|
s: String;
|
||||||
begin
|
begin
|
||||||
//DebugLn('TMainIDEBase.UpdateWindowMenu: enter');
|
//DebugLn('TMainIDEBase.UpdateWindowMenu: enter');
|
||||||
@ -1810,7 +1810,7 @@ begin
|
|||||||
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Name
|
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Name
|
||||||
else
|
else
|
||||||
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Caption;
|
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Caption;
|
||||||
CurMenuItem.MenuItem.Checked := WindowMenuActiveForm = TCustomForm(WindowsList[i]);
|
CurMenuItem.Checked := WindowMenuActiveForm = TCustomForm(WindowsList[i]);
|
||||||
CurMenuItem.OnClick:=@mnuWindowItemClick;
|
CurMenuItem.OnClick:=@mnuWindowItemClick;
|
||||||
// in the 'center' list
|
// in the 'center' list
|
||||||
CurMenuItem := GetMenuItem(i, itmCenterWindowLists);
|
CurMenuItem := GetMenuItem(i, itmCenterWindowLists);
|
||||||
@ -1824,8 +1824,8 @@ begin
|
|||||||
//create source page menuitems
|
//create source page menuitems
|
||||||
itmTabListProject.Visible := False;
|
itmTabListProject.Visible := False;
|
||||||
itmTabListOther.Visible := False;
|
itmTabListOther.Visible := False;
|
||||||
itmTabListProject.MenuItem.Checked := False;
|
itmTabListProject.Checked := False;
|
||||||
itmTabListOther.MenuItem.Checked := False;
|
itmTabListOther.Checked := False;
|
||||||
itmTabListPackage.Clear;
|
itmTabListPackage.Clear;
|
||||||
|
|
||||||
if SourceEditorManager.SourceEditorCount > 0 then begin
|
if SourceEditorManager.SourceEditorCount > 0 then begin
|
||||||
@ -1847,25 +1847,25 @@ begin
|
|||||||
j := PtrUInt(EdList.Objects[i]);
|
j := PtrUInt(EdList.Objects[i]);
|
||||||
EditorCur := SourceEditorManager.SourceEditors[j];
|
EditorCur := SourceEditorManager.SourceEditors[j];
|
||||||
if (EditorCur.GetProjectFile <> nil) and (EditorCur.GetProjectFile.IsPartOfProject) then begin
|
if (EditorCur.GetProjectFile <> nil) and (EditorCur.GetProjectFile.IsPartOfProject) then begin
|
||||||
M := itmTabListProject;
|
aSection := itmTabListProject;
|
||||||
CurMenuItem := GetMenuItem(ItemCountProject, M);
|
CurMenuItem := GetMenuItem(ItemCountProject, aSection);
|
||||||
inc(ItemCountProject);
|
inc(ItemCountProject);
|
||||||
end else begin
|
end else begin
|
||||||
SourceEditorManager.OnPackageForSourceEditor(P, EditorCur);
|
SourceEditorManager.OnPackageForSourceEditor(P, EditorCur);
|
||||||
if P <> nil then begin
|
if P <> nil then begin
|
||||||
s := Format(lisTabsFor, [p.Name]);
|
s := Format(lisTabsFor, [p.Name]);
|
||||||
if itmTabListPackage.FindByName(S) is TIDEMenuSection then
|
if itmTabListPackage.FindByName(S) is TIDEMenuSection then
|
||||||
M := TIDEMenuSection(itmTabListPackage.FindByName(S))
|
aSection := TIDEMenuSection(itmTabListPackage.FindByName(S))
|
||||||
else
|
else
|
||||||
M := RegisterIDESubMenu(itmTabListPackage, S, S);
|
aSection := RegisterIDESubMenu(itmTabListPackage, S, S);
|
||||||
CurMenuItem := GetMenuItem(M.Count, M);
|
CurMenuItem := GetMenuItem(aSection.Count, aSection);
|
||||||
end else begin
|
end else begin
|
||||||
M := itmTabListOther;
|
aSection := itmTabListOther;
|
||||||
CurMenuItem := GetMenuItem(ItemCountOther, M);
|
CurMenuItem := GetMenuItem(ItemCountOther, aSection);
|
||||||
inc(ItemCountOther);
|
inc(ItemCountOther);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
M.Visible := True;
|
aSection.Visible := True;
|
||||||
if EditorCur.SharedEditorCount > 1 then
|
if EditorCur.SharedEditorCount > 1 then
|
||||||
CurMenuItem.Caption := EditorCur.PageName + ' ('+TForm(EditorCur.Owner).Caption+')'
|
CurMenuItem.Caption := EditorCur.PageName + ' ('+TForm(EditorCur.Owner).Caption+')'
|
||||||
//CurMenuItem.Caption := EditorCur.PageName
|
//CurMenuItem.Caption := EditorCur.PageName
|
||||||
@ -1873,9 +1873,9 @@ begin
|
|||||||
else
|
else
|
||||||
CurMenuItem.Caption := EditorCur.PageName;
|
CurMenuItem.Caption := EditorCur.PageName;
|
||||||
if CurMenuItem.MenuItem <> nil then
|
if CurMenuItem.MenuItem <> nil then
|
||||||
CurMenuItem.MenuItem.Checked := SourceEditorManager.ActiveEditor = EditorCur;
|
CurMenuItem.Checked := SourceEditorManager.ActiveEditor = EditorCur;
|
||||||
if (SourceEditorManager.ActiveEditor = EditorCur) and (M.MenuItem <> nil) then
|
if (SourceEditorManager.ActiveEditor = EditorCur) and (aSection.MenuItem <> nil) then
|
||||||
M.MenuItem.Checked := true;
|
aSection.Checked := true;
|
||||||
CurMenuItem.OnClick := @mnuWindowSourceItemClick;
|
CurMenuItem.OnClick := @mnuWindowSourceItemClick;
|
||||||
CurMenuItem.Tag := j;
|
CurMenuItem.Tag := j;
|
||||||
end;
|
end;
|
||||||
@ -1884,8 +1884,8 @@ begin
|
|||||||
ClearMenuItem(ItemCountOther, itmTabListOther);
|
ClearMenuItem(ItemCountOther, itmTabListOther);
|
||||||
for i := 0 to itmTabListPackage.Count - 1 do begin
|
for i := 0 to itmTabListPackage.Count - 1 do begin
|
||||||
if itmTabListPackage.Items[i] is TIDEMenuSection then begin
|
if itmTabListPackage.Items[i] is TIDEMenuSection then begin
|
||||||
M := itmTabListPackage.Items[i] as TIDEMenuSection;
|
aSection := itmTabListPackage.Items[i] as TIDEMenuSection;
|
||||||
M.Caption := M.Caption + Format(' (%d)', [M.Count]);
|
aSection.Caption := aSection.Caption + Format(' (%d)', [aSection.Count]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
itmTabListProject.Caption := dlgEnvProject + Format(' (%d)', [itmTabListProject.Count]);
|
itmTabListProject.Caption := dlgEnvProject + Format(' (%d)', [itmTabListProject.Count]);
|
||||||
|
|||||||
@ -6523,7 +6523,7 @@ var
|
|||||||
begin
|
begin
|
||||||
PopM:=TPopupMenu(Sender);
|
PopM:=TPopupMenu(Sender);
|
||||||
SourceTabMenuRoot.MenuItem:=PopM.Items;
|
SourceTabMenuRoot.MenuItem:=PopM.Items;
|
||||||
SourceTabMenuRoot.BeginUpdate;
|
//SourceTabMenuRoot.BeginUpdate;
|
||||||
try
|
try
|
||||||
// Get the tab that was clicked
|
// Get the tab that was clicked
|
||||||
if PopM.PopupComponent is TPageControl then begin
|
if PopM.PopupComponent is TPageControl then begin
|
||||||
@ -6625,7 +6625,7 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
SourceTabMenuRoot.EndUpdate;
|
//SourceTabMenuRoot.EndUpdate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -6661,7 +6661,7 @@ begin
|
|||||||
IDECommandList.ExecuteUpdateEvents;
|
IDECommandList.ExecuteUpdateEvents;
|
||||||
|
|
||||||
SourceEditorMenuRoot.MenuItem:=SrcPopupMenu.Items;
|
SourceEditorMenuRoot.MenuItem:=SrcPopupMenu.Items;
|
||||||
SourceEditorMenuRoot.BeginUpdate;
|
//SourceEditorMenuRoot.BeginUpdate;
|
||||||
try
|
try
|
||||||
RemoveUserDefinedMenuItems;
|
RemoveUserDefinedMenuItems;
|
||||||
RemoveContextMenuItems;
|
RemoveContextMenuItems;
|
||||||
@ -6746,7 +6746,7 @@ begin
|
|||||||
Manager.OnPopupMenu(@AddContextPopupMenuItem);
|
Manager.OnPopupMenu(@AddContextPopupMenuItem);
|
||||||
SourceEditorMenuRoot.NotifySubSectionOnShow(Self);
|
SourceEditorMenuRoot.NotifySubSectionOnShow(Self);
|
||||||
finally
|
finally
|
||||||
SourceEditorMenuRoot.EndUpdate;
|
//SourceEditorMenuRoot.EndUpdate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -250,7 +250,7 @@ type
|
|||||||
procedure DisableI18NForLFMCheckBoxChange(Sender: TObject);
|
procedure DisableI18NForLFMCheckBoxChange(Sender: TObject);
|
||||||
procedure EditVirtualUnitMenuItemClick(Sender: TObject);
|
procedure EditVirtualUnitMenuItemClick(Sender: TObject);
|
||||||
procedure ExpandDirectoryMenuItemClick(Sender: TObject);
|
procedure ExpandDirectoryMenuItemClick(Sender: TObject);
|
||||||
procedure FilterEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure FilterEditKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
|
||||||
procedure FindInFilesMenuItemClick(Sender: TObject);
|
procedure FindInFilesMenuItemClick(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
@ -798,7 +798,7 @@ begin
|
|||||||
//debugln(['TPackageEditorForm.FilesPopupMenuPopup START ',ItemsPopupMenu.Items.Count]);
|
//debugln(['TPackageEditorForm.FilesPopupMenuPopup START ',ItemsPopupMenu.Items.Count]);
|
||||||
PackageEditorMenuFilesRoot.MenuItem:=ItemsPopupMenu.Items;
|
PackageEditorMenuFilesRoot.MenuItem:=ItemsPopupMenu.Items;
|
||||||
//debugln(['TPackageEditorForm.FilesPopupMenuPopup START after connect ',ItemsPopupMenu.Items.Count]);
|
//debugln(['TPackageEditorForm.FilesPopupMenuPopup START after connect ',ItemsPopupMenu.Items.Count]);
|
||||||
PackageEditorMenuRoot.BeginUpdate;
|
//PackageEditorMenuRoot.BeginUpdate;
|
||||||
try
|
try
|
||||||
CollectSelected;
|
CollectSelected;
|
||||||
Writable := not LazPackage.ReadOnly;
|
Writable := not LazPackage.ReadOnly;
|
||||||
@ -862,7 +862,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
PackageEditorMenuRoot.EndUpdate;
|
//PackageEditorMenuRoot.EndUpdate;
|
||||||
end;
|
end;
|
||||||
FSingleSelectedFile := Nil;
|
FSingleSelectedFile := Nil;
|
||||||
FSingleSelectedDep := Nil;
|
FSingleSelectedDep := Nil;
|
||||||
@ -936,7 +936,7 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
PackageEditorMenuRoot.MenuItem:=MorePopupMenu.Items;
|
PackageEditorMenuRoot.MenuItem:=MorePopupMenu.Items;
|
||||||
PackageEditorMenuRoot.BeginUpdate;
|
//PackageEditorMenuRoot.BeginUpdate;
|
||||||
try
|
try
|
||||||
Writable:=(not LazPackage.ReadOnly);
|
Writable:=(not LazPackage.ReadOnly);
|
||||||
|
|
||||||
@ -964,7 +964,7 @@ begin
|
|||||||
// under section PkgEditMenuSectionMisc
|
// under section PkgEditMenuSectionMisc
|
||||||
SetItem(PkgEditMenuViewPackageSource,@ViewPkgSourceClick);
|
SetItem(PkgEditMenuViewPackageSource,@ViewPkgSourceClick);
|
||||||
finally
|
finally
|
||||||
PackageEditorMenuRoot.EndUpdate;
|
//PackageEditorMenuRoot.EndUpdate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
object TestMenuIntfForm: TTestMenuIntfForm
|
object TestMenuIntfDlg: TTestMenuIntfDlg
|
||||||
Left = 287
|
Left = 287
|
||||||
Height = 237
|
Height = 237
|
||||||
Top = 215
|
Top = 215
|
||||||
Width = 541
|
Width = 541
|
||||||
Caption = 'TestMenuIntfForm'
|
Caption = 'TestMenuIntfDlg'
|
||||||
Menu = TestMainMenuIntf1
|
Menu = TestMainMenuIntf1
|
||||||
LCLVersion = '1.7'
|
LCLVersion = '1.7'
|
||||||
object TestMainMenuIntf1: TMainMenu
|
object TestMainMenuIntf1: TMainMenu
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
unit testmenuintf;
|
unit TestMenuIntf;
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
@ -10,9 +10,9 @@ uses
|
|||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
{ TTestMenuIntfForm }
|
{ TTestMenuIntfDlg }
|
||||||
|
|
||||||
TTestMenuIntfForm = class(TForm)
|
TTestMenuIntfDlg = class(TForm)
|
||||||
TestMainMenuIntf1: TMainMenu;
|
TestMainMenuIntf1: TMainMenu;
|
||||||
TestPopupMenuIntf1: TPopupMenu;
|
TestPopupMenuIntf1: TPopupMenu;
|
||||||
private
|
private
|
||||||
@ -22,13 +22,31 @@ type
|
|||||||
{ TMenuIntfTest }
|
{ TMenuIntfTest }
|
||||||
|
|
||||||
TTestMenuIntf = class(TTestCase)
|
TTestMenuIntf = class(TTestCase)
|
||||||
|
private
|
||||||
|
FDialog: TTestMenuIntfDlg;
|
||||||
|
FMainMenuRoot: TIDEMenuSection;
|
||||||
|
FPopupMenuRoot: TIDEMenuSection;
|
||||||
|
protected
|
||||||
|
procedure SetUp; override;
|
||||||
|
procedure TearDown; override;
|
||||||
public
|
public
|
||||||
|
function CreateCommand(aParent: TIDEMenuSection; aName: string): TIDEMenuCommand;
|
||||||
|
function CreateSection(aParent: TIDEMenuSection; aName: string): TIDEMenuSection;
|
||||||
|
property Dialog: TTestMenuIntfDlg read FDialog;
|
||||||
|
property MainMenuRoot: TIDEMenuSection read FMainMenuRoot;
|
||||||
|
property PopupMenuRoot: TIDEMenuSection read FPopupMenuRoot;
|
||||||
published
|
published
|
||||||
procedure TestMainMenu;
|
procedure TestEmptyMainMenu;
|
||||||
|
procedure TestSinglePopupMenu;
|
||||||
|
procedure TestPopupMenuList;
|
||||||
|
procedure TestPopupMenuLogicalSection;
|
||||||
|
procedure TestPopupMenuSubMenu;
|
||||||
|
procedure TestPopupMenuVisible;
|
||||||
|
procedure TestPopupMenuClearHiddenSection;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
TestMenuIntfForm: TTestMenuIntfForm;
|
TestMenuIntfDlg: TTestMenuIntfDlg;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -37,9 +55,220 @@ implementation
|
|||||||
|
|
||||||
{ TMenuIntfTest }
|
{ TMenuIntfTest }
|
||||||
|
|
||||||
procedure TTestMenuIntf.TestMainMenu;
|
procedure TTestMenuIntf.SetUp;
|
||||||
begin
|
begin
|
||||||
|
inherited SetUp;
|
||||||
|
IDEMenuRoots:=TIDEMenuRoots.Create;
|
||||||
|
FMainMenuRoot:=RegisterIDEMenuRoot('MainMenuRoot');
|
||||||
|
FPopupMenuRoot:=RegisterIDEMenuRoot('PopupMenuRoot');
|
||||||
|
FDialog:=TTestMenuIntfDlg.Create(nil);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestMenuIntf.TearDown;
|
||||||
|
begin
|
||||||
|
FreeAndNil(FDialog);
|
||||||
|
FMainMenuRoot:=nil;
|
||||||
|
FPopupMenuRoot:=nil;
|
||||||
|
FreeAndNil(IDEMenuRoots);
|
||||||
|
inherited TearDown;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TTestMenuIntf.CreateCommand(aParent: TIDEMenuSection; aName: string): TIDEMenuCommand;
|
||||||
|
begin
|
||||||
|
Result:=RegisterIDEMenuCommand(aParent,aName,aName);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TTestMenuIntf.CreateSection(aParent: TIDEMenuSection; aName: string
|
||||||
|
): TIDEMenuSection;
|
||||||
|
begin
|
||||||
|
Result:=RegisterIDEMenuSection(aParent,aName);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestMenuIntf.TestEmptyMainMenu;
|
||||||
|
begin
|
||||||
|
FMainMenuRoot.MenuItem:=Dialog.TestMainMenuIntf1.Items;
|
||||||
|
MainMenuRoot.ConsistencyCheck;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestMenuIntf.TestSinglePopupMenu;
|
||||||
|
begin
|
||||||
|
FPopupMenuRoot.MenuItem:=Dialog.TestPopupMenuIntf1.Items;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
RegisterIDEMenuCommand(PopupMenuRoot,'Help','Help');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestMenuIntf.TestPopupMenuList;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
FPopupMenuRoot.MenuItem:=Dialog.TestPopupMenuIntf1.Items;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
for i:=1 to 3 do begin
|
||||||
|
RegisterIDEMenuCommand(PopupMenuRoot,'Item'+IntToStr(i),'Item'+IntToStr(i));
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestMenuIntf.TestPopupMenuLogicalSection;
|
||||||
|
var
|
||||||
|
Section1: TIDEMenuSection;
|
||||||
|
begin
|
||||||
|
FPopupMenuRoot.MenuItem:=Dialog.TestPopupMenuIntf1.Items;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
Section1:=RegisterIDEMenuSection(PopupMenuRoot,'Section1');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
Section1.ChildrenAsSubMenu:=false;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
RegisterIDEMenuCommand(Section1,'Item1','Item1');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestMenuIntf.TestPopupMenuSubMenu;
|
||||||
|
var
|
||||||
|
Section1: TIDEMenuSection;
|
||||||
|
begin
|
||||||
|
FPopupMenuRoot.MenuItem:=Dialog.TestPopupMenuIntf1.Items;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
Section1:=RegisterIDEMenuSection(PopupMenuRoot,'Section1');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
RegisterIDEMenuCommand(Section1,'Item1','Item1');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestMenuIntf.TestPopupMenuVisible;
|
||||||
|
var
|
||||||
|
LogSection1, SubMenu2, LogSection2: TIDEMenuSection;
|
||||||
|
Item1, Item2, Item3, Item4: TIDEMenuCommand;
|
||||||
|
begin
|
||||||
|
FPopupMenuRoot.MenuItem:=Dialog.TestPopupMenuIntf1.Items;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
|
||||||
|
LogSection1:=RegisterIDEMenuSection(PopupMenuRoot,'LogSection1');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
Item1:=RegisterIDEMenuCommand(LogSection1,'Item1','Item1');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('LogSection1.VisibleActive',true,LogSection1.VisibleActive);
|
||||||
|
AssertEquals('LogSection1.VisibleCommandCount',1,LogSection1.VisibleCommandCount);
|
||||||
|
|
||||||
|
SubMenu2:=RegisterIDEMenuSection(PopupMenuRoot,'SubMenu2');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
Item2:=RegisterIDEMenuCommand(SubMenu2,'Item2','Item2');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('SubMenu2.VisibleActive',true,SubMenu2.VisibleActive);
|
||||||
|
AssertEquals('SubMenu2.VisibleCommandCount',1,SubMenu2.VisibleCommandCount);
|
||||||
|
|
||||||
|
LogSection2:=RegisterIDEMenuSection(PopupMenuRoot,'LogSection2');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
Item3:=RegisterIDEMenuCommand(LogSection2,'Item3','Item3');
|
||||||
|
Item4:=RegisterIDEMenuCommand(LogSection2,'Item4','Item4');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('LogSection2.VisibleActive',true,LogSection2.VisibleActive);
|
||||||
|
AssertEquals('LogSection2.VisibleCommandCount',2,LogSection2.VisibleCommandCount);
|
||||||
|
|
||||||
|
// hide Item1 -> auto hides LogSection1
|
||||||
|
Item1.Visible:=false;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('LogSection1.VisibleActive',false,LogSection1.VisibleActive);
|
||||||
|
AssertEquals('LogSection1.VisibleCommandCount',0,LogSection1.VisibleCommandCount);
|
||||||
|
|
||||||
|
// show Item1 -> auto shows LogSection1
|
||||||
|
Item1.Visible:=true;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('LogSection1.VisibleActive',true,LogSection1.VisibleActive);
|
||||||
|
AssertEquals('LogSection1.VisibleCommandCount',1,LogSection1.VisibleCommandCount);
|
||||||
|
|
||||||
|
// hide Item2 -> auto hides SubMenu2
|
||||||
|
Item2.Visible:=false;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('SubMenu2.VisibleActive',false,SubMenu2.VisibleActive);
|
||||||
|
AssertEquals('SubMenu2.VisibleCommandCount',0,SubMenu2.VisibleCommandCount);
|
||||||
|
|
||||||
|
// show Item2 -> auto shows SubMenu2
|
||||||
|
Item2.Visible:=true;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('SubMenu2.VisibleActive',true,SubMenu2.VisibleActive);
|
||||||
|
AssertEquals('SubMenu2.VisibleCommandCount',1,SubMenu2.VisibleCommandCount);
|
||||||
|
|
||||||
|
// hide Item3, Item4 still visible
|
||||||
|
Item3.Visible:=false;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('LogSection2.VisibleActive',true,LogSection2.VisibleActive);
|
||||||
|
AssertEquals('LogSection2.VisibleCommandCount',1,LogSection2.VisibleCommandCount);
|
||||||
|
|
||||||
|
// hide Item4 -> auto hide LogSection2
|
||||||
|
Item4.Visible:=false;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('LogSection2.VisibleActive',false,LogSection2.VisibleActive);
|
||||||
|
AssertEquals('LogSection2.VisibleCommandCount',0,LogSection2.VisibleCommandCount);
|
||||||
|
|
||||||
|
// show Item3 -> auto shows LogSection2
|
||||||
|
Item3.Visible:=true;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('LogSection2.VisibleActive',true,LogSection2.VisibleActive);
|
||||||
|
AssertEquals('LogSection2.VisibleCommandCount',1,LogSection2.VisibleCommandCount);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestMenuIntf.TestPopupMenuClearHiddenSection;
|
||||||
|
var
|
||||||
|
LogSection1, SubSection2: TIDEMenuSection;
|
||||||
|
Item2: TIDEMenuCommand;
|
||||||
|
begin
|
||||||
|
FPopupMenuRoot.MenuItem:=Dialog.TestPopupMenuIntf1.Items;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
|
||||||
|
LogSection1:=RegisterIDEMenuSection(PopupMenuRoot,'LogSection1');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
RegisterIDEMenuCommand(LogSection1,'Item1','Item1');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
|
||||||
|
SubSection2:=RegisterIDEMenuSection(LogSection1,'SubSection2');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
Item2:=RegisterIDEMenuCommand(SubSection2,'Item2','Item2');
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
|
||||||
|
writeln('TTestMenuIntf.TestPopupMenuClearHiddenSection START');
|
||||||
|
AssertEquals('LogSection1.VisibleActive',true,LogSection1.VisibleActive);
|
||||||
|
AssertEquals('LogSection1.VisibleCommandCount',2,LogSection1.VisibleCommandCount);
|
||||||
|
AssertEquals('SubSection2.VisibleActive',true,SubSection2.VisibleActive);
|
||||||
|
AssertEquals('SubSection2.VisibleCommandCount',1,SubSection2.VisibleCommandCount);
|
||||||
|
|
||||||
|
// hide SubSection2 -> LogSection1 looses one command
|
||||||
|
writeln('TTestMenuIntf.TestPopupMenuClearHiddenSection hide SubSection2 -> LogSection1 looses one command');
|
||||||
|
SubSection2.Visible:=false;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('LogSection1.VisibleActive',true,LogSection1.VisibleActive);
|
||||||
|
AssertEquals('LogSection1.VisibleCommandCount',1,LogSection1.VisibleCommandCount);
|
||||||
|
AssertEquals('SubSection2.VisibleActive',false,SubSection2.VisibleActive);
|
||||||
|
AssertEquals('SubSection2.VisibleCommandCount',1,SubSection2.VisibleCommandCount);
|
||||||
|
|
||||||
|
// hide Item2 -> no effect on LogSection1
|
||||||
|
writeln('TTestMenuIntf.TestPopupMenuClearHiddenSection hide Item2 -> no effect on LogSection1');
|
||||||
|
Item2.Visible:=false;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('LogSection1.VisibleActive',true,LogSection1.VisibleActive);
|
||||||
|
AssertEquals('LogSection1.VisibleCommandCount',1,LogSection1.VisibleCommandCount);
|
||||||
|
AssertEquals('SubSection2.VisibleActive',false,SubSection2.VisibleActive);
|
||||||
|
AssertEquals('SubSection2.VisibleCommandCount',0,SubSection2.VisibleCommandCount);
|
||||||
|
|
||||||
|
// show Item2 -> no effect on LogSection1
|
||||||
|
writeln('TTestMenuIntf.TestPopupMenuClearHiddenSection show Item2 -> no effect on LogSection1');
|
||||||
|
Item2.Visible:=true;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('LogSection1.VisibleActive',true,LogSection1.VisibleActive);
|
||||||
|
AssertEquals('LogSection1.VisibleCommandCount',1,LogSection1.VisibleCommandCount);
|
||||||
|
AssertEquals('SubSection2.VisibleActive',false,SubSection2.VisibleActive);
|
||||||
|
AssertEquals('SubSection2.VisibleCommandCount',1,SubSection2.VisibleCommandCount);
|
||||||
|
|
||||||
|
// clear SubSection2 -> no effect on LogSection1
|
||||||
|
writeln('TTestMenuIntf.TestPopupMenuClearHiddenSection clear SubSection2 -> no effect on LogSection1');
|
||||||
|
SubSection2.Clear;
|
||||||
|
Item2:=nil;
|
||||||
|
PopupMenuRoot.ConsistencyCheck;
|
||||||
|
AssertEquals('LogSection1.VisibleActive',true,LogSection1.VisibleActive);
|
||||||
|
AssertEquals('LogSection1.VisibleCommandCount',1,LogSection1.VisibleCommandCount);
|
||||||
|
AssertEquals('SubSection2.VisibleActive',false,SubSection2.VisibleActive);
|
||||||
|
AssertEquals('SubSection2.VisibleCommandCount',0,SubSection2.VisibleCommandCount);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
|||||||
@ -107,8 +107,10 @@
|
|||||||
<Unit14>
|
<Unit14>
|
||||||
<Filename Value="ideintf\testmenuintf.pas"/>
|
<Filename Value="ideintf\testmenuintf.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<ComponentName Value="TestMenuIntfForm"/>
|
<ComponentName Value="TestMenuIntfDlg"/>
|
||||||
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
|
<UnitName Value="TestMenuIntf"/>
|
||||||
</Unit14>
|
</Unit14>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
|
|||||||
@ -29,7 +29,7 @@ begin
|
|||||||
Application.Title:='Run Lazarus tests';
|
Application.Title:='Run Lazarus tests';
|
||||||
Application.Initialize;
|
Application.Initialize;
|
||||||
Application.CreateForm(TGuiTestRunner, TestRunner);
|
Application.CreateForm(TGuiTestRunner, TestRunner);
|
||||||
Application.CreateForm(TTestMenuIntfForm, TestMenuIntfForm);
|
Application.CreateForm(TTestMenuIntfDlg, TestMenuIntfDlg);
|
||||||
Application.Run;
|
Application.Run;
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user