Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphicUnitTest: Add clear_window_and_event_loop method #7493

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions kivy/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,23 @@ def setUp(self):
Window.create_window()
Window.register()
Window.initialized = True
Window.canvas.clear()
Window.close = lambda *s: True
Window.close = lambda *s: None
self.clear_window_and_event_loop()

def clear_window_and_event_loop(self):
from kivy.base import EventLoop
window = self.Window
for child in window.children[:]:
window.remove_widget(child)
window.canvas.before.clear()
window.canvas.clear()
window.canvas.after.clear()
EventLoop.touches.clear()
for post_proc in EventLoop.postproc_modules:
if hasattr(post_proc, 'touches'):
post_proc.touches.clear()
elif hasattr(post_proc, 'last_touches'):
post_proc.last_touches.clear()

def on_window_flip(self, window):
'''Internal method to be called when the window have just displayed an
Expand Down Expand Up @@ -299,10 +314,10 @@ def tearDown(self, fake=False):
'''
from kivy.base import stopTouchApp
from kivy.core.window import Window
from kivy.clock import Clock
Window.unbind(on_flip=self.on_window_flip)
self.clear_window_and_event_loop()
self.Window = None
stopTouchApp()

if not fake and self.test_failed:
self.assertTrue(False)
super(GraphicUnitTest, self).tearDown()
Expand Down