Faculty of Information Technology
Software Engineering Group

Ticket #165: libwidg_fix_1_of_1_rev_4dc6edccd6f7_Issue__165__Not_all_spaces_are_created_equal.patch

File libwidg_fix_1_of_1_rev_4dc6edccd6f7_Issue__165__Not_all_spaces_are_created_equal.patch, 6.5 KB (added by Patrik Svestka, 5 years ago)

Test cases for the new functionality

  • tests/EditTextViewTests.st

    # HG changeset patch
    # User Patrik Svestka <patrik.svestka@gmail.com>
    # Date 1506426001 -7200
    #      Tue Sep 26 13:40:01 2017 +0200
    # Branch jv
    # Node ID 4dc6edccd6f7248c575dba241aebe3bc32f15328
    # Parent  df5e0e50fe4ecdd8a23ff67ac7f8bf7503d36fea
    Issue #165: Not all spaces are created equal
    
    Test cases, using Mock tests, to test if the white spaces
    are deleted correctly using trimBlankLines options.
    
    
    https://swing.fit.cvut.cz/projects/stx-jv/ticket/165
    
    diff -r df5e0e50fe4e -r 4dc6edccd6f7 tests/EditTextViewTests.st
    a b  
    5555    "Created: / 24-02-2015 / 08:21:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    5656!
    5757
     58test_02a
     59    "Checking if white spaces on a blank line are preserved. Scenario:
     60     1) ensures trimBlankLines is set to false
     61     2) enter white spaces and a text at the end
     62     3) move cursor to end of white spaces
     63     4) press return
     64     5) move cursor to next line
     65     6) press backspace
     66     7) assert: that textView contents returns text
     67        including white spaces at the beginning"
     68
     69    |wasOn|
     70
     71    MessageTracer mockMethod:(UserPreferences instanceBehavior compiledMethodAt:#trimBlankLines)
     72        do:[:state | UserPreferences current trimBlankLines:false].
     73
     74    textViewInteractor type:Character space.
     75    textViewInteractor type:Character space.
     76    textViewInteractor type:Character space.
     77    textViewInteractor type:'test'.
     78
     79    wasOn := textView hideCursor.
     80    textView setCursorCol:4.
     81    wasOn ifTrue:[
     82        textView showCursor
     83    ].
     84
     85    textViewInteractor type:#Return.
     86
     87    wasOn := textView hideCursor.
     88    textView setCursorLine:2.
     89    textView setCursorCol:1.
     90    wasOn ifTrue:[
     91        textView showCursor
     92    ].
     93
     94    textViewInteractor type:#BackSpace.
     95
     96    MessageTracer unwrapMethod:(UserPreferences instanceBehavior compiledMethodAt:#trimBlankLines).
     97
     98    self assert:textView contents asString = ('   test' , Character cr).
     99
     100    "Created: / 26-09-2017 / 11:24:34 / svestkap"
     101!
     102
     103test_02b
     104    "Checking if white spaces on a blank line are preserved. Scenario:
     105     1) ensures trimBlankLines is set to true
     106     2) enter white spaces and a text at the end
     107     3) move cursor to end of white spaces
     108     4) press return
     109     5) move cursor to next line
     110     6) press backspace
     111     7) assert: that textView contents returns text
     112        disregarding white spaces at the beginning"
     113   
     114    |wasOn|
     115
     116    MessageTracer mockMethod:(UserPreferences instanceBehavior compiledMethodAt:#trimBlankLines)
     117        do:[:state | UserPreferences current trimBlankLines:true].
     118
     119    textViewInteractor type:Character space.
     120    textViewInteractor type:Character space.
     121    textViewInteractor type:Character space.
     122    textViewInteractor type:'test'.
     123
     124    wasOn := textView hideCursor.
     125    textView setCursorCol:4.
     126    wasOn ifTrue:[
     127        textView showCursor
     128    ].
     129
     130    textViewInteractor type:#Return.
     131
     132    wasOn := textView hideCursor.
     133    textView setCursorLine:2.
     134    textView setCursorCol:1.
     135    wasOn ifTrue:[
     136        textView showCursor
     137    ].
     138
     139    textViewInteractor type:#BackSpace.
     140
     141    MessageTracer unwrapMethod:(UserPreferences instanceBehavior compiledMethodAt:#trimBlankLines).
     142
     143    self assert:textView contents asString = ('test' , Character cr).
     144
     145    "Created: / 26-09-2017 / 11:46:54 / svestkap"
     146!
     147
     148test_02c
     149    "Checking if white spaces on a blank line are preserved. Scenario:
     150     1) ensures trimBlankLines is set to false
     151     2) enter text with String crlf in the middle, which moves
     152        the text after crlf to next line
     153     3) move cursor to end first line
     154     4) enter white spaces
     155     5) move cursor to the next line
     156     6) press backspace
     157     7) assert: that textView contents returns a text
     158        which should contain number of white spaces entered"
     159
     160    |wasOn|
     161
     162    MessageTracer mockMethod:(UserPreferences instanceBehavior compiledMethodAt:#trimBlankLines)
     163        do:[:state | UserPreferences current trimBlankLines:false].
     164
     165    textView contents:'This text is to', String crlf, 'continue'.
     166
     167    wasOn := textView hideCursor.
     168    textView setCursorLine:1.
     169    textView setCursorCol:16.
     170    wasOn ifTrue:[
     171        textView showCursor
     172    ].
     173
     174    textViewInteractor type: Character space.
     175    textViewInteractor type: Character space.
     176    textViewInteractor type: Character space.
     177
     178    wasOn := textView hideCursor.
     179    textView setCursorLine:2.
     180    textView setCursorCol:1.
     181    wasOn ifTrue:[
     182        textView showCursor
     183    ].
     184
     185    textViewInteractor type: #BackSpace.
     186
     187    MessageTracer unwrapMethod:(UserPreferences instanceBehavior compiledMethodAt:#trimBlankLines).
     188
     189    self assert:textView contents asString = ('This text is to   continue', String crlf).
     190
     191    "Created: / 17-08-2017 / 09:23:10 / svestkap"
     192    "Modified: / 26-09-2017 / 12:00:17 / svestkap"
     193!
     194
     195test_02d
     196    "Checking if white spaces on a blank line are preserved. Scenario:
     197     1) ensures trimBlankLines is set to true
     198     2) enter text with String crlf in the middle, which moves
     199        the text after crlf to next line
     200     3) move cursor to end first line
     201     4) enter white spaces
     202     5) move cursor to the next line
     203     6) press backspace
     204     7) assert: that textView contents returns a text
     205        disregarding the white spaces entered"
     206
     207    |wasOn|
     208
     209    MessageTracer mockMethod:(UserPreferences instanceBehavior compiledMethodAt:#trimBlankLines)
     210        do:[:state | UserPreferences current trimBlankLines:true].
     211
     212    textView contents:'This text is to', String crlf, 'continue'.
     213
     214    wasOn := textView hideCursor.
     215    textView setCursorLine:1.
     216    textView setCursorCol:16.
     217    wasOn ifTrue:[
     218        textView showCursor
     219    ].
     220
     221    textViewInteractor type: Character space.
     222    textViewInteractor type: Character space.
     223    textViewInteractor type: Character space.
     224
     225    wasOn := textView hideCursor.
     226    textView setCursorLine:2.
     227    textView setCursorCol:1.
     228    wasOn ifTrue:[
     229        textView showCursor
     230    ].
     231
     232    textViewInteractor type: #BackSpace.
     233
     234    MessageTracer unwrapMethod:(UserPreferences instanceBehavior compiledMethodAt:#trimBlankLines).
     235
     236    self assert:textView contents asString = ('This text is tocontinue', String crlf).
     237
     238    "Created: / 17-08-2017 / 09:23:10 / svestkap"
     239    "Modified: / 26-09-2017 / 12:00:17 / svestkap"
     240!
     241
    58242test_issue124_case1_01
    59243    "
    60244    See https://swing.fit.cvut.cz/projects/stx-jv/ticket/124#comment:19