Exemplo n.º 1
0
 def test_play():
     app = ELiDEApp()
     app.config = {'ELiDE': {'boardchar': 'foo'}}
     app.spotcfg = SpotConfigScreen()
     app.pawncfg = PawnConfigScreen()
     app.statcfg = StatScreen()
     char = Facade()
     char.name = 'foo'
     app.character = char
     app.engine = app.statcfg.engine = MockEngine()
     char.character = SimpleNamespace(engine=app.engine)
     app.engine.character['foo'] = char
     entity = ListenableDict()
     entity.engine = app.engine
     entity.name = 'name'
     app.selected_proxy = app.proxy = app.statcfg.proxy = entity
     screen = MainScreen(app=app, graphboards={'foo': GraphBoard(
         character=char, app=app)}, gridboards={
         'foo': GridBoard(character=char)
     }, play_speed=1.0)
     win = window_with_widget(screen)
     idle_until(lambda: 'timepanel' in screen.ids)
     timepanel = screen.ids['timepanel']
     idle_until(lambda: timepanel.size != [100, 100])
     turnfield = timepanel.ids['turnfield']
     turn_before = int(turnfield.hint_text)
     playbut = timepanel.ids['playbut']
     x, y = playbut.center
     sx = x / win.width
     sy = y / win.height
     motion = MockTouch("unittest", 1, {'sx': sx, 'sy': sy})
     EventLoop.post_dispatch_input("begin", motion)
     EventLoop.post_dispatch_input("end", motion)
     idle_until(lambda: int(turnfield.hint_text) == 3, 300, "Time didn't advance fast enough")
Exemplo n.º 2
0
def _tap_on_ui_thread(automator, args):
    global_x,global_y = automator.global_center()
    app = App.get_running_app()
    
    relative_pos = {"x": global_x / app.root.width, "y" : global_y / app.root.height}
    touch = FakeMotionEvent("fake", 1, relative_pos)
     
    EventLoop.post_dispatch_input("begin", touch)
    EventLoop.post_dispatch_input("end", touch)
Exemplo n.º 3
0
 def __init__(self, raw_x, raw_y):
     win = EventLoop.window
     super().__init__("unittest", 1, {
         "x": raw_x / float(win.width),
         "y": raw_y / float(win.height),
     })
     # press & release
     EventLoop.post_dispatch_input("begin", self)
     EventLoop.post_dispatch_input("end", self)
     EventLoop.idle()
Exemplo n.º 4
0
    def test_smooth_scroll_end(self):
        EventLoop.ensure_window()
        win = EventLoop.window
        grid = _TestGrid()
        scroll = ScrollView(smooth_scroll_end=10)

        assert scroll.smooth_scroll_end == 10
        scroll.add_widget(grid)

        # XXX this shouldn't be needed, but previous tests apparently
        # don't cleanup
        while win.children:
            win.remove_widget(win.children[0])

        win.add_widget(scroll)

        # get widgets ready
        EventLoop.idle()

        e = scroll.effect_y
        assert e.velocity == 0

        touch = UTMotionEvent(
            "unittest", next(touch_id), {
                "x": scroll.center_x / float(win.width),
                "y": scroll.center_y / float(win.height),
            })

        touch.profile.append('button')
        touch.button = 'scrollup'

        EventLoop.post_dispatch_input("begin", touch)
        # EventLoop.post_dispatch_input("update", touch)
        assert e.velocity == 10 * scroll.scroll_wheel_distance
        EventLoop.idle()
        assert 0 < e.velocity < 10 * scroll.scroll_wheel_distance
        EventLoop.post_dispatch_input("end", touch)
        EventLoop.idle()
        assert 0 < e.velocity < 10 * scroll.scroll_wheel_distance

        # wait for velocity to die off
        while e.velocity:
            EventLoop.idle()

        touch = UTMotionEvent(
            "unittest", next(touch_id), {
                "x": scroll.center_x / float(win.width),
                "y": scroll.center_y / float(win.height),
            })
        touch.profile.append('button')
        touch.button = 'scrolldown'

        EventLoop.post_dispatch_input("begin", touch)
        # EventLoop.post_dispatch_input("update", touch)
        assert e.velocity == -10 * scroll.scroll_wheel_distance
        EventLoop.idle()
        assert 0 > e.velocity > -10 * scroll.scroll_wheel_distance
        EventLoop.post_dispatch_input("end", touch)
        EventLoop.idle()
        assert 0 > e.velocity > -10 * scroll.scroll_wheel_distance
