Skip to content

Commit 0e7302e

Browse files
committed
tests: add a few basic unit tests for WindowProperties class
1 parent 074c518 commit 0e7302e

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

tests/display/test_winprops.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from panda3d.core import WindowProperties
2+
3+
import pytest
4+
5+
6+
def test_winprops_ctor():
7+
props = WindowProperties()
8+
assert not props.is_any_specified()
9+
10+
11+
def test_winprops_copy_ctor():
12+
props = WindowProperties()
13+
props.set_size(1, 2)
14+
15+
props2 = WindowProperties(props)
16+
assert props == props2
17+
assert props2.get_size() == (1, 2)
18+
19+
with pytest.raises(TypeError):
20+
WindowProperties(None)
21+
22+
23+
def test_winprops_ctor_kwargs():
24+
props = WindowProperties(size=(1, 2), origin=3)
25+
26+
assert props.has_size()
27+
assert props.get_size() == (1, 2)
28+
29+
assert props.has_origin()
30+
assert props.get_origin() == (3, 3)
31+
32+
# Invalid property should throw
33+
with pytest.raises(TypeError):
34+
WindowProperties(swallow_type="african")
35+
36+
# Invalid value should throw
37+
with pytest.raises(TypeError):
38+
WindowProperties(size="invalid")
39+
40+
41+
def test_winprops_size_staticmethod():
42+
props = WindowProperties.size(1, 2)
43+
assert props.has_size()
44+
assert props.get_size() == (1, 2)
45+
46+
props = WindowProperties.size((1, 2))
47+
assert props.has_size()
48+
assert props.get_size() == (1, 2)
49+
50+
51+
def test_winprops_size_property():
52+
props = WindowProperties()
53+
54+
# Test get
55+
props.set_size(1, 2)
56+
assert props.size == (1, 2)
57+
58+
# Test has
59+
props.clear_size()
60+
assert props.size is None
61+
62+
# Test set
63+
props.size = (4, 5)
64+
assert props.get_size() == (4, 5)
65+
66+
# Test clear
67+
props.size = None
68+
assert not props.has_size()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy