From 2f53302e98f50b75f57923963b5767229631d4b8 Mon Sep 17 00:00:00 2001 From: "Yi Yang @ Anteros" Date: Wed, 25 Dec 2024 01:01:19 +0800 Subject: [PATCH] (agrf) finish the layout test refactor --- agrf/lib/building/layout_test.py | 39 ++++++++++++++------------------ 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/agrf/lib/building/layout_test.py b/agrf/lib/building/layout_test.py index 8c38f3af..1f722d00 100644 --- a/agrf/lib/building/layout_test.py +++ b/agrf/lib/building/layout_test.py @@ -10,50 +10,45 @@ temperate_1012 = np.array(Image.open("agrf/third_party/opengfx2/temperate/1012.png")) -gs1012 = ADefaultGroundSprite(1012) +dgs1012 = ADefaultGroundSprite(1012) +gs1012 = AGroundSprite(image_sprite("agrf/third_party/opengfx2/temperate/1012.png")) +l1012 = ALayout(dgs1012, [], True) def test_default_groundsprite(): - assert (temperate_1012 == gs1012.graphics(4, 32).to_image()).all() + assert (temperate_1012 == dgs1012.graphics(4, 32).to_image()).all() def test_default_groundsprite_M(): - assert (temperate_1011 == gs1012.M.graphics(4, 32).to_image()).all() + assert (temperate_1011 == dgs1012.M.graphics(4, 32).to_image()).all() def test_default_groundsprite_R(): - assert (temperate_1012 == gs1012.R.graphics(4, 32).to_image()).all() + assert (temperate_1012 == dgs1012.R.graphics(4, 32).to_image()).all() def test_default_groundsprite_T(): - assert (temperate_1012 == gs1012.T.graphics(4, 32).to_image()).all() + assert (temperate_1012 == dgs1012.T.graphics(4, 32).to_image()).all() def test_groundsprite(): - gs1012 = AGroundSprite(image_sprite("agrf/third_party/opengfx2/temperate/1012.png")) - graphics = gs1012.graphics(4, 32).to_image() - assert graphics.shape == (127, 256, 4) - assert graphics[64, 128, 1] == 67 + assert (temperate_1012 == gs1012.graphics(4, 32).to_image()).all() def test_layout(): - l = ALayout(gs1012, [], True) + assert (temperate_1012 == l1012.graphics(4, 32).to_image()).all() + + +def test_layout_M(): + assert (temperate_1011 == l1012.M.graphics(4, 32).to_image()).all() - graphics = l.graphics(4, 32).to_image() - assert graphics.shape == (127, 256, 4) - assert graphics[64, 128, 1] == 67 - m_graphics = l.M.graphics(4, 32).to_image() - assert m_graphics.shape == (127, 256, 4) - assert m_graphics[64, 128, 1] == 72 +def test_layout_R(): + assert (temperate_1012 == l1012.R.graphics(4, 32).to_image()).all() - r_graphics = l.R.graphics(4, 32).to_image() - assert r_graphics.shape == (127, 256, 4) - assert r_graphics[64, 128, 1] == 67 - t_graphics = l.T.graphics(4, 32).to_image() - assert t_graphics.shape == (127, 256, 4) - assert t_graphics[64, 128, 1] == 67 +def test_layout_T(): + assert (temperate_1012 == l1012.T.graphics(4, 32).to_image()).all() def test_symmetry():