Exemplo n.º 5
0
    def __init__(self, raw_x, raw_y):
        win = EventLoop.window

        super(UTMotionEvent, self).__init__(
            "unittest", 1, {
                "x": raw_x / float(win.width),
                "y": raw_y / float(win.height),
            }
        )

        # press & release
        EventLoop.post_dispatch_input("begin", self)
        EventLoop.post_dispatch_input("end", self)
        EventLoop.idle()
Exemplo n.º 6
0
    def test_smooth_scroll_end(self):
        EventLoop.ensure_window()
        win = EventLoop.window
        grid = TestGrid()
        scroll = ScrollView(smooth_scroll_end=10)

        assert scroll.smooth_scroll_end == 10
        scroll.add_widget(grid)

        # XXX this shouldn't be needed, but previous tests apparently
        # don't cleanup
        while win.children:
            win.remove_widget(win.children[0])

        win.add_widget(scroll)

        # get widgets ready
        EventLoop.idle()

        e = scroll.effect_y
        assert e.velocity == 0

        touch = UTMotionEvent("unittest", next(touch_id), {
            "x": scroll.center_x / float(win.width),
            "y": scroll.center_y / float(win.height),
        })

        touch.profile.append('button')
        touch.button = 'scrollup'

        EventLoop.post_dispatch_input("begin", touch)
        # EventLoop.post_dispatch_input("update", touch)
        assert e.velocity == 10 * scroll.scroll_wheel_distance
        EventLoop.idle()
        assert 0 < e.velocity < 10 * scroll.scroll_wheel_distance
        EventLoop.post_dispatch_input("end", touch)
        EventLoop.idle()
        assert 0 < e.velocity < 10 * scroll.scroll_wheel_distance

        # wait for velocity to die off
        while e.velocity:
            EventLoop.idle()

        touch = UTMotionEvent("unittest", next(touch_id), {
            "x": scroll.center_x / float(win.width),
            "y": scroll.center_y / float(win.height),
        })
        touch.profile.append('button')
        touch.button = 'scrolldown'

        EventLoop.post_dispatch_input("begin", touch)
        # EventLoop.post_dispatch_input("update", touch)
        assert e.velocity == -10 * scroll.scroll_wheel_distance
        EventLoop.idle()
        assert 0 > e.velocity > -10 * scroll.scroll_wheel_distance
        EventLoop.post_dispatch_input("end", touch)
        EventLoop.idle()
        assert 0 > e.velocity > -10 * scroll.scroll_wheel_distance
Exemplo n.º 7
0
 def test_select_spot():
     char = Facade()
     char.add_place(0, _x=0.1, _y=0.1)
     app = ELiDEApp()
     board = GraphBoard(app=app, character=char)
     boardview = GraphBoardView(board=board)
     win = window_with_widget(boardview)
     idle_until(lambda: 0 in board.spot and board.spot[0] in board.
                spotlayout.children)
     x, y = board.spot[0].center
     motion = MockTouch("unittest", 1, {
         'sx': x / win.width,
         'sy': y / win.height
     })
     EventLoop.post_dispatch_input("begin", motion)
     EventLoop.post_dispatch_input("end", motion)
     assert app.selection == board.spot[0]
Exemplo n.º 8
0
    def test_scroll_doesnt_move_cursor(self):
        ti = self.make_scrollable_text_input()

        from kivy.base import EventLoop
        win = EventLoop.window
        touch = UTMotionEvent("unittest", next(touch_id), {
            "x": ti.center_x / float(win.width),
            "y": ti.center_y / float(win.height),
        })
        touch.profile.append('button')
        touch.button = 'scrolldown'

        prev_cursor = ti.cursor
        assert ti._visible_lines_range == (20, 30)
        EventLoop.post_dispatch_input("begin", touch)
        EventLoop.post_dispatch_input("end", touch)
        self.advance_frames(1)
        assert ti._visible_lines_range == (19, 29)
        assert ti.cursor == prev_cursor
Exemplo n.º 9
0
    def test_scroll_doesnt_move_cursor(self):
        ti = self.make_scrollable_text_input()

        from kivy.base import EventLoop
        win = EventLoop.window
        touch = UTMotionEvent("unittest", next(touch_id), {
            "x": ti.center_x / float(win.width),
            "y": ti.center_y / float(win.height),
        })
        touch.profile.append('button')
        touch.button = 'scrolldown'

        prev_cursor = ti.cursor
        assert ti._visible_lines_range == (20, 30)
        EventLoop.post_dispatch_input("begin", touch)
        EventLoop.post_dispatch_input("end", touch)
        self.advance_frames(1)
        assert ti._visible_lines_range == (19, 29)
        assert ti.cursor == prev_cursor
Exemplo n.º 10
0
 def test_select_arrow():
     char = Facade()
     char.add_place(0, _x=0.1, _y=0.1)
     char.add_place(1, _x=0.2, _y=0.1)
     char.add_portal(0, 1)
     app = ELiDEApp()
     board = GraphBoard(app=app, character=char)
     boardview = GraphBoardView(board=board)
     win = window_with_widget(boardview)
     idle_until(lambda: 0 in board.arrow and 1 in board.arrow[0] and board.
                arrow[0][1] in board.arrowlayout.children)
     ox, oy = board.spot[0].center
     dx, dy = board.spot[1].center
     motion = MockTouch("unittest", 1, {
         'sx': (ox + ((dx - ox) / 2)) / win.width,
         'sy': dy / win.height
     })
     EventLoop.post_dispatch_input("begin", motion)
     EventLoop.post_dispatch_input("end", motion)
     assert app.selection == board.arrow[0][1]
Exemplo n.º 11
0
    def test_vertical_scroll_doesnt_depend_on_lines_rendering(self):
        # TextInput.on_touch_down was checking the possibility to scroll_up
        # using the positions of the rendered lines' rects. These positions
        # don't change when the lines are skipped (e.g. during fast scroll
        # or ctrl+cursor_home) which lead to scroll freeze
        ti = self.make_scrollable_text_input()

        # move viewport to the first line
        ti.do_cursor_movement('cursor_home', control=True)
        self.advance_frames(1)
        assert ti._visible_lines_range == (0, 10)

        from kivy.base import EventLoop
        win = EventLoop.window

        # slowly scroll to the last line to render all lines at least once
        for _ in range(30):  # little overscroll is important for detection
            touch = UTMotionEvent(
                "unittest", next(touch_id), {
                    "x": ti.center_x / float(win.width),
                    "y": ti.center_y / float(win.height),
                })
            touch.profile.append('button')
            touch.button = 'scrollup'

            EventLoop.post_dispatch_input("begin", touch)
            EventLoop.post_dispatch_input("end", touch)
            self.advance_frames(1)
        assert ti._visible_lines_range == (20, 30)

        # jump to the first line again
        ti.do_cursor_movement('cursor_home', control=True)

        # temp fix: only change of cursor position triggers update as for now
        ti._trigger_update_graphics()

        self.advance_frames(1)
        assert ti._visible_lines_range == (0, 10)

        # scrolling up should work now
        touch = UTMotionEvent(
            "unittest", next(touch_id), {
                "x": ti.center_x / float(win.width),
                "y": ti.center_y / float(win.height),
            })
        touch.profile.append('button')
        touch.button = 'scrollup'
        EventLoop.post_dispatch_input("begin", touch)
        EventLoop.post_dispatch_input("end", touch)
        self.advance_frames(1)
        assert ti._visible_lines_range == (1, 11)
