Skip to content

Commit

Permalink
Fix #testActivateActionButtons for MiDuplicationBrowser.
Browse files Browse the repository at this point in the history
This browser needs some improvements.
  • Loading branch information
ClotildeToullec committed Sep 3, 2024
1 parent 9a78549 commit 6f97e0b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 29 deletions.
5 changes: 3 additions & 2 deletions src/MooseIDE-Duplication/MiDuplicationBrowser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ MiDuplicationBrowser >> list: collection1 hasSameElements: collection2 [

{ #category : #'accessing - private tests' }
MiDuplicationBrowser >> lstEntities [
^lstEntities

^ lstEntities
]

{ #category : #'accessing - private tests' }
Expand All @@ -204,7 +205,7 @@ MiDuplicationBrowser >> lstReplicatedFragments [
{ #category : #accessing }
MiDuplicationBrowser >> miSelectedItem [

^ specModel selectedEntities
^ specModel miSelectedItem
]

{ #category : #utilities }
Expand Down
31 changes: 19 additions & 12 deletions src/MooseIDE-Duplication/MiDuplicationBrowserModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ MiDuplicationBrowserModel >> initializeSettings [

{ #category : #api }
MiDuplicationBrowserModel >> isSelected: anEntity [
^selectedEntities includes: anEntity

^ selectedEntities includes: anEntity
]

{ #category : #settings }
Expand Down Expand Up @@ -183,7 +184,7 @@ MiDuplicationBrowserModel >> maxReplicasShowed [
{ #category : #accessing }
MiDuplicationBrowserModel >> miSelectedItem [

^selectedEntities
^ selectedEntities ifEmpty: [ entities ]
]

{ #category : #settings }
Expand Down Expand Up @@ -226,17 +227,21 @@ MiDuplicationBrowserModel >> numberOfEntities [

{ #category : #api }
MiDuplicationBrowserModel >> numberOfEntitiesInReplicas [
^(replicatedFragmentsHierarchy keys flatCollectAsSet: [ :fragment | fragment replicas collect: #entity ]) size

^ (replicatedFragmentsHierarchy keys flatCollectAsSet: [ :fragment |
fragment replicas collect: #entity ]) size
]

{ #category : #api }
MiDuplicationBrowserModel >> numberOfFragments [
^replicatedFragmentsHierarchy size

^ replicatedFragmentsHierarchy size
]

{ #category : #api }
MiDuplicationBrowserModel >> numberOfSelectedEntities [
^selectedEntities size

^ selectedEntities size
]

{ #category : #api }
Expand All @@ -263,23 +268,25 @@ MiDuplicationBrowserModel >> replicatedFragmentsHierarchy: aCollection [

{ #category : #api }
MiDuplicationBrowserModel >> rootFragments [

| children |
children := replicatedFragmentsHierarchy associations flatCollect: #value.
^replicatedFragmentsHierarchy keys reject: [ :fragment | children includes: fragment]

children := replicatedFragmentsHierarchy associations flatCollect:
#value.
^ replicatedFragmentsHierarchy keys reject: [ :fragment |
children includes: fragment ]
]

{ #category : #accessing }
MiDuplicationBrowserModel >> selectedEntities [
MiDuplicationBrowserModel >> selectEntities: entityCollection [

^selectedEntities
selectedEntities := entityCollection.
browser updateToolbar
]

{ #category : #accessing }
MiDuplicationBrowserModel >> selectedEntities: entityCollection [

selectedEntities := entityCollection.
"browser highlightEntity: selectedEntities."
browser updateToolbar
]

Expand All @@ -292,7 +299,7 @@ MiDuplicationBrowserModel >> selectedFragments: selectedFragments [
ifTrue: [ allReplicas first: (settings getItemValue: self maxReplicasShowed) ]
ifFalse: [ allReplicas ].

self selectedEntities:
self selectEntities:
(allReplicas collectAsSet: #entity) asMooseGroup.
browser showReplicas: allReplicas
]
Expand Down
12 changes: 8 additions & 4 deletions src/MooseIDE-Tests/MiDuplicationBrowserModelTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,16 @@ MiDuplicationBrowserModelTest >> testRootFragments [

{ #category : #tests }
MiDuplicationBrowserModelTest >> testSelectedFragment [
model entities: { method1 . method2 . method3 }.
self assertEmpty: model selectedEntities.

model selectedFragments: {fragment2}.
model entities: {
method1.
method2.
method3 }.
self assertEmpty: model miSelectedItem.

model selectedFragments: { fragment2 }.
self assert: model selectedEntities size equals: 2.
self assert: (model isSelected: method1).
self assert: (model isSelected: method2).
self deny: (model isSelected: method3).
self deny: (model isSelected: method3)
]
23 changes: 12 additions & 11 deletions src/MooseIDE-Tests/MiDuplicationBrowserTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ Class {
{ #category : #running }
MiDuplicationBrowserTest >> browserClass [

^MiDuplicationBrowser
^ MiDuplicationBrowser
]

{ #category : #running }
MiDuplicationBrowserTest >> initializeEntityToSelect [

entityToSelect := (self method: 'method1' withSource: (1 to: 8))
asMooseGroup
]

{ #category : #running }
Expand Down Expand Up @@ -88,12 +95,6 @@ MiDuplicationBrowserTest >> sourceCode: lineInterval [
to: lineInterval last)
]

{ #category : #tests }
MiDuplicationBrowserTest >> testActivateActionButtons [

browser actionButtons do: [ :button | self deny: button isEnabled ].
]

{ #category : #'tests - actions' }
MiDuplicationBrowserTest >> testFollowEntity [

Expand All @@ -118,16 +119,16 @@ MiDuplicationBrowserTest >> testFormatReplicatedFragment [
MiDuplicationBrowserTest >> testMiSelectedItem [

| entities |
entities := {
entities := {
(self method: 'method1').
(self method: 'method2') } asMooseGroup.

browser model entities: entities.

self assertEmpty: browser miSelectedItem.
self deny: browser canPropagate.
self denyEmpty: browser miSelectedItem.
self assert: browser canPropagate.

browser model selectedEntities: entities.
browser model selectEntities: entities.
self assert: browser miSelectedItem size equals: 2.
self assert: browser canPropagate
]
Expand Down

0 comments on commit 6f97e0b

Please sign in to comment.