~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to components/synedit/test/testhighlighterlfm.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
unit TestHighlighterLfm;
 
2
 
 
3
{$mode objfpc}{$H+}
 
4
 
 
5
interface
 
6
 
 
7
uses
 
8
  Classes, SysUtils, testregistry, TestBase, Forms, LCLProc, TestHighlightFoldBase,
 
9
  SynEdit, SynEditTypes, SynHighlighterLFM, SynEditHighlighterFoldBase;
 
10
 
 
11
type
 
12
 
 
13
  { TTestBaseHighlighterLem }
 
14
 
 
15
  TTestBaseHighlighterLem = class(TTestBaseHighlighterFoldBase)
 
16
  protected
 
17
    function LfmHighLighter: TSynLFMSyn;
 
18
    function CreateTheHighLighter: TSynCustomFoldHighlighter; override;
 
19
    procedure EnableFolds(AEnbledTypes: TLfmCodeFoldBlockTypes;
 
20
                          AHideTypes: TLfmCodeFoldBlockTypes = [];
 
21
                          ANoFoldTypes: TLfmCodeFoldBlockTypes = []
 
22
                         );
 
23
    //procedure DebugFoldInfo(ALineIdx: Integer; AFilter: TSynFoldActions; Group: Integer=0);
 
24
    //procedure DebugFoldInfo(AFilter: TSynFoldActions; Group: Integer=0);
 
25
    //function FoldActionsToString(AFoldActions: TSynFoldActions): String;
 
26
  end;
 
27
 
 
28
  { TTestHighlighterLfm }
 
29
 
 
30
  TTestHighlighterLfm = class(TTestBaseHighlighterLem)
 
31
  protected
 
32
    function TestTextFoldInfo1: TStringArray;
 
33
 
 
34
    procedure CheckTokensForLine(Name: String; LineIdx: Integer; ExpTokens: Array of TtkTokenKind);
 
35
  published
 
36
    procedure TestFoldInfo;
 
37
  end;
 
38
 
 
39
implementation
 
40
 
 
41
{ TTestBaseHighlighterLem }
 
42
 
 
43
function TTestBaseHighlighterLem.LfmHighLighter: TSynLFMSyn;
 
44
begin
 
45
  Result := TSynLFMSyn(FTheHighLighter);
 
46
end;
 
47
 
 
48
function TTestBaseHighlighterLem.CreateTheHighLighter: TSynCustomFoldHighlighter;
 
49
begin
 
50
  Result := TSynLFMSyn.Create(nil);
 
51
end;
 
52
 
 
53
procedure TTestBaseHighlighterLem.EnableFolds(AEnbledTypes: TLfmCodeFoldBlockTypes;
 
54
  AHideTypes: TLfmCodeFoldBlockTypes; ANoFoldTypes: TLfmCodeFoldBlockTypes);
 
55
var
 
56
  i: TLfmCodeFoldBlockType;
 
57
begin
 
58
  for i := low(TLfmCodeFoldBlockType) to high(TLfmCodeFoldBlockType) do begin
 
59
    LfmHighLighter.FoldConfig[ord(i)].Enabled := i in AEnbledTypes;
 
60
    if (i in ANoFoldTypes) then
 
61
      LfmHighLighter.FoldConfig[ord(i)].Modes := []
 
62
    else
 
63
      LfmHighLighter.FoldConfig[ord(i)].Modes := [fmFold];
 
64
    if i in AHideTypes then
 
65
      LfmHighLighter.FoldConfig[ord(i)].Modes := LfmHighLighter.FoldConfig[ord(i)].Modes + [fmHide]
 
66
  end;
 
67
end;
 
68
 
 
69
function TTestHighlighterLfm.TestTextFoldInfo1: TStringArray;
 
70
begin
 
71
  SetLength(Result, 11);
 
72
  Result[0] := 'object BreakPointGroupDlg: TBreakPointGroupDlg';
 
73
  Result[1] := '  Left = 431';
 
74
  Result[2] := '  Height = 225';
 
75
  Result[3] := '  object ButtonPanel1: TButtonPanel';
 
76
  Result[4] := '    Left = 6';
 
77
  Result[5] := '  end';
 
78
  Result[6] := '  object Label1: TLabel';
 
79
  Result[7] := '    Left = 0';
 
80
  Result[8] := '  end';
 
81
  Result[9] := 'end';
 
82
  Result[10] := '';
 
83
 
 
84
 
 
85
end;
 
86
 
 
87
procedure TTestHighlighterLfm.CheckTokensForLine(Name: String; LineIdx: Integer;
 
88
  ExpTokens: array of TtkTokenKind);
 
89
var
 
90
  c: Integer;
 
91
begin
 
92
  LfmHighLighter.StartAtLineIndex(LineIdx);
 
93
  c := 0;
 
94
  while not LfmHighLighter.GetEol do begin
 
95
    //DebugLn([LfmHighLighter.GetToken,' (',PasHighLighter.GetTokenID ,') at ', PasHighLighter.GetTokenPos]);
 
96
    AssertEquals(Name + 'TokenId Line='+IntToStr(LineIdx)+' pos='+IntToStr(c),  ord(ExpTokens[c]), ord(LfmHighLighter.GetTokenID));
 
97
    LfmHighLighter.Next;
 
98
    inc(c);
 
99
    if c >= length(ExpTokens) then
 
100
      break;
 
101
  end;
 
102
  AssertEquals(Name+ 'TokenId Line='+IntToStr(LineIdx)+'  amount of tokens', length(ExpTokens), c );
 
103
end;
 
104
 
 
105
procedure TTestHighlighterLfm.TestFoldInfo;
 
106
begin
 
107
  ReCreateEdit;
 
108
 
 
109
  //  DebugFoldInfo([]);
 
110
 
 
111
  {%region}
 
112
  SetLines(TestTextFoldInfo1);
 
113
  EnableFolds([cfbtLfmObject..cfbtLfmNone]);
 
114
  PushBaseName('Text 1 all folds');
 
115
 
 
116
  EnableFolds([cfbtLfmObject..cfbtLfmNone], [cfbtLfmNone]);
 
117
  AssertEquals('Len 0', 9, LfmHighLighter.FoldLineLength(0,0));
 
118
  //AssertEquals('Len 1', 0, LfmHighLighter.FoldLineLength(1,0));
 
119
  AssertEquals('Len 3', 2, LfmHighLighter.FoldLineLength(3,0));
 
120
  //AssertEquals('Len 4', 0, LfmHighLighter.FoldLineLength(4,0));
 
121
  //AssertEquals('Len 5', 0, LfmHighLighter.FoldLineLength(5,0));
 
122
  AssertEquals('Len 6', 2, LfmHighLighter.FoldLineLength(6,0));
 
123
 
 
124
  CheckFoldOpenCounts('', [1, 0, 0, 1, 0, 0, 1, 0, 0, 0]);
 
125
 
 
126
  {%endregion}
 
127
 
 
128
end;
 
129
 
 
130
 
 
131
 
 
132
initialization
 
133
 
 
134
  RegisterTest(TTestHighlighterLfm);
 
135
end.
 
136