...
 
Commits (3)
' Gambas class file
Private $bNoSelectButton As Boolean
Private $hTimerReset As Timer
Public Sub ReadConfig()
......
' Gambas class file
Private $Tests As TestCommand[]
Private $MySettings As Settings
Private $sBackuptests As String
Private Const CURRENT_TESTSUITE_KEY As String = "@Current"
Public Const IDENT_CAR As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ÀÁÂÃĂÄĀÅÆĆČÇÈÉÊĔËĒÌÍÎĬÏÐŁÑÒÓÔÕÖŐØŠÙÚÛÜŰÝÞßàáâãăäāåæćčçèéêĕëēìíîĭïðłñòóôõöőøšùúûüűýÿþ0123456789$#_+-.,:;?!~!\"§$%&/(){[]}=<>|'`^°€@ "
Private $sCurrentTestSuiteCalled As String = "[" & ("current") & "]"
Private $sCurrentTestSuite As String
Public Sub _new()
$MySettings = New Settings(Project.Dir &/ ".tests")
Project.Compile()
$Tests = TestRunner.List(Project.Dir)
'just for creation and debugging
'$Tests = TestRunner.List("~/programming/gambas/gambas/comp/src/gb.test")
$sCurrentTestSuite = CURRENT_TESTSUITE_KEY
FillTestSuites()
FillTree(GetCurrentTests())
Catch
Message.Error(Error.Text)
End
Private Function GetCurrentTests() As String
Return GetTestsFromSettings(CURRENT_TESTSUITE_KEY)
End
Private Function GetTestsFromSettings(TestSuite As String) As String
Return $MySettings["Testsuite " & Testsuite & "/Tests"]
End
Private Sub FillTestSuites()
Dim Testsuite As String
Dim asBuf As New String[]
Dim sBuf As String
lvwTestSuites.Clear
lvwTestSuites.Add("*", "[All Tests]")
lvwTestSuites.Add(CURRENT_TESTSUITE_KEY, $sCurrentTestSuiteCalled)
lvwTestSuites[CURRENT_TESTSUITE_KEY].Selected = True
For Each sBuf In $MySettings.Keys
If sBuf Begins "Testsuite " Then
Testsuite = Right(sBuf, Len(sBuf) - 10)
If IsNotValid(Testsuite, True) Then
Error.Raise(Subst(("Forbidden character in the name of a testsuite in &1. Please fix this file."), $MySettings.Path))
Endif
If Testsuite <> CURRENT_TESTSUITE_KEY Then
asBuf.Add(Testsuite)
Endif
Endif
Next
asBuf.Sort
For Each Testsuite In asBuf
lvwTestSuites.Add(Testsuite, Testsuite)
Next
If $MySettings["CurrentTestsuite"] Then
lvwTestSuites[$MySettings["CurrentTestsuite"]].Selected = True
Endif
Catch
Message.Error(Error.Text)
Me.Close
End
Private Sub FillTree(Tests As String)
Dim Command As TestCommand
Dim sKeyModule, sModule, sMethod, sCur As String
Dim asSelected As New String[]
Dim i As Integer
tvwTests.Clear
tvwTests.Selection.Clear
asSelected = Split(Tests, ",")
For i = 0 To asSelected.Count - 1
asSelected[i] = Trim(asSelected[i])
Next
For Each Command In $Tests
sModule = Command.ModuleName
If sKeyModule = Null Then
sKeyModule = sModule
tvwTests.Add(sKeyModule, sModule)
sCur = sModule
GoSub CHECK_SELECTED
Else If sKeyModule <> sModule Then
tvwTests.Add(sModule, sModule, Null, Null, sKeyModule)
sKeyModule = sModule
sCur = sModule
GoSub CHECK_SELECTED
Endif
For Each sMethod In Command.Methods
tvwTests.Add(sModule & "." & sMethod, sMethod, Null, sKeyModule)
sCur = sModule & "." & sMethod
GoSub CHECK_SELECTED
Next
Next
FillSelected()
Goto THE_END
CHECK_SELECTED:
If tvwTests.MoveTo(sCur) = False Then
tvwTests.Item.Expanded = True
If asSelected.Exist(sCur) Then
tvwTests.Item.EnsureVisible()
tvwTests.Item.Selected = True
Else
tvwTests.Item.Selected = False
Endif
Endif
Return
THE_END:
End
Private Sub FillSelected()
Dim asBuf As New String[]
Dim sTests As String
Dim sKey As String
For Each sKey In tvwTests.Keys
If tvwTests[sKey].Selected = True Then
asBuf.Add(sKey)
Endif
Next
sTests = asBuf.Join(", ")
' Normalize Tests
sTests = TestCommand.ToString(TestCommand.FromString(sTests))
If sTests = Null Then
sTests = "*"
TxtSelected.Text = sTests
Endif
StoreTests($sCurrentTestSuite, sTests)
End
Private Sub StoreTests(TestSuite As String, Tests As String)
Dim i As Integer
Tests = Trim(Tests)
Testsuite = Trim(Testsuite)
TxtSelected.Text = Tests
'remove spaces
i = InStr(Tests, " ")
While i > 0
Tests = Left(Tests, i - 1) & Right(Tests, Len(Tests) - i)
i = InStr(Tests, " ")
Wend
$MySettings["CurrentTestsuite"] = Testsuite
$MySettings["Testsuite " & TestSuite & "/Tests"] = Tests
End
Public Sub Form_KeyPress()
'Maybe TODO: Ctrl-Z Ctrl-Y
'ctrl-Z
If Key.Control And If Key.Code = Key["z"] Then
FillTree($sBackuptests)
Endif
If Key.code = Key.Esc Then
Me.Close
Endif
End
Public Sub btnSave_Click()
Dim msg As String
If txtNameTestSuite.Text Then
If IsNotValid(txtNameTestSuite.Text) Then
msg = Subst(("There are forbidden characters in the name. Allowed characters are &1 and space."), GetAllowedCharsForHumans())
Message.Warning(msg)
Goto THE_END
Endif
If Trim(txtNameTestSuite.Text) = CURRENT_TESTSUITE_KEY Then
msg = Subst(("The name &1 is not allowed."), CURRENT_TESTSUITE_KEY)
Message.Warning(msg)
Goto THE_END
Endif
StoreTests(txtNameTestSuite.Text, TxtSelected.Text)
Else
Message.Info(("To save a testsuite, you must specify a name."))
Endif
FillTestSuites()
txtNameTestSuite.Text = Null
THE_END:
End
Public Sub lvwTestSuites_Click()
Dim Tests As String
If lvwTestSuites.Key Then
If lvwTestSuites.Key = "*" Then
Tests = "*"
Else
Tests = GetTestsFromSettings(lvwTestSuites.Key)
Endif
'Name to store
If lvwTestSuites.Key <> "*" And If lvwTestSuites.Key <> CURRENT_TESTSUITE_KEY Then
txtNameTestSuite.Text = lvwTestSuites.Key
Else
txtNameTestSuite.Text = Null
Endif
FillTree(Tests)
' keep this at this position
$MySettings["CurrentTestsuite"] = lvwTestSuites.Key
$MySettings.Save
Endif
End
Public Sub txtNameTestSuite_KeyPress()
If Key.Code = Key.Enter Or If Key.Code = Key.Return Then
btnSave_Click()
Endif
End
Public Sub lvwTestSuites_KeyPress()
If Key.Code = Key.Del Then
DeleteTestSuite()
Endif
If Key.Code = Key.Enter Or If Key.Code = Key.Return Then
lvwTestSuites_Click()
Endif
End
Private Sub DeleteTestSuite()
'delete Testsuite
If lvwTestSuites.Key <> CURRENT_TESTSUITE_KEY And If lvwTestSuites.Key <> "*" Then
If $MySettings["Testsuite " & lvwTestSuites.Key & "/Tests"] Then
If Message.Question(Subst(("Do you really want to delete the testsuite &1?"), lvwTestSuites.Key), ("Cancel"), ("Yes")) = 2 Then
$MySettings["Testsuite " & lvwTestSuites.Key & "/Tests"] = Null
If $MySettings["CurrentTestsuite"] = lvwTestSuites.Key Then
$MySettings["CurrentTestsuite"] = Null
Endif
$MySettings.Save()
FillTestSuites
Endif
Endif
Endif
End
Private Function IsNotValid(Name As String, Optional AllowSpecialChars As Boolean) As Boolean
Dim sChar As String
Dim i As Integer
Dim sAllowedChars As String
sAllowedChars = IDENT_CAR
If AllowSpecialChars = True Then
sAllowedChars &= "@*"
Endif
For i = 0 To Len(Name) - 1
sChar = Name[i]
If InStr(sAllowedChars, sChar) = 0 Then
Return True
Endif
Next
End
Private Function GetAllowedCharsForHumans() As String
Dim sBuf As String
Dim i As Integer
For i = 1 To String.Len(IDENT_CAR) Step 60
sbuf &= String.Mid(IDENT_CAR, i, 60) & gb.lf
Next
Return sbuf
End
Public Sub tvwTests_Select()
$sBackuptests = TxtSelected.Text
FillSelected()
If Not lvwTestSuites.Exist(CURRENT_TESTSUITE_KEY) Then
lvwTestSuites.Add(CURRENT_TESTSUITE_KEY, $sCurrentTestSuiteCalled)
Endif
lvwTestSuites[CURRENT_TESTSUITE_KEY].Selected = True
End
Public Sub btnDeleteTestSuite_Click()
DeleteTestSuite()
End
Public Sub btnRenameTestSuite_Click()
Dim sOldName, sNewName, sTests As String
If lvwTestSuites.Key <> CURRENT_TESTSUITE_KEY And If lvwTestSuites.Key <> "*" Then
sNewName = InputBox((Subst("Please enter new name for &1", lvwTestSuites.Key)), ("Rename Test Suite"), lvwTestSuites.Key)
If sNewName And If sNewName <> lvwTestSuites.Key Then
sOldName = lvwTestSuites.Key
sTests = $MySettings["Testsuite " & lvwTestSuites.Key & "/Tests"]
$MySettings["Testsuite " & sNewName & "/Tests"] = sTests
$MySettings["Testsuite " & lvwTestSuites.Key & "/Tests"] = Null
If $MySettings["CurrentTestsuite"] = sOldName Then
$MySettings["CurrentTestsuite"] = sNewName
Endif
$MySettings.Save()
FillTestSuites
Endif
Endif
End
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,148,98)
Text = ("Choose Tests to be run with F4")
Arrangement = Arrange.Vertical
Spacing = True
Margin = True
{ splSelectTests HSplit
MoveScaled(1,1,116,62)
Expand = True
{ panTestSuites VBox
MoveScaled(2,6,31,41)
{ lblSuites Label
MoveScaled(1,1,24,4)
Text = ("Test Suites")
}
{ lvwTestSuites ListView
MoveScaled(1,7,29,22)
ToolTip = ("Hit Del to delete a test suite.")
Expand = True
}
{ HBox1 HBox
MoveScaled(1,35,29,4)
{ btnDeleteTestSuite Button
MoveScaled(0,0,13,4)
NoTabFocus = True
ToolTip = ("Delete test suite (Del)")
AutoResize = True
Text = ("Delete")
}
{ btnRenameTestSuite Button
MoveScaled(14,0,14,4)
NoTabFocus = True
ToolTip = ("Rename test suite")
AutoResize = True
Text = ("Rename")
}
}
}
{ panSelectTests VBox
MoveScaled(43,11,56,31)
Expand = True
{ lblSelect Label
MoveScaled(2,0,24,4)
Text = ("Select tests")
}
{ tvwTests TreeView
MoveScaled(2,10,46,16)
NoTabFocus = True
Expand = True
Mode = Select.Multiple
ShowCheck = True
}
}
}
{ panSelectedTests VBox
MoveScaled(1,64,116,21)
Spacing = True
{ lblSelected Label
MoveScaled(0,0,35,4)
Text = ("Selected tests (current testsuite)")
}
{ txtSelected TextArea
MoveScaled(0,4,112,11)
NoTabFocus = True
Expand = True
ReadOnly = True
Wrap = True
}
{ panSave HBox
MoveScaled(1,16,109,4)
Spacing = True
Invert = True
{ btnSave Button
MoveScaled(76,0,16,4)
Text = ("Save")
}
{ txtNameTestSuite TextBox
MoveScaled(51,0,24,4)
}
{ lblStoreas Label
MoveScaled(7,0,43,4)
Text = ("Store this testsuite as:")
Alignment = Align.Right
}
}
}
}
......@@ -40,18 +40,18 @@
}
{ mnuAdvanced Menu
Text = ("Advanced")
{ mnuLowerCase Menu
Action = ".lcase"
Text = ("Lower case")
Picture = Picture["img/16/lcase.png"]
Shortcut = "Ctrl+Shift+L"
}
{ mnuUpperCase Menu
Action = ".ucase"
Text = ("Upper case")
Picture = Picture["img/16/ucase.png"]
Picture = Picture["icon:/small/text-upper"]
Shortcut = "Ctrl+Shift+U"
}
{ mnuLowerCase Menu
Action = ".lcase"
Text = ("Lower case")
Picture = Picture["icon:/small/text-lower"]
Shortcut = "Ctrl+Shift+L"
}
{ Menu2 Menu
}
{ mnuComment Menu
......@@ -625,7 +625,7 @@
{ Action lcase
Text = "Lower case"
Shortcut = "Ctrl+Shift+L"
Picture = "img/16/lcase.png"
Picture = "icon:/small/text-lower"
}
{ Action locked
Text = "Locked"
......@@ -700,7 +700,7 @@
{ Action ucase
Text = "Upper case"
Shortcut = "Ctrl+Shift+U"
Picture = "img/16/ucase.png"
Picture = "icon:/small/text-upper"
}
{ Action uncomment
Text = "Uncomment"
......
......@@ -44,13 +44,13 @@
{ mnuUpperCase Menu
Action = ".ucase"
Text = ("Upper case")
Picture = Picture["img/16/ucase.png"]
Picture = Picture["icon:/small/text-upper"]
Shortcut = "Ctrl+Alt+U"
}
{ mnuLowerCase Menu
Action = ".lcase"
Text = ("Lower case")
Picture = Picture["img/16/lcase.png"]
Picture = Picture["icon:/small/text-lower"]
Shortcut = "Ctrl+Alt+L"
}
{ Menu6 Menu
......@@ -607,7 +607,7 @@
{ Action lcase
Text = "Lower case"
Shortcut = "Ctrl+Alt+L"
Picture = "img/16/lcase.png"
Picture = "icon:/small/text-lower"
}
{ Action locked
Text = "Locked"
......@@ -696,7 +696,7 @@
{ Action ucase
Text = "Upper case"
Shortcut = "Ctrl+Alt+U"
Picture = "img/16/ucase.png"
Picture = "icon:/small/text-upper"
}
{ Action uncomment
Text = "Uncomment"
......
......@@ -201,11 +201,13 @@ text-center actions/format-justify-center
text-fill actions/format-justify-fill
text-italic actions/format-text-italic
text-left actions/format-justify-left
text-lower actions/format-text-lowercase
text-middle actions/format-align-vertical-center
text-right actions/format-justify-right
text-strike actions/format-text-strikethrough
text-top actions/format-align-vertical-top
text-underline actions/format-text-underline
text-upper actions/format-text-uppercase
tools [elementary]categories/applications-developmenent;[breeze*]categories/applications-system;actions/applications-system;categories/applications-system
top actions/go-top
transparency #
......