Faculty of Information Technology
Software Engineering Group

Ticket #165: libwidg_fix_1_of_1_rev_7e214afed3b8_Issue__165__Added_tests_for___trimBlankLines__option.patch

File libwidg_fix_1_of_1_rev_7e214afed3b8_Issue__165__Added_tests_for___trimBlankLines__option.patch, 6.9 KB (added by Jan Vrany, 5 years ago)
  • tests/EditTextViewTests.st

    # HG changeset patch
    # User Jan Vrany <jan.vrany@fit.cvut.cz>
    # Date 1506426001 -7200
    #      Tue Sep 26 13:40:01 2017 +0200
    # Branch jv
    # Node ID 7e214afed3b8fe0709a8854360eab7a0479d563f
    # Parent  e301f5bd90b1f568837a4e095c1734d04968c489
    Issue #165: Added tests for `#trimBlankLines` option
    
    https://swing.fit.cvut.cz/projects/stx-jv/ticket/165
    
    diff -r e301f5bd90b1 -r 7e214afed3b8 tests/EditTextViewTests.st
    a b  
    3737    textView topView destroy.
    3838
    3939    "Created: / 23-07-2014 / 07:17:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    40     "Modified: / 24-02-2015 / 08:17:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     40    "Modified: / 04-10-2017 / 23:07:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    4141! !
    4242
    4343!EditTextViewTests methodsFor:'tests'!
     
    5757    "Created: / 24-02-2015 / 08:21:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    5858!
    5959
     60test_02a
     61    "Checking if white spaces on a blank line are preserved. Scenario:
     62     1) ensures trimBlankLines is set to false
     63     2) enter white spaces and a text at the end
     64     3) move cursor to end of white spaces
     65     4) press return
     66     5) move cursor to next line
     67     6) press backspace
     68     7) assert: that textView contents returns text
     69        including white spaces at the beginning"
     70
     71    |wasOn|
     72
     73    textView trimBlankLines: false.
     74   
     75    textViewInteractor type:Character space.
     76    textViewInteractor type:Character space.
     77    textViewInteractor type:Character space.
     78    textViewInteractor type:'test'.
     79
     80    wasOn := textView hideCursor.
     81    textView setCursorCol:4.
     82    wasOn ifTrue:[
     83        textView showCursor
     84    ].
     85
     86    textViewInteractor type:#Return.
     87
     88    wasOn := textView hideCursor.
     89    textView setCursorLine:2.
     90    textView setCursorCol:1.
     91    wasOn ifTrue:[
     92        textView showCursor
     93    ].
     94
     95    textViewInteractor type:#BackSpace.
     96
     97    MessageTracer unwrapMethod:(UserPreferences instanceBehavior compiledMethodAt:#trimBlankLines).
     98
     99    self assert:textView contents asString = ('   test' , Character cr).
     100
     101    "Created: / 26-09-2017 / 11:24:34 / svestkap"
     102    "Modified: / 04-10-2017 / 23:05:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     103!
     104
     105test_02b
     106    "Checking if white spaces on a blank line are preserved. Scenario:
     107     1) ensures trimBlankLines is set to true
     108     2) enter white spaces and a text at the end
     109     3) move cursor to end of white spaces
     110     4) press return
     111     5) move cursor to next line
     112     6) press backspace
     113     7) assert: that textView contents returns text
     114        disregarding white spaces at the beginning"
     115   
     116    |wasOn|
     117
     118   textView trimBlankLines: true.   
     119
     120    textViewInteractor type:Character space.
     121    textViewInteractor type:Character space.
     122    textViewInteractor type:Character space.
     123    textViewInteractor type:'test'.
     124
     125    wasOn := textView hideCursor.
     126    textView setCursorCol:4.
     127    wasOn ifTrue:[
     128        textView showCursor
     129    ].
     130
     131    textViewInteractor type:#Return.
     132
     133    wasOn := textView hideCursor.
     134    textView setCursorLine:2.
     135    textView setCursorCol:1.
     136    wasOn ifTrue:[
     137        textView showCursor
     138    ].
     139
     140    textViewInteractor type:#BackSpace.
     141
     142
     143    self assert:textView contents asString = ('test' , Character cr).
     144
     145    "Created: / 26-09-2017 / 11:46:54 / svestkap"
     146    "Modified: / 04-10-2017 / 23:05:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     147!
     148
     149test_02c
     150    "Checking if white spaces on a blank line are preserved. Scenario:
     151     1) ensures trimBlankLines is set to false
     152     2) enter text with String crlf in the middle, which moves
     153        the text after crlf to next line
     154     3) move cursor to end first line
     155     4) enter white spaces
     156     5) move cursor to the next line
     157     6) press backspace
     158     7) assert: that textView contents returns a text
     159        which should contain number of white spaces entered"
     160
     161    |wasOn|
     162
     163   textView 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
     188    self assert:textView contents asString = ('This text is to   continue', String crlf).
     189
     190    "Created: / 17-08-2017 / 09:23:10 / svestkap"
     191    "Modified: / 26-09-2017 / 12:00:17 / svestkap"
     192    "Modified: / 04-10-2017 / 23:05:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     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    textView trimBlankLines: true.                   
     210
     211    textView contents:'This text is to', String crlf, 'continue'.
     212
     213    wasOn := textView hideCursor.
     214    textView setCursorLine:1.
     215    textView setCursorCol:16.
     216    wasOn ifTrue:[
     217        textView showCursor
     218    ].
     219
     220    textViewInteractor type: Character space.
     221    textViewInteractor type: Character space.
     222    textViewInteractor type: Character space.
     223
     224    wasOn := textView hideCursor.
     225    textView setCursorLine:2.
     226    textView setCursorCol:1.
     227    wasOn ifTrue:[
     228        textView showCursor
     229    ].
     230
     231    textViewInteractor type: #BackSpace.
     232
     233    self assert:textView contents asString = ('This text is tocontinue', String crlf).
     234
     235    "Created: / 17-08-2017 / 09:23:10 / svestkap"
     236    "Modified: / 26-09-2017 / 12:00:17 / svestkap"
     237    "Modified: / 04-10-2017 / 23:05:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     238!
     239
    60240test_issue124_case1_01
    61241    "
    62242    See https://swing.fit.cvut.cz/projects/stx-jv/ticket/124#comment:19
     
    82262    See https://swing.fit.cvut.cz/projects/stx-jv/ticket/124#comment:19
    83263    "
    84264
     265    textView trimBlankLines: true.         
     266
    85267    textView contents:'1234'.
    86268    textView setCursorCol:3.
    87269    textView selectToEndOfLine.
     
    103285    self assert:textView contents asString = ('1234' , Character cr).
    104286
    105287    "Created: / 17-03-2017 / 09:48:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    106     "Modified: / 17-03-2017 / 14:13:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    107     "Modified (comment): / 04-05-2017 / 22:31:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     288    "Modified: / 04-10-2017 / 23:07:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    108289!
    109290
    110291test_issue124_case1_04