Skip to content
Permalink
Browse files

Merge pull request #671 from tesonep/making-tests-to-use-adapters

Making tests to use adapters
  • Loading branch information...
tesonep committed Jul 26, 2019
2 parents d46e348 + f7932a7 commit 715050c5091217ce6303b1ee8bea8374fd21d17f
@@ -72,7 +72,7 @@ SpMorphicListAdapter >> hasFilter [
]

{ #category : #testing }
SpMorphicListAdapter >> isEditableRow: aRow column: aColumn [
SpMorphicListAdapter >> isNonEditableRow: aRow column: aColumn [

^ (self widget dataSource
cellColumn: (self widget columns at: aColumn)
@@ -182,6 +182,12 @@ SpMorphicListAdapter >> selectIndex: anInteger [
widget selectIndex: anInteger
]

{ #category : #testing }
SpMorphicListAdapter >> selectedIndexes [

^ widget selectedIndexes
]

{ #category : #factory }
SpMorphicListAdapter >> selectionChanged: ann [
| diff |
@@ -52,6 +52,11 @@ SpMorphicTableAdapter >> buildWidget [
^ widget
]

{ #category : #testing }
SpMorphicTableAdapter >> columns [
^ widget columns
]

{ #category : #factory }
SpMorphicTableAdapter >> defaultColumn [

@@ -65,7 +70,7 @@ SpMorphicTableAdapter >> ensureAtLeastOneColumnIn: tableMorph [
]

{ #category : #testing }
SpMorphicTableAdapter >> isEditableRow: aRow column: aColumn [
SpMorphicTableAdapter >> isNonEditableRow: aRow column: aColumn [

^ (self widget dataSource
cellColumn: (self widget columns at: aColumn)
@@ -167,6 +172,12 @@ SpMorphicTableAdapter >> selectIndex: anInteger [
widget selectIndex: anInteger
]

{ #category : #testing }
SpMorphicTableAdapter >> selectedIndexes [

^ widget selectedIndexes
]

{ #category : #factory }
SpMorphicTableAdapter >> selectionChanged: ann [
| diff selection |
@@ -161,7 +161,7 @@ SpAbstractAdapterTestCase >> testVisibilityWithBlock [
]

{ #category : #running }
SpAbstractAdapterTestCase >> testVisibilityWithBlock2 [
SpAbstractAdapterTestCase >> testVisibilityWithBlockThatReturnsFalse [
presenter visibleIf: [ false ].
self deny: self adapter isVisible
]
@@ -34,26 +34,26 @@ SpAbstractListAdapterMultipleSelectionTest >> testSelectManyIndexesKeepsAllSelec
presenter selectIndex: 1.
presenter selectIndex: 2.
self
assert: self widget selectedIndexes asArray
assert: self adapter selectedIndexes asArray
equals: #(1 2)
]

{ #category : #'tests-model-to-widget' }
SpAbstractListAdapterMultipleSelectionTest >> testSelectPresenterIndexOutsideRangeUnsetsSelectedIndexInWidget [
presenter selectIndex: 100.
self assert: self widget selectedIndexes isEmpty
self assert: self adapter selectedIndexes isEmpty
]

{ #category : #'tests-model-to-widget' }
SpAbstractListAdapterMultipleSelectionTest >> testSelectPresenterIndexSetsSelectedIndexInWidget [
presenter selectIndex: 1.
self assert: (self widget selectedIndexes includes: 1)
self assert: (self adapter selectedIndexes includes: 1)
]

{ #category : #'tests-model-to-widget' }
SpAbstractListAdapterMultipleSelectionTest >> testSelectPresenterItemSetsSelectedIndexInWidget [
presenter selectItem: 20.
self assert: (self widget selectedIndexes includes: 2)
self assert: (self adapter selectedIndexes includes: 2)
]

{ #category : #'tests-widget-to-model' }
@@ -62,7 +62,7 @@ SpAbstractListAdapterMultipleSelectionTest >> testSelectWidgetIndexRaisesSelecti
counter := 0.
presenter selection
whenChangedDo: [ :selection | counter := counter + 1 ].
self widget selectIndex: 1.
self adapter selectIndex: 1.
self assert: counter equals: 1
]

@@ -71,14 +71,14 @@ SpAbstractListAdapterMultipleSelectionTest >> testSelectWidgetIndexRaisesSelecti
| selectedIndex |
presenter selection
whenChangedDo: [ :selection | selectedIndex := selection selectedIndexes ].
self widget selectIndex: 1.
self adapter selectIndex: 1.
self assert: (selectedIndex includes: 1)
]

{ #category : #'tests-widget-to-model' }
SpAbstractListAdapterMultipleSelectionTest >> testStringColumnsShouldBeNonEditable [

self assert: (self adapter isEditableRow: 4 column: 1)
self assert: (self adapter isNonEditableRow: 4 column: 1)
]

{ #category : #'tests-widget-to-model' }
@@ -91,7 +91,7 @@ SpAbstractListAdapterMultipleSelectionTest >> testSubscribeToEventDoesNotRaiseEv
{ #category : #'tests-widget-to-model' }
SpAbstractListAdapterMultipleSelectionTest >> testUnselectAllInWidgetRaisesEmptySelectionChangeEvent [
| gotSelection |
self widget selectIndex: 1.
self adapter selectIndex: 1.
presenter selection
whenChangedDo: [ :selection | gotSelection := selection ].
self adapter selectIndex: 0.
@@ -102,7 +102,7 @@ SpAbstractListAdapterMultipleSelectionTest >> testUnselectAllInWidgetRaisesEmpty
SpAbstractListAdapterMultipleSelectionTest >> testUnselectAllInWidgetRaisesSelectionIndexChangeEventOnce [
| counter |
counter := 0.
self widget selectIndex: 1.
self adapter selectIndex: 1.
presenter selection
whenChangedDo: [ :selection | counter := counter + 1 ].
self adapter selectIndex: 0.
@@ -24,25 +24,25 @@ SpAbstractListAdapterSingleSelectionTest >> initializeTestedInstance [
SpAbstractListAdapterSingleSelectionTest >> testSelectManyIndexesKeepsLastSelectionInWidget [
presenter selectIndex: 1.
presenter selectIndex: 2.
self assert: self widget selectedIndexes equals: #(2)
self assert: self adapter selectedIndexes equals: #(2)
]

{ #category : #'tests-model-to-widget' }
SpAbstractListAdapterSingleSelectionTest >> testSelectPresenterIndexOutsideRangeUnsetsSelectedIndexInWidget [
presenter selectIndex: 100.
self assert: self widget selectedIndexes isEmpty
self assert: self adapter selectedIndexes isEmpty
]

{ #category : #'tests-model-to-widget' }
SpAbstractListAdapterSingleSelectionTest >> testSelectPresenterIndexSetsSelectedIndexInWidget [
presenter selectIndex: 1.
self assert: (self widget selectedIndexes includes: 1)
self assert: (self adapter selectedIndexes includes: 1)
]

{ #category : #'tests-model-to-widget' }
SpAbstractListAdapterSingleSelectionTest >> testSelectPresenterItemSetsSelectedIndexInWidget [
presenter selectItem: 20.
self assert: (self widget selectedIndexes includes: 2)
self assert: (self adapter selectedIndexes includes: 2)
]

{ #category : #'tests-widget-to-model' }
@@ -60,7 +60,7 @@ SpAbstractListAdapterSingleSelectionTest >> testSelectWidgetIndexRaisesSelection
| selectedIndex |
presenter selection
whenChangedDo: [ :selection | selectedIndex := selection selectedIndex ].
self widget selectIndex: 1.
self adapter selectIndex: 1.
self assert: selectedIndex equals: 1
]

@@ -95,15 +95,15 @@ SpAbstractListAdapterSingleSelectionTest >> testUnselectPresenterIndexUnselectsI
presenter
selectIndex: 1;
unselectIndex: 1.
self assert: self widget selectedIndexes isEmpty
self assert: self adapter selectedIndexes isEmpty
]

{ #category : #'tests-model-to-widget' }
SpAbstractListAdapterSingleSelectionTest >> testUnselectPresenterItemUnselectsIndexInWidget [
presenter
selectItem: 20;
unselectItem: 20.
self assert: self widget selectedIndexes isEmpty
self assert: self adapter selectedIndexes isEmpty
]

{ #category : #'tests-widget-to-model' }
@@ -20,7 +20,7 @@ SpAbstractListCommonPropertiestTest >> testChangeListInPresenterUpdatesWidget [

self presenter items: #( '1' '2' '3').

backendForTest assertList: self widget displayItems: #('1' '2' '3')
backendForTest assertList: self adapter displayItems: #('1' '2' '3')
]

{ #category : #running }
@@ -31,7 +31,7 @@ SpAbstractListCommonPropertiestTest >> testDoubleClickActivatesRowInDoubleClickA
self presenter activateOnDoubleClick.
self presenter whenActivatedDo: [ activated := true ].

backendForTest doubleClickFirstRowAndColumn: self widget.
backendForTest doubleClickFirstRowAndColumn: self adapter.

self assert: activated
]
@@ -55,7 +55,7 @@ SpAbstractListCommonPropertiestTest >> testSingleClickActivatesRowInSingleClickA
activateOnSingleClick;
whenActivatedDo: [ activated := true ].

backendForTest clickFirstRowAndColumn: self widget.
backendForTest clickFirstRowAndColumn: self adapter.

self assert: activated.
]
@@ -31,7 +31,7 @@ SpAbstractTreeTableAdapterTest >> testChangingRootsUpdateWidget [

self presenter roots: #(10 11 12).

backendForTest assertList: self adapter widget displayItems: #('10' '11' '12').
backendForTest assertList: self adapter displayItems: #('10' '11' '12').


]
@@ -92,7 +92,7 @@ SpAbstractTreeTableAdapterTest >> testShowingColumnDisplayColumn [

self presenter showColumnHeaders.

backendForTest assertHasHeader: self adapter widget
backendForTest assertHasHeader: self adapter
]

{ #category : #running }
@@ -20,8 +20,12 @@ SpImageAdapterTest >> imageForm [

{ #category : #building }
SpImageAdapterTest >> testAutoscale [

self presenter image: self imageForm.

self presenter autoScale: false.
self deny: self adapter hasImageAutoscaled.

self presenter autoScale: true.
self assert: self adapter hasImageAutoscaled.

@@ -41,7 +41,7 @@ SpListCommonPropertiestTest >> testRemoveHeaderTitleInPresenterRemovesColumnHead
self presenter headerTitle: 'test'.
self presenter hideHeaderTitle.

backendForTest denyHasHeader: self widget
backendForTest denyHasHeader: self adapter
]

{ #category : #running }
@@ -54,7 +54,7 @@ SpListCommonPropertiestTest >> testSetColumnTitleInPresenterPutsColumnHeaderMorp

self presenter headerTitle: 'test'.

backendForTest assertListHeaderOf: self widget equals: #('test')
backendForTest assertListHeaderOf: self adapter equals: #('test')
]

{ #category : #running }
@@ -9,10 +9,10 @@ Class {
}

{ #category : #asserting }
SpMorphicBackendForTest >> assertHasHeader: aFTTableMorph [
SpMorphicBackendForTest >> assertHasHeader: anAdapter [
self waitUntilUIRedrawed.

self assert: (aFTTableMorph instVarNamed: #showColumnHeaders)
self assert: (anAdapter widget instVarNamed: #showColumnHeaders)
]

{ #category : #asserting }
@@ -32,13 +32,13 @@ SpMorphicBackendForTest >> assertImage: actual equals: expected [
]

{ #category : #asserting }
SpMorphicBackendForTest >> assertList: aFTTableMorph displayItems: aCollection [
SpMorphicBackendForTest >> assertList: anAdapter displayItems: aCollection [

| tableContainer tableRowContents |

self waitUntilUIRedrawed.

tableContainer := aFTTableMorph submorphs first.
tableContainer := anAdapter widget submorphs first.
tableRowContents := tableContainer submorphs collect: [ :row |
| cell |
cell := row submorphs first.
@@ -50,13 +50,13 @@ SpMorphicBackendForTest >> assertList: aFTTableMorph displayItems: aCollection [
]

{ #category : #asserting }
SpMorphicBackendForTest >> assertListHeaderOf: aFTTableMorph equals: aCollection [
SpMorphicBackendForTest >> assertListHeaderOf: anAdapter equals: aCollection [

| tableContainer tableRowMorph cells |

self waitUntilUIRedrawed.

tableContainer := aFTTableMorph submorphs first.
tableContainer := anAdapter widget submorphs first.
tableRowMorph := tableContainer submorphs first.
cells := tableRowMorph submorphs.

@@ -70,34 +70,34 @@ SpMorphicBackendForTest >> canChangeFonts [
]

{ #category : #emulating }
SpMorphicBackendForTest >> clickFirstRowAndColumn: aFTTableMorph [
SpMorphicBackendForTest >> clickFirstRowAndColumn: anAdapter [

self waitUntilUIRedrawed.

aFTTableMorph mouseDown: (MouseEvent new
anAdapter widget mouseDown: (MouseEvent new
setHand: HandMorph new;
setPosition: aFTTableMorph submorphs first submorphs first bounds center;
setPosition: anAdapter widget submorphs first submorphs first bounds center;
yourself).

]

{ #category : #asserting }
SpMorphicBackendForTest >> denyHasHeader: aFTTableMorph [
SpMorphicBackendForTest >> denyHasHeader: anAdapter [

| tableContainer |
self waitUntilUIRedrawed.

tableContainer := aFTTableMorph submorphs first.
tableContainer := anAdapter widget submorphs first.
self assert: tableContainer submorphs size = 3
]

{ #category : #simulating }
SpMorphicBackendForTest >> doubleClickFirstRowAndColumn: aFTTableMorph [
SpMorphicBackendForTest >> doubleClickFirstRowAndColumn: anAdapter [

self waitUntilUIRedrawed.

aFTTableMorph doubleClick: (MouseEvent new
setPosition: aFTTableMorph submorphs first submorphs first bounds center;
anAdapter widget doubleClick: (MouseEvent new
setPosition: anAdapter widget submorphs first submorphs first bounds center;
yourself).

]
@@ -27,7 +27,7 @@ SpTableCommonPropertiestTest >> testAddColumnInPresenterAddsItToWidget [
self presenter
addColumn: newColumn.

self assert: self widget columns last id equals: newColumn title
self assert: self adapter columns last id equals: newColumn title
]

{ #category : #tests }
@@ -41,7 +41,7 @@ SpTableCommonPropertiestTest >> testHideColumnHeadersInPresenterHidesThemInWidge
{ #category : #tests }
SpTableCommonPropertiestTest >> testListWithoutColumnsHasSingleColumn [

self assert: self widget columns size equals: 1
self assert: self adapter columns size equals: 1
]

{ #category : #tests }
@@ -46,11 +46,13 @@ SpSearchableList class >> isDeprecated [
{ #category : #initialization }
SpSearchableList >> initializePresenter [
searchPresenter
whenTextChangedDo:
[ :newText |
searchPresenter getText asLowercase
whenTextChangedDo: [ :newText |
searchPresenter text asLowercase
ifEmpty: [ listPresenter items: baseItems ]
ifNotEmpty: [ :text | listPresenter items: (baseItems select: [ :element | element asLowercase beginsWith: text ]) ] ]
ifNotEmpty: [ :text |
listPresenter
items:
(baseItems select: [ :element | element asLowercase beginsWith: text ]) ] ]
]

{ #category : #initialization }

0 comments on commit 715050c

Please sign in to comment.
You can’t perform that action at this time.