Ignore:
Timestamp:
Feb 9, 2022, 3:51:26 PM (3 years ago)
Author:
chronos
Message:
  • Added: Support for profile photo as URL.
  • Added: New UContactImage form to show profile photo in bigger size and with URL.
  • Modified: Profile photo image load/save handling moved to separate unit UContactImage.
  • Fixed: Some dynamically created forms were not translated.
  • Added: Remember last used file name for image open/save dialog.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormTest.pas

    r97 r103  
    3535    procedure ReloadList;
    3636    procedure UpdateInterface;
     37    procedure InitTestCases;
    3738  public
    3839    TestCases: TTestCases;
     
    7879  ARun.Enabled := Assigned(ListViewTestCases.Selected);
    7980  AShow.Enabled := Assigned(ListViewTestCases.Selected);
     81end;
     82
     83procedure TFormTest.InitTestCases;
     84const
     85  VCardVersion = 'VERSION:2.1';
     86begin
     87  TestCases := TTestCases.Create;
     88  with TestCases do begin
     89    with TTestCaseLoadSave(AddNew('Load and save', TTestCaseLoadSave)) do begin
     90      Input := VCardBegin + LineEnding +
     91        VCardVersion + LineEnding +
     92        'N:Surname;Name' + LineEnding +
     93        'FN:Name Surname' + LineEnding +
     94        VCardEnd + LineEnding;
     95      Output := Input;
     96    end;
     97    with TTestCaseLoadSave(AddNew('Long text', TTestCaseLoadSave)) do begin
     98      Input := VCardBegin + LineEnding +
     99        VCardVersion + LineEnding +
     100        'NOTE:This is some long test which is really multi-lined each line is on d' + LineEnding +
     101        ' ifferent line so it is on multiple lines.' + LineEnding +
     102        VCardEnd + LineEnding;
     103      Output := Input;
     104    end;
     105    with TTestCaseLoadSave(AddNew('Multi-line', TTestCaseLoadSave)) do begin
     106      Input := VCardBegin + LineEnding +
     107        VCardVersion + LineEnding +
     108        'NOTE:First line\nsecond line\nempty line\n\nlast line' + LineEnding +
     109        VCardEnd + LineEnding;
     110     Output := Input;
     111    end;
     112    with TTestCaseLoadSave(AddNew('Quoted-printable load-save', TTestCaseLoadSave)) do begin
     113      Input := VCardBegin + LineEnding +
     114        VCardVersion + LineEnding +
     115        'FN;ENCODING=QUOTED-PRINTABLE:Jm=C3=A9no=20P=C5=99=C3=ADjmen=C3=AD' + LineEnding +
     116        VCardEnd + LineEnding;
     117      Output := Input;
     118    end;
     119    with TTestCaseLoadSave(AddNew('Quoted-printable load-save multi-line', TTestCaseLoadSave)) do begin
     120      Input := VCardBegin + LineEnding +
     121        VCardVersion + LineEnding +
     122        'FN;ENCODING=QUOTED-PRINTABLE:Jm=C3=A9no=20P=C5=99=C3=ADjmen=C3=AD=' + LineEnding +
     123        'Jm=C3=A9no=20P=C5=99=C3=ADjmen=C3=AD' + LineEnding +
     124        VCardEnd + LineEnding;
     125      Output := Input;
     126    end;
     127    //AddNew('Encoding base64', TTestCaseLoadSave);
     128    //AddNew('Encoding quoted-printable', TTestCaseLoadSave);
     129    //AddNew('Image format', TTestCaseLoadSave);
     130    with TTestCaseLoadSave(AddNew('Empty', TTestCaseLoadSave)) do begin
     131      Input := '';
     132      Output := '';
     133    end;
     134    with TTestCaseLoadSave(AddNew('Begin only', TTestCaseLoadSave)) do begin
     135      Input := VCardBegin;
     136      Output := '';
     137    end;
     138    with TTestCaseLoadSave(AddNew('Missing end', TTestCaseLoadSave)) do begin
     139      Input := VCardBegin + LineEnding +
     140        VCardVersion + LineEnding +
     141        'N:Surname;Name' + LineEnding +
     142        'FN:Name Surname' + LineEnding;
     143      Output := '';
     144    end;
     145    with TTestCaseLoadSave(AddNew('Missing start', TTestCaseLoadSave)) do begin
     146      Input := VCardVersion + LineEnding +
     147        'N:Surname;Name' + LineEnding +
     148        'FN:Name Surname' + LineEnding +
     149        VCardEnd + LineEnding;
     150      Output := '';
     151    end;
     152    with TTestCaseCheckProperty(AddNew('Propery FN', TTestCaseCheckProperty)) do begin
     153      Index := cfFullName;
     154      Value := 'Name Surname';
     155      Input := VCardBegin + LineEnding +
     156        VCardVersion + LineEnding +
     157        'FN:' + Value + LineEnding +
     158        VCardEnd + LineEnding;
     159    end;
     160    with TTestCaseCheckProperty(AddNew('Escaped new lines in text', TTestCaseCheckProperty)) do begin
     161      Index := cfNote;
     162      Value := 'Line' + #13#10 + 'Line';
     163      Input := VCardBegin + LineEnding +
     164        VCardVersion + LineEnding +
     165        'NOTE:Line\nLine' + LineEnding +
     166        VCardEnd + LineEnding;
     167    end;
     168    with TTestCaseCheckProperty(AddNew('Compound value', TTestCaseCheckProperty)) do begin
     169      Index := cfFirstName;
     170      Value := 'FirstName';
     171      Input := VCardBegin + LineEnding +
     172        VCardVersion + LineEnding +
     173        'N:Surname;FirstName;;;' + LineEnding +
     174        VCardEnd + LineEnding;
     175    end;
     176    with TTestCaseCheckProperty(AddNew('Quoted-printable special symbols', TTestCaseCheckProperty)) do begin
     177      Index := cfFullName;
     178      Value := 'Jméno Příjmení';
     179      Input := VCardBegin + LineEnding +
     180        VCardVersion + LineEnding +
     181        'FN;ENCODING=QUOTED-PRINTABLE:Jm=C3=A9no=20P=C5=99=C3=ADjmen=C3=AD' + LineEnding +
     182        VCardEnd + LineEnding;
     183    end;
     184  end;
    80185end;
    81186
     
    115220
    116221procedure TFormTest.FormCreate(Sender: TObject);
    117 const
    118   VCardVersion = 'VERSION:2.1';
    119 begin
    120   TestCases := TTestCases.Create;
    121   with TestCases do begin
    122     with TTestCaseLoadSave(AddNew('Load and save', TTestCaseLoadSave)) do begin
    123       Input := VCardBegin + LineEnding +
    124         VCardVersion + LineEnding +
    125         'N:Surname;Name' + LineEnding +
    126         'FN:Name Surname' + LineEnding +
    127         VCardEnd + LineEnding;
    128       Output := Input;
    129     end;
    130     with TTestCaseLoadSave(AddNew('Long text', TTestCaseLoadSave)) do begin
    131       Input := VCardBegin + LineEnding +
    132         VCardVersion + LineEnding +
    133         'NOTE:This is some long test which is really multi-lined each line is on d' + LineEnding +
    134         ' ifferent line so it is on multiple lines.' + LineEnding +
    135         VCardEnd + LineEnding;
    136       Output := Input;
    137     end;
    138     with TTestCaseLoadSave(AddNew('Multi-line', TTestCaseLoadSave)) do begin
    139       Input := VCardBegin + LineEnding +
    140         VCardVersion + LineEnding +
    141         'NOTE:First line\nsecond line\nempty line\n\nlast line' + LineEnding +
    142         VCardEnd + LineEnding;
    143       Output := Input;
    144     end;
    145     with TTestCaseLoadSave(AddNew('Quoted-printable load-save', TTestCaseLoadSave)) do begin
    146       Input := VCardBegin + LineEnding +
    147         VCardVersion + LineEnding +
    148         'FN;ENCODING=QUOTED-PRINTABLE:Jm=C3=A9no=20P=C5=99=C3=ADjmen=C3=AD' + LineEnding +
    149         VCardEnd + LineEnding;
    150       Output := Input;
    151     end;
    152     with TTestCaseLoadSave(AddNew('Quoted-printable load-save multi-line', TTestCaseLoadSave)) do begin
    153       Input := VCardBegin + LineEnding +
    154         VCardVersion + LineEnding +
    155         'FN;ENCODING=QUOTED-PRINTABLE:Jm=C3=A9no=20P=C5=99=C3=ADjmen=C3=AD=' + LineEnding +
    156         'Jm=C3=A9no=20P=C5=99=C3=ADjmen=C3=AD' + LineEnding +
    157         VCardEnd + LineEnding;
    158       Output := Input;
    159     end;
    160     //AddNew('Encoding base64', TTestCaseLoadSave);
    161     //AddNew('Encoding quoted-printable', TTestCaseLoadSave);
    162     //AddNew('Image format', TTestCaseLoadSave);
    163     with TTestCaseLoadSave(AddNew('Empty', TTestCaseLoadSave)) do begin
    164       Input := '';
    165       Output := '';
    166     end;
    167     with TTestCaseLoadSave(AddNew('Begin only', TTestCaseLoadSave)) do begin
    168       Input := VCardBegin;
    169       Output := '';
    170     end;
    171     with TTestCaseLoadSave(AddNew('Missing end', TTestCaseLoadSave)) do begin
    172       Input := VCardBegin + LineEnding +
    173         VCardVersion + LineEnding +
    174         'N:Surname;Name' + LineEnding +
    175         'FN:Name Surname' + LineEnding;
    176       Output := '';
    177     end;
    178     with TTestCaseLoadSave(AddNew('Missing start', TTestCaseLoadSave)) do begin
    179       Input := VCardVersion + LineEnding +
    180         'N:Surname;Name' + LineEnding +
    181         'FN:Name Surname' + LineEnding +
    182         VCardEnd + LineEnding;
    183       Output := '';
    184     end;
    185     with TTestCaseCheckProperty(AddNew('Propery FN', TTestCaseCheckProperty)) do begin
    186       Index := cfFullName;
    187       Value := 'Name Surname';
    188       Input := VCardBegin + LineEnding +
    189         VCardVersion + LineEnding +
    190         'FN:' + Value + LineEnding +
    191         VCardEnd + LineEnding;
    192     end;
    193     with TTestCaseCheckProperty(AddNew('Escaped new lines in text', TTestCaseCheckProperty)) do begin
    194       Index := cfNote;
    195       Value := 'Line' + #13#10 + 'Line';
    196       Input := VCardBegin + LineEnding +
    197         VCardVersion + LineEnding +
    198         'NOTE:Line\nLine' + LineEnding +
    199         VCardEnd + LineEnding;
    200     end;
    201     with TTestCaseCheckProperty(AddNew('Compound value', TTestCaseCheckProperty)) do begin
    202       Index := cfFirstName;
    203       Value := 'FirstName';
    204       Input := VCardBegin + LineEnding +
    205         VCardVersion + LineEnding +
    206         'N:Surname;FirstName;;;' + LineEnding +
    207         VCardEnd + LineEnding;
    208     end;
    209     with TTestCaseCheckProperty(AddNew('Quoted-printable special symbols', TTestCaseCheckProperty)) do begin
    210       Index := cfFullName;
    211       Value := 'Jméno Příjmení';
    212       Input := VCardBegin + LineEnding +
    213         VCardVersion + LineEnding +
    214         'FN;ENCODING=QUOTED-PRINTABLE:Jm=C3=A9no=20P=C5=99=C3=ADjmen=C3=AD' + LineEnding +
    215         VCardEnd + LineEnding;
    216     end;
    217   end;
     222begin
     223  Core.Translator.TranslateComponentRecursive(Self);
     224  Core.ThemeManager1.UseTheme(Self);
     225
     226  InitTestCases;
    218227end;
    219228
Note: See TracChangeset for help on using the changeset viewer.