Exemplo n.º 12
0
    def test_vertical_scroll_doesnt_depend_on_lines_rendering(self):
        # TextInput.on_touch_down was checking the possibility to scroll_up
        # using the positions of the rendered lines' rects. These positions
        # don't change when the lines are skipped (e.g. during fast scroll
        # or ctrl+cursor_home) which lead to scroll freeze
        ti = self.make_scrollable_text_input()

        # move viewport to the first line
        ti.do_cursor_movement('cursor_home', control=True)
        self.advance_frames(1)
        assert ti._visible_lines_range == (0, 10)

        from kivy.base import EventLoop
        win = EventLoop.window

        # slowly scroll to the last line to render all lines at least once
        for _ in range(30):  # little overscroll is important for detection
            touch = UTMotionEvent("unittest", next(touch_id), {
                "x": ti.center_x / float(win.width),
                "y": ti.center_y / float(win.height),
            })
            touch.profile.append('button')
            touch.button = 'scrollup'

            EventLoop.post_dispatch_input("begin", touch)
            EventLoop.post_dispatch_input("end", touch)
            self.advance_frames(1)
        assert ti._visible_lines_range == (20, 30)

        # jump to the first line again
        ti.do_cursor_movement('cursor_home', control=True)

        # temp fix: only change of cursor position triggers update as for now
        ti._trigger_update_graphics()

        self.advance_frames(1)
        assert ti._visible_lines_range == (0, 10)

        # scrolling up should work now
        touch = UTMotionEvent("unittest", next(touch_id), {
            "x": ti.center_x / float(win.width),
            "y": ti.center_y / float(win.height),
        })
        touch.profile.append('button')
        touch.button = 'scrollup'
        EventLoop.post_dispatch_input("begin", touch)
        EventLoop.post_dispatch_input("end", touch)
        self.advance_frames(1)
        assert ti._visible_lines_range == (1, 11)
 def test_relativelayout_on_touch_move(self):
     EventLoop.ensure_window()
     rl = RelativeLayout()
     EventLoop.window.add_widget(rl)
     touch = UTMotionEvent("unittest", 1, {"x": .5, "y": .5})
     EventLoop.post_dispatch_input("begin", touch)
     touch.move({"x": .6, "y": .4})
     EventLoop.post_dispatch_input("update", touch)
     EventLoop.post_dispatch_input("end", touch)
Exemplo n.º 14
0
 def test_relativelayout_on_touch_move(self):
     EventLoop.ensure_window()
     rl = RelativeLayout()
     EventLoop.window.add_widget(rl)
     touch = UTMotionEvent("unittest", 1, {"x": .5, "y": .5})
     EventLoop.post_dispatch_input("begin", touch)
     touch.move({"x": .6, "y": .4})
     EventLoop.post_dispatch_input("update", touch)
     EventLoop.post_dispatch_input("end", touch)
