The Trunk: MorphicTests-mt.45.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: MorphicTests-mt.45.mcz

commits-2
Marcel Taeumel uploaded a new version of MorphicTests to project The Trunk:
http://source.squeak.org/trunk/MorphicTests-mt.45.mcz

==================== Summary ====================

Name: MorphicTests-mt.45
Author: mt
Time: 15 December 2017, 2:41:31.499738 pm
UUID: b37c9408-de4e-c241-97ea-ca024031cf67
Ancestors: MorphicTests-dtl.44

Adds test for focus events and reject bug.

=============== Diff against MorphicTests-dtl.44 ===============

Item was changed:
  Morph subclass: #MorphForEventTests
+ instanceVariableNames: 'eventsDuringCapture eventsDuringBubble eventsRejected eventsFiltered handlesMouseDown keyStrokesReceived fullFocusDispatch'
- instanceVariableNames: 'eventsDuringCapture eventsDuringBubble eventsRejected eventsFiltered handlesMouseDown keyStrokesReceived'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'MorphicTests-Events'!

Item was added:
+ ----- Method: MorphForEventTests>>fullFocusDispatch (in category 'accessing') -----
+ fullFocusDispatch
+ ^ fullFocusDispatch ifNil: [false]!

Item was added:
+ ----- Method: MorphForEventTests>>fullFocusDispatch: (in category 'accessing') -----
+ fullFocusDispatch: aBoolean
+ fullFocusDispatch := aBoolean.!

Item was added:
+ ----- Method: MorphForEventTests>>processFocusEvent:using: (in category 'events-processing') -----
+ processFocusEvent: anEvent using: defaultDispatcher
+
+ ^ self fullFocusDispatch
+ ifTrue: [defaultDispatcher dispatchFocusEventFully: anEvent with: self]
+ ifFalse: [defaultDispatcher dispatchFocusEvent: anEvent with: self]
+
+
+ !

Item was added:
+ ----- Method: MorphicEventDispatcherTests>>test11FocusEventReject (in category 'tests') -----
+ test11FocusEventReject
+ "If a morph with mouse focus or keyboard focus rejects the event, that focus should be cleared."
+
+ | m1 m2 |
+ m1 := MorphForEventTests new.
+ m1 fullFocusDispatch: false.
+ m1 on: #mouseDown send: #hide to: m1.
+ m1 on: #keyStroke send: #hide to: m1.
+ m1 openInWorld: world.
+
+ hand newMouseFocus: m1.
+ hand handleEvent: (self redMouseDownAt: m1 center).
+ self assert: hand mouseFocus isNil.
+
+ hand newKeyboardFocus: m1.
+ hand handleEvent: (self keystroke: $x at: m1 center).
+ self assert: hand keyboardFocus isNil.
+
+ m2 := MorphForEventTests new.
+ m2 bounds: m1 bounds.
+ m1 addMorph: m2.
+ m1 fullFocusDispatch: true.
+
+ hand newMouseFocus: m1.
+ hand handleEvent: (self redMouseDownAt: m2 center).
+ self assert: hand mouseFocus isNil.
+
+ hand newKeyboardFocus: m2.
+ hand handleEvent: (self keystroke: $x at: m2 center).
+ self assert: hand keyboardFocus isNil.
+ !