Skip to content

Commit

Permalink
add test for test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyan11 committed Dec 24, 2023
1 parent 8a9f9eb commit e718dfa
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions src/Pyramid-Bloc/PyramidPluginTestModeTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Class {
#name : #PyramidPluginTestModeTest,
#superclass : #TestCase,
#instVars : [
'plugin',
'spacePlugin',
'editor'
],
#category : #'Pyramid-Bloc-plugin-testmode'
}

{ #category : #accessing }
PyramidPluginTestModeTest >> editor [
^ editor
]

{ #category : #accessing }
PyramidPluginTestModeTest >> plugin [

^ plugin
]

{ #category : #running }
PyramidPluginTestModeTest >> setUp [

super setUp.

plugin := PyramidPluginTestMode new.
spacePlugin := PyramidSpacePlugin new.
editor := PyramidEditorBuilder new plugins: { plugin . spacePlugin }; build.
]

{ #category : #tests }
PyramidPluginTestModeTest >> testIsTestOnGoing [

self assert: self plugin isTestOnGoing not.
self plugin switchToTestMode.
self assert: self plugin isTestOnGoing.
self plugin switchToTestMode.
self assert: self plugin isTestOnGoing not.
]

{ #category : #tests }
PyramidPluginTestModeTest >> testSwitchToTestMode [

| element elementThatReceiveEvent |
element := BlElement new
size: 500 asPoint;
background: Color blue;
addEventHandler: (BlEventHandler
on: BlPrimaryClickEvent
do: [ :evt | ]);
yourself.
self plugin elementAtEvents addEventHandler: (BlEventHandler
on: BlPrimaryClickEvent
do: [ :evt | ]).
self editor projectModel firstLevelElements add: element.

self plugin elementAtMain forceLayout.
elementThatReceiveEvent := self plugin elementAtMain
findMouseEventTargetAt:
10 asPoint
+ self plugin currentTransformTranslation.
self deny: elementThatReceiveEvent equals: element.

self plugin switchToTestMode.
self plugin elementAtMain forceLayout.
elementThatReceiveEvent := self plugin elementAtMain
findMouseEventTargetAt:
10 asPoint
+ self plugin currentTransformTranslation.
self assert: elementThatReceiveEvent equals: element.

self plugin switchToTestMode.
self plugin elementAtMain forceLayout.
elementThatReceiveEvent := self plugin elementAtMain
findMouseEventTargetAt:
10 asPoint
+ self plugin currentTransformTranslation.
self deny: elementThatReceiveEvent equals: element
]

0 comments on commit e718dfa

Please sign in to comment.