Exemplo n.º 15
0
    def test_slider_move(self):
        EventLoop.ensure_window()
        win = EventLoop.window
        layout = BoxLayout(orientation='vertical')

        s_handle = TestSliderHandle()
        s_all = TestSliderAll()
        layout.add_widget(s_handle)
        layout.add_widget(s_all)
        win.add_widget(layout)

        # get widgets ready
        EventLoop.idle()

        cur1 = s_handle.children[0]
        cur2 = s_all.children[0]

        h1 = cur1.to_window(*cur1.center)[1]
        h2 = h1 - s_handle.cursor_height
        h3 = cur2.to_window(*cur2.center)[1]
        h4 = h3 - s_all.cursor_height

        w1 = cur1.to_window(*cur1.center)[0]
        w2 = cur2.to_window(*cur2.center)[0]
        wh = win.width / 2.0
        dt = 2

        # default pos, new pos, slider ID
        points = [
            [w1, h1, wh, h1, 'handle'],
            [w1, h2, wh, h2, 'handle'],
            [w2, h3, wh, h3, 'all'],
            [w2, h4, wh, h4, 'all'],
        ]

        for point in points:
            x, y, nx, ny, id = point

            # custom touch
            touch = UTMotionEvent("unittest", 1, {
                "x": x / float(win.width),
                "y": y / float(win.height),
            })

            # touch down
            EventLoop.post_dispatch_input("begin", touch)

            if id == 'handle':
                # touch on handle
                if x == w1 and y == h1:
                    self.assertAlmostEqual(
                        s_handle.value, 0.0,
                        delta=dt
                    )
                # touch in widget area (ignored, previous value)
                elif x == w1 and y == h2:
                    self.assertAlmostEqual(
                        s_handle.value, 50.0,
                        delta=dt
                    )
            elif id == 'all':
                # touch on handle:
                if x == w1 and y == h3:
                    self.assertAlmostEqual(
                        s_all.value, 0.0,
                        delta=dt
                    )
                # touch in widget area
                elif x == w1 and y == h4:
                    self.assertAlmostEqual(
                        s_all.value, 0.0,
                        delta=dt
                    )

            # move from default to new pos
            touch.move({
                "x": nx / float(win.width),
                "y": ny / float(win.height)
            })
            EventLoop.post_dispatch_input("update", touch)

            if id == 'handle':
                # move from handle to center
                if nx == wh and ny == h1:
                    self.assertAlmostEqual(
                        s_handle.value, 50.0,
                        delta=dt
                    )
                # move to center (ignored, previous value)
                elif nx == wh and ny == h2:
                    self.assertAlmostEqual(
                        s_handle.value, 50.0,
                        delta=dt
                    )
            elif id == 'all':
                # touch on handle:
                if nx == wh and ny == h3:
                    self.assertAlmostEqual(
                        s_all.value, 50.0,
                        delta=dt
                    )
                # touch in widget area
                elif nx == wh and ny == h4:
                    self.assertAlmostEqual(
                        s_all.value, 50.0,
                        delta=dt
                    )

            # touch up
            EventLoop.post_dispatch_input("end", touch)

        self.render(layout)
Exemplo n.º 16
0
    def test_slider_move(self):
        EventLoop.ensure_window()
        win = EventLoop.window
        layout = BoxLayout(orientation='vertical')

        s_handle = _TestSliderHandle()
        s_all = _TestSliderAll()
        layout.add_widget(s_handle)
        layout.add_widget(s_all)
        win.add_widget(layout)

        # get widgets ready
        EventLoop.idle()

        cur1 = s_handle.children[0]
        cur2 = s_all.children[0]

        h1 = cur1.to_window(*cur1.center)[1]
        h2 = h1 - s_handle.cursor_height
        h3 = cur2.to_window(*cur2.center)[1]
        h4 = h3 - s_all.cursor_height

        w1 = cur1.to_window(*cur1.center)[0]
        w2 = cur2.to_window(*cur2.center)[0]
        wh = win.width / 2.0
        dt = 2

        # default pos, new pos, slider ID
        points = [
            [w1, h1, wh, h1, 'handle'],
            [w1, h2, wh, h2, 'handle'],
            [w2, h3, wh, h3, 'all'],
            [w2, h4, wh, h4, 'all'],
        ]

        for point in points:
            x, y, nx, ny, id = point

            # custom touch
            touch = UTMotionEvent("unittest", 1, {
                "x": x / float(win.width),
                "y": y / float(win.height),
            })

            # touch down
            EventLoop.post_dispatch_input("begin", touch)

            if id == 'handle':
                # touch on handle
                if x == w1 and y == h1:
                    self.assertAlmostEqual(s_handle.value, 0.0, delta=dt)
                # touch in widget area (ignored, previous value)
                elif x == w1 and y == h2:
                    self.assertAlmostEqual(s_handle.value, 50.0, delta=dt)
            elif id == 'all':
                # touch on handle:
                if x == w1 and y == h3:
                    self.assertAlmostEqual(s_all.value, 0.0, delta=dt)
                # touch in widget area
                elif x == w1 and y == h4:
                    self.assertAlmostEqual(s_all.value, 0.0, delta=dt)

            # move from default to new pos
            touch.move({
                "x": nx / float(win.width),
                "y": ny / float(win.height)
            })
            EventLoop.post_dispatch_input("update", touch)

            if id == 'handle':
                # move from handle to center
                if nx == wh and ny == h1:
                    self.assertAlmostEqual(s_handle.value, 50.0, delta=dt)
                # move to center (ignored, previous value)
                elif nx == wh and ny == h2:
                    self.assertAlmostEqual(s_handle.value, 50.0, delta=dt)
            elif id == 'all':
                # touch on handle:
                if nx == wh and ny == h3:
                    self.assertAlmostEqual(s_all.value, 50.0, delta=dt)
                # touch in widget area
                elif nx == wh and ny == h4:
                    self.assertAlmostEqual(s_all.value, 50.0, delta=dt)

            # touch up
            EventLoop.post_dispatch_input("end", touch)

        self.render(layout)
