summaryrefslogtreecommitdiff
path: root/tests/test_scaling.py
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-03-29 14:29:45 +0200
committerViljami Ilola <+@hix.fi>2024-03-29 14:29:45 +0200
commitc75093304fb09dcdee61ea36169074828b1e210d (patch)
tree088cbede4e9f3bc34d7a393764f5c708600ec8d3 /tests/test_scaling.py
parent063628a3c493df902af9cef4f56f726a9d4ee906 (diff)
scaling and display tests
Diffstat (limited to 'tests/test_scaling.py')
-rw-r--r--tests/test_scaling.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_scaling.py b/tests/test_scaling.py
new file mode 100644
index 0000000..170dbab
--- /dev/null
+++ b/tests/test_scaling.py
@@ -0,0 +1,24 @@
+import unittest
+
+from display import Scaling, INTERNAL_HEIGHT, INTERNAL_WIDTH
+
+class TestScaling(unittest.TestCase):
+ def test_update_scaling(self):
+ Scaling.update_scaling((100,400))
+ self.assertEqual((100,400), Scaling.resolution)
+ self.assertEqual((100//2,400//2), Scaling.center)
+ self.assertEqual((100/INTERNAL_WIDTH), Scaling.factor)
+ self.assertEqual(0, Scaling.left)
+ Scaling.update_scaling((400,100))
+ self.assertEqual((100/INTERNAL_HEIGHT), Scaling.factor)
+ self.assertEqual(0, Scaling.top)
+
+ def test_scale_functions(self):
+ Scaling.update_scaling((1000,1000))
+ s = Scaling.scale_to_display(Scaling.scale_to_internal((400,500)))
+ self.assertAlmostEqual(400, s[0], delta = 0.1)
+ self.assertAlmostEqual(500, s[1], delta = 0.1)
+
+
+
+ \ No newline at end of file