tests/VDBInstructionListApplicationTests.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 10 Jun 2019 15:22:49 +0100
changeset 166 d55f55ac977b
parent 164 364ebdd1d42c
permissions -rw-r--r--
plugins/bee: add symbol filter to quickly search through (possibly long) list of symbols.

"
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 }"

VDBAbstractApplicationTests subclass:#VDBInstructionListApplicationTests
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-UI-Others-Tests'
!

!VDBInstructionListApplicationTests 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/
"
! !

!VDBInstructionListApplicationTests methodsFor:'tests'!

test_01a
    | stack frameHolder |

    debugger := GDBDebugger new.
    self assert: debugger isConnected.

    frameHolder := ValueHolder new.
    application := VDBInstructionListApplication new.
    application debuggerHolder: (ValueHolder with: debugger).
    application disassemblableHolder: frameHolder.  
    application frameHolder: frameHolder.  
    application open.


    debugger executable: GDBDebuggeesResource current binaryFactorial1.
    debugger send: 'b factorial'.
    debugger send: 'r' andWaitFor: GDBStoppedEvent.
    debugger send: 'c' andWaitFor: GDBStoppedEvent.

    stack := debugger selectedInferior threads first stack.
    self assert: stack size = 3.

    frameHolder value: stack first.

    debugger send: 'stepi' andWaitFor: GDBStoppedEvent.
    debugger send: 'next' andWaitFor: GDBStoppedEvent.
    debugger send: 'd'.

    frameHolder value: nil.
    
    debugger send: 'c' andWaitFor: GDBThreadGroupExitedEvent.

    "Created: / 03-10-2018 / 12:27:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 12-06-2019 / 15:54:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_01b
    | stack frameHolder |

    debugger := GDBDebugger new.
    self assert: debugger isConnected.

    frameHolder := ValueHolder new.
    application := VDBInstructionListApplication new.
    application debuggerHolder: (ValueHolder with: debugger).
    application disassemblableHolder: frameHolder.  
    application frameHolder: frameHolder.  
    application allButOpen.


    debugger executable: GDBDebuggeesResource current binaryFactorial1.
    debugger send: 'b factorial'.
    debugger send: 'r' andWaitFor: GDBStoppedEvent.
    debugger send: 'c' andWaitFor: GDBStoppedEvent.

    stack := debugger selectedInferior threads first stack.
    self assert: stack size = 3.

    frameHolder value: stack first.

    debugger send: 'stepi' andWaitFor: GDBStoppedEvent.
    debugger send: 'next' andWaitFor: GDBStoppedEvent.
    debugger send: 'd'.
    debugger send: 'c' andWaitFor: GDBThreadGroupExitedEvent.

    "Created: / 03-10-2018 / 12:27:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 12-06-2019 / 15:54:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_02
    "
    This test tests that contents is not updated when
    listView is not visible and gets update when it becomes
    visible.
    "

    | stack frameHolder internalListView |

    debugger := GDBDebugger new.
    self assert: debugger isConnected.

    frameHolder := ValueHolder new.
    application := VDBInstructionListApplication new.
    application debuggerHolder: (ValueHolder with: debugger).
    application disassemblableHolder: frameHolder.  
    application frameHolder: frameHolder.  
    application open.
    application window waitUntilVisible.
    internalListView := application instVarNamed: #internalListView.
    debugger executable: GDBDebuggeesResource current binaryFactorial1.
    debugger send: 'b factorial'.
    debugger send: 'r' andWaitFor: GDBStoppedEvent.
    debugger send: 'c' andWaitFor: GDBStoppedEvent.

    stack := debugger selectedInferior threads first stack.
    self assert: stack size = 3.

    "/ List visible, no frame set, so list should 
    "/ be empty.
    self assert: frameHolder value isNil.
    self assert: internalListView shown.
    self assert: internalListView list isEmpty.

    "/ List visible, set a frame, list should get
    "/ updated and should contain some instructions
    frameHolder value: stack first.
    self waitForUIToStabilize.

    self assert: frameHolder value notNil.
    self assert: internalListView shown.
    self assert: internalListView list notEmpty.

    "/ List visible, set frame to nil, list should 
    "/ become empty.
    frameHolder value: nil.
    self waitForUIToStabilize.

    self assert: frameHolder value isNil.
    self assert: internalListView shown.
    self assert: internalListView list isEmpty.

    "/ Hide the list and set frame, list should
    "/ stay empty (i.e., not updated)
    application window beInvisible.
    frameHolder value: stack first.
    self waitForUIToStabilize.

    self assert: frameHolder value notNil.
    self assert: internalListView shown not.
    self assert: internalListView list isEmpty.

    "/ Show the list, contents should get
    "/ updated.
    application window beVisible.
    internalListView waitUntilVisible.
    self waitForUIToStabilize.

    self assert: frameHolder value notNil.
    self assert: internalListView shown.
    self assert: internalListView list notEmpty.

    debugger send: 'd'.
    debugger send: 'c' andWaitFor: GDBThreadGroupExitedEvent.
    self waitForUIToStabilize.

    "Created: / 23-01-2019 / 16:28:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 12-06-2019 / 16:13:36 / jv"
    "Modified: / 12-06-2019 / 16:15:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBInstructionListApplicationTests class methodsFor:'documentation'!

version_HG

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