Exemplo n.º 17
0
    def process_points(self, scroll, points):
        win = EventLoop.window
        dt = 0.02

        for point in points:
            if DEBUG:
                print('point:', point, scroll.scroll_x, scroll.scroll_y)
                Clock.schedule_once(lambda *dt: sleep(0.5), 0)
                self.render(scroll)

            x, y, nx, ny, pos_x, pos_y, border_check = point
            scroll.bar_pos = (pos_x, pos_y)

            touch = UTMotionEvent("unittest", next(touch_id), {
                "x": x / float(win.width),
                "y": y / float(win.height),
            })

            # we start with the default top-left corner
            self.assertAlmostEqual(scroll.scroll_x, 0.0, delta=dt)
            self.assertAlmostEqual(scroll.scroll_y, 1.0, delta=dt)

            # check the collision with the margin empty area
            if border_check:
                EventLoop.post_dispatch_input("begin", touch)
                touch.move({
                    "x": nx / float(win.width),
                    "y": ny / float(win.height)
                })
                EventLoop.post_dispatch_input("update", touch)
                EventLoop.post_dispatch_input("end", touch)

                self.assertAlmostEqual(scroll.scroll_x, 0.0, delta=dt)
                self.assertAlmostEqual(scroll.scroll_y, 1.0, delta=dt)
                return

            EventLoop.post_dispatch_input("begin", touch)
            touch.move({
                "x": nx / float(win.width),
                "y": ny / float(win.height)
            })
            EventLoop.post_dispatch_input("update", touch)
            EventLoop.post_dispatch_input("end", touch)

            if DEBUG:
                print(scroll.scroll_x, scroll.scroll_y)
                Clock.schedule_once(lambda *dt: sleep(0.5), 0)
                self.render(scroll)

            # check the scroll position
            self.assertAlmostEqual(scroll.scroll_x,
                                   0.0 if x == nx else 1.0,
                                   delta=dt)
            self.assertAlmostEqual(scroll.scroll_y,
                                   1.0 if y == ny else 0.0,
                                   delta=dt)

            # reset scroll to original state
            scroll.scroll_x = 0.0
            scroll.scroll_y = 1.0
Exemplo n.º 18
0
    def test_touch_draw(self):
        # get Window instance for creating visible
        # widget tree and for calculating coordinates
        EventLoop.ensure_window()
        win = EventLoop.window

        # add widget for testing
        child = WidgetCanvasDraw()
        win.add_widget(child)

        # get widgets ready
        EventLoop.idle()

        # default "cursor" position in the middle
        pos = [win.width / 2.0, win.height / 2.0]

        # default pos, new pos
        points = [
            [pos[0] - 5, pos[1], pos[0] + 5, pos[1]],
            [pos[0], pos[1] - 5, pos[0], pos[1] + 5]
        ]

        # general behavior for touch+move+release
        for i, point in enumerate(points):
            x, y, nx, ny = point

            # create custom MotionEvent (touch) instance
            touch = UTMotionEvent("unittest", 1, {
                "sx": x / float(win.width),
                "sy": y / float(win.height),
            })

            # dispatch the MotionEvent in EventLoop as
            # touch/press/click, see Profiles for more info:
            # https://kivy.org/docs/api-kivy.input.motionevent.html#profiles
            EventLoop.post_dispatch_input("begin", touch)

            # the touch is dispatched and has ud['lines']
            # available from on_touch_down
            self.assertIn('lines', touch.ud)
            self.assertTrue(isinstance(touch.ud['lines'], Point))

            # move touch from current to the new position
            touch.move({
                "sx": nx / float(win.width),
                "sy": ny / float(win.height)
            })
            # update the MotionEvent in EventLoop
            EventLoop.post_dispatch_input("update", touch)

            # release the MotionEvent in EventLoop
            EventLoop.post_dispatch_input("end", touch)

            # still available, but released
            self.assertIn('lines', touch.ud)
            self.assertTrue(isinstance(touch.ud['lines'], Point))

            expected_points = [[
                x + 0, y, x + 1, y,
                x + 2, y, x + 3, y,
                x + 4, y, x + 5, y,
                x + 6, y, x + 7, y,
                x + 8, y, x + 9, y
            ], [
                x, y + 0, x, y + 1,
                x, y + 2, x, y + 3,
                x, y + 4, x, y + 5,
                x, y + 6, x, y + 7,
                x, y + 8, x, y + 9
            ]]

            # check if the instruction points == expected ones
            self.assertEqual(
                touch.ud['lines'].points,
                expected_points[i]
            )

        # render the graphics
        self.render(child)
Exemplo n.º 19
0
    def process_points(self, scroll, points):
        win = EventLoop.window
        dt = 0.02

        for point in points:
            if DEBUG:
                print('point:', point, scroll.scroll_x, scroll.scroll_y)
                Clock.schedule_once(lambda *dt: sleep(0.5), 0)
                self.render(scroll)

            x, y, nx, ny, pos_x, pos_y, border_check = point
            scroll.bar_pos = (pos_x, pos_y)

            touch = UTMotionEvent("unittest", next(touch_id), {
                "x": x / float(win.width),
                "y": y / float(win.height),
            })

            # we start with the default top-left corner
            self.assertAlmostEqual(scroll.scroll_x, 0.0, delta=dt)
            self.assertAlmostEqual(scroll.scroll_y, 1.0, delta=dt)

            # check the collision with the margin empty area
            if border_check:
                EventLoop.post_dispatch_input("begin", touch)
                touch.move({
                    "x": nx / float(win.width),
                    "y": ny / float(win.height)
                })
                EventLoop.post_dispatch_input("update", touch)
                EventLoop.post_dispatch_input("end", touch)

                self.assertAlmostEqual(scroll.scroll_x, 0.0, delta=dt)
                self.assertAlmostEqual(scroll.scroll_y, 1.0, delta=dt)
                return

            EventLoop.post_dispatch_input("begin", touch)
            touch.move({
                "x": nx / float(win.width),
                "y": ny / float(win.height)
            })
            EventLoop.post_dispatch_input("update", touch)
            EventLoop.post_dispatch_input("end", touch)

            if DEBUG:
                print(scroll.scroll_x, scroll.scroll_y)
                Clock.schedule_once(lambda *dt: sleep(0.5), 0)
                self.render(scroll)

            # check the scroll position
            self.assertAlmostEqual(
                scroll.scroll_x, 0.0 if x == nx else 1.0,
                delta=dt
            )
            self.assertAlmostEqual(
                scroll.scroll_y, 1.0 if y == ny else 0.0,
                delta=dt
            )

            # reset scroll to original state
            scroll.scroll_x = 0.0
            scroll.scroll_y = 1.0