How to use get_providers method in Airtest

Best Python code snippet using Airtest

test_mouse_hover_event.py

Source:test_mouse_hover_event.py Github

copy

Full Screen

...64 assert self.motion_event.spos == spos65 def assert_no_event(self):66 assert self.etype is None67 assert self.motion_event is None68 def get_providers(self, with_window_children=False):69 from kivy.base import EventLoop70 win = EventLoop.window71 if with_window_children:72 from kivy.uix.button import Button73 button = Button(on_touch_down=self.on_any_touch_event,74 on_touch_move=self.on_any_touch_event,75 on_touch_up=self.on_any_touch_event)76 self.button_widget = button77 win.add_widget(button)78 return win, self.mouse79 def test_no_event_on_cursor_leave(self):80 win, mouse = self.get_providers()81 win.dispatch('on_cursor_leave')82 self.advance_frames(1)83 self.assert_no_event()84 def test_no_event_on_system_size(self):85 win, mouse = self.get_providers()86 w, h = win.system_size87 win.system_size = (w + 10, h + 10)88 self.advance_frames(1)89 self.assert_no_event()90 def test_no_event_on_rotate(self):91 win, mouse = self.get_providers()92 win.rotation = 9093 self.advance_frames(1)94 self.assert_no_event()95 def test_no_event_on_close(self):96 win, mouse = self.get_providers()97 win.dispatch('on_close')98 self.advance_frames(1)99 self.assert_no_event()100 def test_begin_event_on_cursor_enter(self):101 win, mouse = self.get_providers()102 x, y = win.mouse_pos103 win.dispatch('on_cursor_enter')104 self.advance_frames(1)105 self.assert_event('begin', win.to_normalized_pos(x, y))106 # Cleanup107 win.dispatch('on_cursor_leave')108 self.advance_frames(1)109 def test_begin_event_on_mouse_pos(self):110 win, mouse = self.get_providers()111 x, y = win.mouse_pos = (10.0, 10.0)112 self.advance_frames(1)113 self.assert_event('begin', win.to_normalized_pos(x, y))114 # Cleanup115 win.dispatch('on_cursor_leave')116 self.advance_frames(1)117 def test_update_event_with_enter_and_mouse_pos(self):118 win, mouse = self.get_providers()119 win.dispatch('on_cursor_enter')120 x, y = win.mouse_pos = (50.0, 50.0)121 self.advance_frames(1)122 self.assert_event('update', win.to_normalized_pos(x, y))123 # Cleanup124 win.dispatch('on_cursor_leave')125 self.advance_frames(1)126 def test_update_event_with_mouse_pos(self):127 win, mouse = self.get_providers()128 win.mouse_pos = (10.0, 10.0)129 x, y = win.mouse_pos = (50.0, 50.0)130 self.advance_frames(1)131 self.assert_event('update', win.to_normalized_pos(x, y))132 # Cleanup133 win.dispatch('on_cursor_leave')134 self.advance_frames(1)135 def test_update_event_on_rotate(self):136 win, mouse = self.get_providers()137 x, y = win.mouse_pos = (10.0, 10.0)138 win.rotation = 90139 self.advance_frames(1)140 self.assert_event('update', win.to_normalized_pos(x, y))141 # Cleanup142 win.dispatch('on_cursor_leave')143 self.advance_frames(1)144 def test_update_event_on_system_size(self):145 win, mouse = self.get_providers()146 x, y = win.mouse_pos = (10.0, 10.0)147 w, h = win.system_size148 win.system_size = (w + 10, h + 10)149 self.advance_frames(1)150 self.assert_event('update', win.to_normalized_pos(x, y))151 # Cleanup152 win.dispatch('on_cursor_leave')153 self.advance_frames(1)154 def test_end_event_on_cursor_leave(self):155 win, mouse = self.get_providers()156 x, y = win.mouse_pos = (10.0, 10.0)157 win.dispatch('on_cursor_leave')158 self.advance_frames(1)159 self.assert_event('end', win.to_normalized_pos(x, y))160 def test_end_event_on_window_close(self):161 win, mouse = self.get_providers()162 x, y = win.mouse_pos = (10.0, 10.0)163 win.dispatch('on_close')164 self.advance_frames(1)165 self.assert_event('end', win.to_normalized_pos(x, y))166 def test_with_full_cycle_with_cursor_events(self):167 win, mouse = self.get_providers()168 # Test begin event169 win.dispatch('on_cursor_enter')170 x, y = win.mouse_pos171 self.advance_frames(1)172 self.assert_event('begin', win.to_normalized_pos(x, y))173 # Test update event174 x, y = win.mouse_pos = (10.0, 10.0)175 self.advance_frames(1)176 self.assert_event('update', win.to_normalized_pos(x, y))177 # Test end event178 win.dispatch('on_cursor_leave')179 self.advance_frames(1)180 self.assert_event('end', win.to_normalized_pos(x, y))181 def test_with_full_cycle_with_mouse_pos_and_on_close_event(self):182 win, mouse = self.get_providers()183 # Test begin event184 x, y = win.mouse_pos = (5.0, 5.0)185 self.advance_frames(1)186 self.assert_event('begin', win.to_normalized_pos(x, y))187 # Test update event188 x, y = win.mouse_pos = (10.0, 10.0)189 self.advance_frames(1)190 self.assert_event('update', win.to_normalized_pos(x, y))191 # Test end event192 win.dispatch('on_close')193 self.advance_frames(1)194 self.assert_event('end', win.to_normalized_pos(x, y))195 def test_begin_event_no_dispatch_through_on_touch_events(self):196 win, mouse = self.get_providers(with_window_children=True)197 x, y = win.mouse_pos198 win.dispatch('on_cursor_enter')199 self.advance_frames(1)200 self.assert_event('begin', win.to_normalized_pos(x, y))201 assert self.touch_event is None202 # Cleanup203 win.dispatch('on_cursor_leave')204 self.advance_frames(1)205 def test_update_event_no_dispatch_through_on_touch_events(self):206 win, mouse = self.get_providers(with_window_children=True)207 win.dispatch('on_cursor_enter')208 x, y = win.mouse_pos = (10.0, 10.0)209 self.advance_frames(1)210 self.assert_event('update', win.to_normalized_pos(x, y))211 assert self.touch_event is None212 # Cleanup213 win.dispatch('on_cursor_leave')214 self.advance_frames(1)215 def test_end_event_no_dispatch_through_on_touch_events(self):216 win, mouse = self.get_providers(with_window_children=True)217 win.dispatch('on_cursor_enter')218 x, y = win.mouse_pos = (10.0, 10.0)219 win.dispatch('on_cursor_leave')220 self.advance_frames(1)221 self.assert_event('end', win.to_normalized_pos(x, y))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful