Browse Source

sqldb: tests: clean up forms so database.ini editor is in main form

git-svn-id: trunk@25327 -
reiniero 12 years ago
parent
commit
e7b833bd1b

+ 1 - 0
.gitattributes

@@ -2189,6 +2189,7 @@ packages/fcl-db/tests/README.txt svneol=native#text/plain
 packages/fcl-db/tests/bufdatasettoolsunit.pas svneol=native#text/plain
 packages/fcl-db/tests/database.ini.txt svneol=native#text/plain
 packages/fcl-db/tests/dbftoolsunit.pas svneol=native#text/plain
+packages/fcl-db/tests/dbguitestrunner.pas svneol=native#text/plain
 packages/fcl-db/tests/dbtestframework.pas svneol=native#text/plain
 packages/fcl-db/tests/dbtestframework_gui.lpi svneol=native#text/plain
 packages/fcl-db/tests/dbtestframework_gui.lpr svneol=native#text/plain

+ 68 - 0
packages/fcl-db/tests/dbguitestrunner.pas

@@ -0,0 +1,68 @@
+unit DBGuiTestRunner;
+// Adds database.ini editing facilities to regular GuiTestRunner form
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils,
+  Interfaces, Forms,
+  StdCtrls,
+  GuiTestRunner, inieditor;
+
+type
+
+  { TDBGuiTestRunnerForm }
+
+  TDBGuiTestRunnerForm=class(TGUITestRunner)
+  private
+    DBEditButton: TButton;
+  public
+    procedure DBEditButtonClick(ASender: TObject);
+    constructor Create(AOwner: TComponent); override;
+  end;
+
+var
+  DBGuiTestRunnerForm: TDBGuiTestRunnerForm;
+
+
+implementation
+
+
+{ TDBGuiTestRunnerForm }
+
+procedure TDBGuiTestRunnerForm.DBEditButtonClick(ASender: TObject);
+var
+  DBSelectForm: TFormIniEditor;
+begin
+  DBSelectForm:=TFormIniEditor.Create(nil);
+  try
+    DBSelectForm.INIFile:='database.ini';
+    DBSelectForm.ProfileSelectSection:='Database';
+    DBSelectForm.ProfileSelectKey:='type';
+    // We can ignore resulting db selection as the file is saved already:
+    DBSelectForm.ShowModal;
+  finally
+    DBSelectForm.Free;
+  end;
+end;
+
+constructor TDBGuiTestRunnerForm.Create(AOwner: TComponent);
+// Add our database.ini edit button to the existing GUI
+begin
+  inherited Create(AOwner);
+  DBEditButton:=TButton.Create(Self);
+  DBEditButton.Top:=7;
+  DBEditButton.Left:=210;
+  DBEditButton.Height:=32;
+  DBEditButton.Width:=100;
+  DBEditButton.Caption:='Edit database.ini...';
+  DBEditButton.Hint:='Edit database selection settings (effective for next start)';
+  DBEditButton.OnClick:=@DBEditButtonClick;
+  // Set this last; now all properties take effect
+  DBEditButton.Parent:=Self.Panel1;
+end;
+
+end.
+

+ 11 - 2
packages/fcl-db/tests/dbtestframework_gui.lpi

@@ -1,10 +1,14 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
   <ProjectOptions>
     <Version Value="9"/>
     <General>
+      <Flags>
+        <MainUnitHasCreateFormStatements Value="False"/>
+      </Flags>
       <SessionStorage Value="InProjectDir"/>
       <MainUnit Value="0"/>
+      <Title Value="DBTestFramework"/>
       <ResourceType Value="res"/>
       <UseXPManifest Value="True"/>
     </General>
@@ -76,12 +80,17 @@
         <PackageName Value="FCL"/>
       </Item4>
     </RequiredPackages>
-    <Units Count="1">
+    <Units Count="2">
       <Unit0>
         <Filename Value="dbtestframework_gui.lpr"/>
         <IsPartOfProject Value="True"/>
         <UnitName Value="dbtestframework_gui"/>
       </Unit0>
+      <Unit1>
+        <Filename Value="dbguitestrunner.pas"/>
+        <IsPartOfProject Value="True"/>
+        <UnitName Value="DBGuiTestRunner"/>
+      </Unit1>
     </Units>
   </ProjectOptions>
   <CompilerOptions>

+ 6 - 24
packages/fcl-db/tests/dbtestframework_gui.lpr

@@ -14,10 +14,11 @@ program dbtestframework_gui;
 uses
   Interfaces, Forms,
   // GUI:
-  GuiTestRunner, inieditor,
+  StdCtrls {to extend GuiTestRunner},
+  DBGuiTestRunner, inieditor,
   // Generic DB test framework units
   ToolsUnit,
-  // Connectors for different database-types
+  // Connectors for different database types
   sqldbtoolsunit,
   dbftoolsunit,
   bufdatasettoolsunit,
@@ -37,29 +38,10 @@ uses
 
 {$R *.res}
 
-var
-  DBSelectForm: TFormIniEditor;
-  TestRunForm: TGUITestRunner;
 begin
+  Application.Title:='DBTestFramework';
   Application.Initialize;
