Programaticaly simulate user interaction for Unit Testing in Google Dart -
I'm trying to write some unit tests for complex menus in one place and I simulate user interaction with that menu Want to do
I've found that it is possible to simulate a click with the query code selector ("# myElement"). () , but I would like to be able to trigger more complex events like I found a way to do this. It's still not perfect or not right, but it provides anything I need. I have found this idea: mouseDown
document ,
mouseMove , < Code> TouchStart and
touchEnd in a particular place. , e.t.c.
import 'dart: html'; Import 'dart: async'; Zero main () {// Create target element DivElement menuSprite = new DivElement () .. style. Hight = "50px" .. style.wind = "50px" .. style.bird = "1px solid black"; document.body.children.add (menuSprite); // Esine Event Listener MenuSprite ..onMouseDown.listen ((E) => MenuSprite.style.backgroundColor = "red") ..onMouseUp.listen ((E) => Menu Sprite.style.backgroundColor = " Blue ") ..onTouchStart.listen ((e) => menuSprite.style.backgroundColor =" orange ") ..TouchEnd.listen ((E) => menuSprite.style.backgroundColor =" gray "); // Create event // TODO: see more parameters of the events or are more specific // see: // * https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart-dom-html MouseEvent // * https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart-dom-html.TouchEvent // // Warning: Event Type Case Is Sensitive ('MouseDown' Not Working) . Event myMouseDown = new event ('Masudown'); Event myMouseUp = new event ('mouseup'); Event myTouchStart = new event ('TouchStart'); Event myTouchEnd = new event ('touchend'); // TODO: Mousemove and Touch Moche Event // We can fire events using "Element.dispatchEvent ()". New Future Indispensable (new period (millisecond: 500), () => display menu; disaccharart (mimehouse)); New Future Indispensable (new period (millisecond: 1000), () => display menu; disseachable event (mimahaheusup)); New Future (New period (millisecond: 1500), () => menuSprite.dispatchEvent (myTouchStart)); New Future Indispensable (new period (milliseconds: 2000), () => display menu; disseachable event (matte touchand)); }
Comments
Post a Comment