Fix background Unity input and shop boundaries; record login failure
This commit is contained in:
+16
-8
@@ -414,7 +414,7 @@ class RuntimeTest(unittest.TestCase):
|
|||||||
[mock.call(1, 2, True), mock.call(1, 3, True),
|
[mock.call(1, 2, True), mock.call(1, 3, True),
|
||||||
mock.call(1, 3, False), mock.call(1, 2, False)])
|
mock.call(1, 3, False), mock.call(1, 2, False)])
|
||||||
|
|
||||||
def test_background_click_holds_and_releases_without_moving_window(self):
|
def test_background_click_holds_and_releases_without_moving_pointer_or_window(self):
|
||||||
from lc_mcp.aalc_engine import AalcEngine
|
from lc_mcp.aalc_engine import AalcEngine
|
||||||
engine = AalcEngine.__new__(AalcEngine)
|
engine = AalcEngine.__new__(AalcEngine)
|
||||||
engine.cfg = mock.Mock(simulator=False, win_input_type='background')
|
engine.cfg = mock.Mock(simulator=False, win_input_type='background')
|
||||||
@@ -422,19 +422,26 @@ class RuntimeTest(unittest.TestCase):
|
|||||||
handler = mock.Mock(spec=['set_mouse_pos','set_active','mouse_down','mouse_up'])
|
handler = mock.Mock(spec=['set_mouse_pos','set_active','mouse_down','mouse_up'])
|
||||||
engine.auto.input_handler = handler
|
engine.auto.input_handler = handler
|
||||||
sequence = mock.Mock()
|
sequence = mock.Mock()
|
||||||
sequence.attach_mock(handler.mouse_down, 'down')
|
engine._background_mouse = mock.Mock()
|
||||||
sequence.attach_mock(handler.mouse_up, 'up')
|
sequence.attach_mock(engine._background_mouse, 'message')
|
||||||
with mock.patch('lc_mcp.aalc_engine.time.sleep') as sleep:
|
constants = mock.Mock(WM_MOUSEMOVE=512, WM_LBUTTONDOWN=513, WM_LBUTTONUP=514)
|
||||||
|
with mock.patch.dict(sys.modules, win32con=constants), \
|
||||||
|
mock.patch('lc_mcp.aalc_engine.time.sleep') as sleep:
|
||||||
sequence.attach_mock(sleep, 'sleep')
|
sequence.attach_mock(sleep, 'sleep')
|
||||||
engine.click(100, 200)
|
engine.click(100, 200)
|
||||||
self.assertEqual(sequence.mock_calls, [mock.call.down(100, 200),
|
self.assertEqual(sequence.mock_calls, [mock.call.message(512, 100, 200),
|
||||||
mock.call.sleep(.12), mock.call.up(100, 200),
|
mock.call.sleep(.12),
|
||||||
|
mock.call.message(513, 100, 200, held=True),
|
||||||
|
mock.call.sleep(.12), mock.call.message(514, 100, 200),
|
||||||
mock.call.sleep(.12)])
|
mock.call.sleep(.12)])
|
||||||
engine.auto.mouse_click.assert_not_called()
|
engine.auto.mouse_click.assert_not_called()
|
||||||
with mock.patch('lc_mcp.aalc_engine.time.sleep', side_effect=RuntimeError('interrupted')):
|
handler.set_mouse_pos.assert_not_called()
|
||||||
|
handler.mouse_down.assert_not_called()
|
||||||
|
with mock.patch.dict(sys.modules, win32con=constants), \
|
||||||
|
mock.patch('lc_mcp.aalc_engine.time.sleep', side_effect=[None, RuntimeError('interrupted')]):
|
||||||
with self.assertRaises(RuntimeError):
|
with self.assertRaises(RuntimeError):
|
||||||
engine.click(100, 200)
|
engine.click(100, 200)
|
||||||
self.assertEqual(handler.mouse_up.call_count, 2)
|
self.assertEqual(engine._background_mouse.call_args, mock.call(514, 100, 200))
|
||||||
engine.screen.handle.set_window_pos.assert_not_called()
|
engine.screen.handle.set_window_pos.assert_not_called()
|
||||||
|
|
||||||
def test_background_keypress_holds_and_releases_on_error(self):
|
def test_background_keypress_holds_and_releases_on_error(self):
|
||||||
@@ -501,6 +508,7 @@ server.main(['--stdio'])
|
|||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
engine.drag(100, 100, 800, 500)
|
engine.drag(100, 100, 800, 500)
|
||||||
engine.auto.mouse_drag.assert_not_called()
|
engine.auto.mouse_drag.assert_not_called()
|
||||||
|
engine.cfg.simulator = True
|
||||||
engine.drag(100, 100, 100, 500, 1.5)
|
engine.drag(100, 100, 100, 500, 1.5)
|
||||||
engine.auto.mouse_drag.assert_called_once_with(100, 100, drag_time=1.5, dx=0, dy=400)
|
engine.auto.mouse_drag.assert_called_once_with(100, 100, drag_time=1.5, dx=0, dy=400)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user