From e718dfa7479a393f57ec9b9d4f34b5ca1254b6e2 Mon Sep 17 00:00:00 2001 From: Nyan11 Date: Sun, 24 Dec 2023 11:15:46 +0100 Subject: [PATCH] add test for test mode --- .../PyramidPluginTestModeTest.class.st | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/Pyramid-Bloc/PyramidPluginTestModeTest.class.st diff --git a/src/Pyramid-Bloc/PyramidPluginTestModeTest.class.st b/src/Pyramid-Bloc/PyramidPluginTestModeTest.class.st new file mode 100644 index 00000000..640a965e --- /dev/null +++ b/src/Pyramid-Bloc/PyramidPluginTestModeTest.class.st @@ -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 +]