-  DBSelectForm:=TFormIniEditor.Create(nil);
-  try
-    DBSelectForm.INIFile:='database.ini';
-    DBSelectForm.ProfileSelectSection:='Database';
-    DBSelectForm.ProfileSelectKey:='type';
-    // We can ignore resulting db selection as the file is saved already:
-    DBSelectForm.ShowModal;
-  finally
-    DBSelectForm.Free;
-  end;
-  // Manually run this form because autocreation could have loaded an old
-  // database.ini file (if the user changed it using DBSelectForm)
-  TestRunForm:=TGUITestRunner.Create(nil);
-  try
-    TestRunForm.Show;
-    Application.Run;
-  finally
-    TestRunForm.Free;
-  end;
+  Application.CreateForm(TDBGuiTestRunnerForm, DBGuiTestRunnerForm);
+  Application.Run;
 end.
 

+ 25 - 7
packages/fcl-db/tests/inieditor.lfm

@@ -454,12 +454,14 @@ object FormIniEditor: TFormIniEditor
     Lines.Strings = (
       ''
     )
+    SelectedColor.FrameEdges = sfeAround
     SelectedColor.BackPriority = 50
     SelectedColor.ForePriority = 50
     SelectedColor.FramePriority = 50
     SelectedColor.BoldPriority = 50
     SelectedColor.ItalicPriority = 50
     SelectedColor.UnderlinePriority = 50
+    SelectedColor.StrikeOutPriority = 50
     OnStatusChange = SynMemoStatusChange
     inline SynLeftGutterPartList1: TSynGutterPartList
       object SynGutterMarks1: TSynGutterMarks
@@ -471,6 +473,7 @@ object FormIniEditor: TFormIniEditor
         MouseActions = <>
         MarkupInfo.Background = clBtnFace
         MarkupInfo.Foreground = clNone
+        MarkupInfo.FrameEdges = sfeAround
         DigitCount = 2
         ShowOnlyLineNumbersMultiplesOf = 1
         ZeroStart = False
@@ -485,11 +488,15 @@ object FormIniEditor: TFormIniEditor
       object SynGutterSeparator1: TSynGutterSeparator
         Width = 2
         MouseActions = <>
+        MarkupInfo.Background = clWhite
+        MarkupInfo.Foreground = clGray
+        MarkupInfo.FrameEdges = sfeAround
       end
       object SynGutterCodeFolding1: TSynGutterCodeFolding
         MouseActions = <>
         MarkupInfo.Background = clNone
         MarkupInfo.Foreground = clGray
+        MarkupInfo.FrameEdges = sfeAround
         MouseActionsExpanded = <>
         MouseActionsCollapsed = <>
       end
@@ -497,7 +504,7 @@ object FormIniEditor: TFormIniEditor
   end
   object FileNameEdit: TFileNameEdit
     Left = 56
-    Height = 23
+    Height = 21
     Top = 24
     Width = 368
     OnAcceptFileName = FileNameEditAcceptFileName
@@ -510,28 +517,28 @@ object FormIniEditor: TFormIniEditor
   end
   object INIFileLabel: TLabel
     Left = 8
-    Height = 15
+    Height = 13
     Top = 24
-    Width = 34
+    Width = 32
     Caption = 'INI file'
     ParentColor = False
   end
   object ProfileSelect: TComboBox
     Left = 56
-    Height = 23
+    Height = 21
     Hint = 'Choose the profile you want to enable'
     Top = 61
     Width = 164
-    ItemHeight = 15
+    ItemHeight = 13
     OnSelect = ProfileSelectSelect
     Sorted = True
     TabOrder = 1
   end
   object ProfileLabel: TLabel
     Left = 8
-    Height = 15
+    Height = 13
     Top = 64
-    Width = 34
+    Width = 30
     Caption = 'Profile'
     ParentColor = False
   end
@@ -556,6 +563,17 @@ object FormIniEditor: TFormIniEditor
     OnClick = CancelButtonClick
     TabOrder = 3
   end
+  object Label1: TLabel
+    Left = 8
+    Height = 13
+    Top = 0
+    Width = 229
+    Caption = 'Changes need a program restart to load!'
+    Font.Color = clRed
+    Font.Style = [fsBold]
+    ParentColor = False
+    ParentFont = False
+  end
   object SynIniHighlighter: TSynIniSyn
     DefaultFilter = 'INI Files (*.ini)|*.ini'
     Enabled = False

+ 1 - 0
packages/fcl-db/tests/inieditor.pas

@@ -15,6 +15,7 @@ type
 
   TFormIniEditor = class(TForm)
     GUITimer: TIdleTimer;
+    Label1: TLabel;
     OKButton: TButton;
     CancelButton: TButton;
     ProfileSelect: TComboBox;

+ 1 - 1
packages/fcl-db/tests/sqldbtoolsunit.pas

@@ -12,7 +12,7 @@ uses
   ,pqconnection
   ,odbcconn
   {$IFNDEF WIN64}
-  {See packages\fcl-db\fpmake.pp: Oracle connector is not built if PostgreSQL connectoris not built}
+  {See packages\fcl-db\fpmake.pp: Oracle connector not built yet on Win64}
   ,oracleconnection
   {$ENDIF WIN64}
   ,sqlite3conn