tests/VDBSimpleConsoleViewTest.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 13 Mar 2019 14:07:49 +0000
changeset 149 adaffe052a41
parent 143 df7f89efd39d
child 170 cd9615ebe6a9
permissions -rw-r--r--
Show log output in simple console This needed because, for example, python errors and stacktrace is reported on log stream, not on output stream.

"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
"{ Package: 'jv:vdb/tests' }"

"{ NameSpace: Smalltalk }"

TestCase subclass:#VDBSimpleConsoleViewTest
	instanceVariableNames:'preferences console consoleI'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-UI-Console-Tests'
!

!VDBSimpleConsoleViewTest class methodsFor:'documentation'!

copyright
"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
! !

!VDBSimpleConsoleViewTest methodsFor:'running'!

setUp
    | window |

    super setUp.
    Screen current isNil ifTrue:[
        Smalltalk openDisplay
    ].
    self skipIf:Screen current isNil description:'No display connection'.
    Smalltalk loadPackage:'stx:goodies/sunit/ext/ui'.
    window := StandardSystemView new.
    window extent:320 @ 200.
    window label:self printString.
    console := VDBSimpleConsoleView 
            origin:0.0 @ 0.0
            extent:1.0 @ 1.0
            in:window.
    window open.
    window waitUntilVisible.
    consoleI := console interactor

    "Modified: / 16-01-2019 / 10:24:12 / jv"
    "Modified: / 25-01-2019 / 09:34:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

tearDown
    super tearDown.
    console topView destroy.

    "Created: / 28-09-2018 / 08:29:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 16-01-2019 / 16:23:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBSimpleConsoleViewTest methodsFor:'tests - basic'!

test_basic_01

    console show: '(gdb) '.
    self assert: console list first = '(gdb) '.
    self assert: console cursorCol = 7.

    consoleI type: 'b main'.
    self assert: console list first = '(gdb) b main'.
    self assert: console cursorCol = 13.

    consoleI type: #BackSpace.
    self assert: console list first = '(gdb) b mai'.
    self assert: console cursorCol = 12.

    consoleI type: #CursorLeft.
    self assert: console list first = '(gdb) b mai'.
    self assert: console cursorCol = 11.

    consoleI type: 'x'.
    self assert: console list first = '(gdb) b maxi'.
    self assert: console cursorCol = 12.

    consoleI type: #Delete.
    self assert: console list first = '(gdb) b max'.
    self assert: console cursorCol = 12.

    consoleI type: #CursorRight.
    self assert: console list first = '(gdb) b max'.
    self assert: console cursorCol = 12.

    consoleI type: #BeginOfLine.
    self assert: console list first = '(gdb) b max'.
    self assert: console cursorCol = 7.

    consoleI type: #CursorRight.
    self assert: console list first = '(gdb) b max'.
    self assert: console cursorCol = 8.
    
    consoleI type: 'r'.
    self assert: console list first = '(gdb) br max'.
    self assert: console cursorCol = 9.

    consoleI type: #EndOfLine.
    self assert: console list first = '(gdb) br max'.
    self assert: console cursorCol = 13.

    consoleI type: '('.
    self assert: console list first = '(gdb) br max('.
    self assert: console cursorCol = 14.

    "Created: / 25-01-2019 / 09:37:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 25-01-2019 / 11:42:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBSimpleConsoleViewTest methodsFor:'tests - obsolete'!

test_completion_01
    console completeAction:[ :partial | 
        console completions: #('finish')
    ].
    consoleI type: 'fi'.
    consoleI type: #Tab.
    self assert: console list first asString = 'finish'.

    "Created: / 25-01-2019 / 22:47:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_completion_02

    console completeAction:[ :partial | 
        console completions:     
            (#('file' 'finish') select: [ :each | each startsWith: partial ]).
    ].
    consoleI type: 'f'.
    consoleI type: #Tab.
    self assert: console list first asString = 'fi'.

    consoleI type: 'l'.
    consoleI type: #Tab.
    self assert: console list first asString = 'file'.

    "Created: / 25-01-2019 / 22:48:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_completion_03
    console show: '-> '.

    console completeAction:[ :partial | 
        console completions:     
            (#('file' 'finish') select: [ :each | each startsWith: partial ]).
    ].
    consoleI type: 'f'.
    consoleI type: #Tab.
    consoleI type: #Tab.
    self assert: (console list at: 1) asString = '-> fi'.
    self assert: (console list at: 2) asString = 'file'.
    self assert: (console list at: 3) asString = 'finish'.
    self assert: (console list at: 4) asString = '-> fi'.

    consoleI type: 'n'.
    consoleI type: #Tab.
    self assert: (console list at: 4) asString = '-> finish'.

    "Created: / 25-01-2019 / 22:48:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBSimpleConsoleViewTest class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !