-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
\Add optional 'view' argument to run() methods in Window and application
- Loading branch information
1 parent
575d662
commit bea6b0c
Showing
3 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import pytest | ||
import arcade | ||
|
||
|
||
class TestView(arcade.View): | ||
def __init__(self): | ||
super().__init__() | ||
self.on_show_called = False | ||
|
||
def on_show_view(self): | ||
self.on_show_called = True | ||
|
||
|
||
def test_window_with_view(): | ||
# Cria uma janela e uma view para o teste | ||
window = arcade.Window(width=800, height=600, title="Window Test with View") | ||
view = TestView() | ||
|
||
# Executa o método run com a view | ||
window.run(view=view) | ||
|
||
# Verifica se a view foi mostrada automaticamente | ||
assert window.current_view == view | ||
assert view.on_show_called is True | ||
|
||
# Fecha a janela ao finalizar o teste | ||
window.close() | ||
|
||
|
||
def test_run_without_view(): | ||
# Cria uma janela e chama run sem uma view | ||
window = arcade.Window(width=800, height=600, title="Window Test without View") | ||
|
||
# Executa o método run sem uma view | ||
window.run() | ||
|
||
# Verifica que não há uma view ativa | ||
assert window.current_view is None | ||
|
||
# Fecha a janela ao finalizar o teste | ||
window.close() |