-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auto-test: sync to ags4 from ags3 engine render test
- Loading branch information
1 parent
d7ee3c6
commit 1e99c9d
Showing
4 changed files
with
200 additions
and
1 deletion.
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,157 @@ | ||
// Test EngineRender Module Script | ||
int GetTestEngineRenderCount() | ||
{ | ||
return 8; | ||
} | ||
|
||
void _FillSprite(DynamicSprite *spr, int color) | ||
{ | ||
DrawingSurface *ds = spr.GetDrawingSurface(); | ||
ds.Clear(color); | ||
ds.Release(); | ||
} | ||
|
||
// Takes screenshot 1:1 and compares a part of the image with the given sprite | ||
bool _TakeScreenshotAndCompareRect(int rx, int ry, int rw, int rh, DynamicSprite *match_with) | ||
{ | ||
DynamicSprite *shot = DynamicSprite.CreateFromScreenShot(Screen.Width, Screen.Height); | ||
DrawingSurface *test_ds = shot.GetDrawingSurface(); | ||
DrawingSurface *match_ds = match_with.GetDrawingSurface(); | ||
|
||
for (int y = 0; y < rh; y++) { | ||
for (int x = 0; x < rw; x++) { | ||
if (test_ds.GetPixel(x + rx, y + ry) != match_ds.GetPixel(x, y)) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void TestEngineRender() | ||
{ | ||
tap.Comment("start EngineRender tests"); | ||
tap.Comment(String.Format("System.HardwareAcceleration = %d", System.HardwareAcceleration)); | ||
|
||
// | ||
// Object texture update after dynamic sprite change | ||
// | ||
{ | ||
int color1 = 10; | ||
int color2 = 11; | ||
Object* oDynamicObject = object[0]; | ||
DynamicSprite* dynspr = DynamicSprite.Create(10, 10, false); | ||
_FillSprite(dynspr, color1); | ||
oDynamicObject.Graphic = dynspr.Graphic; | ||
oDynamicObject.X = 100; | ||
oDynamicObject.Y = 100; | ||
oDynamicObject.Visible = true; | ||
Wait(1); | ||
tap.ok( | ||
_TakeScreenshotAndCompareRect(oDynamicObject.X, oDynamicObject.Y - dynspr.Height, dynspr.Width, dynspr.Height, dynspr), | ||
"DynamicSprite update 1-1 (room object) is matched"); | ||
|
||
|
||
_FillSprite(dynspr, color2); | ||
Wait(1); | ||
tap.ok( | ||
_TakeScreenshotAndCompareRect(oDynamicObject.X, oDynamicObject.Y - dynspr.Height, dynspr.Width, dynspr.Height, dynspr), | ||
"DynamicSprite update 1-2 (room object) is matched"); | ||
|
||
oDynamicObject.Visible = false; | ||
oDynamicObject.Graphic = 0; | ||
dynspr.Delete(); | ||
} | ||
|
||
// | ||
// Object texture update after dynamic sprite recreated | ||
// with coincidentally the same sprite ID | ||
// | ||
{ | ||
int color1 = 10; | ||
int color2 = 11; | ||
DynamicSprite* dynspr = DynamicSprite.Create(10, 10, false); | ||
Object* oDynamicObject = object[1]; | ||
_FillSprite(dynspr, color1); | ||
oDynamicObject.Graphic = dynspr.Graphic; | ||
oDynamicObject.X = 100; | ||
oDynamicObject.Y = 100; | ||
oDynamicObject.Visible = true; | ||
Wait(1); | ||
tap.ok( | ||
_TakeScreenshotAndCompareRect(oDynamicObject.X, oDynamicObject.Y - dynspr.Height, dynspr.Width, dynspr.Height, dynspr), | ||
"DynamicSprite recreate 1-1 (room object) is matched"); | ||
|
||
dynspr.Delete(); | ||
dynspr = DynamicSprite.Create(10, 10, false); | ||
_FillSprite(dynspr, color2); | ||
oDynamicObject.Graphic = dynspr.Graphic; | ||
Wait(1); | ||
tap.ok( | ||
_TakeScreenshotAndCompareRect(oDynamicObject.X, oDynamicObject.Y - dynspr.Height, dynspr.Width, dynspr.Height, dynspr), | ||
"DynamicSprite recreate 1-2 (room object) is matched"); | ||
|
||
oDynamicObject.Visible = false; | ||
oDynamicObject.Graphic = 0; | ||
dynspr.Delete(); | ||
} | ||
|
||
// | ||
// Overlay texture update after dynamic sprite change; | ||
// We test overlays separately, because they have slightly different | ||
// path of updating their textures in the engine. Also they are | ||
// dynamic objects themselves and may be deleted completely. | ||
// | ||
{ | ||
int color1 = 10; | ||
int color2 = 11; | ||
DynamicSprite* dynspr = DynamicSprite.Create(10, 10, false); | ||
_FillSprite(dynspr, color1); | ||
Overlay* over = Overlay.CreateGraphical(100, 100, dynspr.Graphic, true); | ||
Wait(1); | ||
tap.ok( | ||
_TakeScreenshotAndCompareRect(over.X, over.Y, dynspr.Width, dynspr.Height, dynspr), | ||
"DynamicSprite update 2-1 (overlay) is matched"); | ||
|
||
|
||
_FillSprite(dynspr, color2); | ||
Wait(1); | ||
tap.ok( | ||
_TakeScreenshotAndCompareRect(over.X, over.Y, dynspr.Width, dynspr.Height, dynspr), | ||
"DynamicSprite update 2-2 (overlay) is matched"); | ||
|
||
over.Remove(); | ||
dynspr.Delete(); | ||
} | ||
|
||
// | ||
// Overlay texture update after dynamic sprite recreated | ||
// with coincidentally the same sprite ID | ||
// | ||
{ | ||
int color1 = 10; | ||
int color2 = 11; | ||
DynamicSprite* dynspr = DynamicSprite.Create(10, 10, false); | ||
_FillSprite(dynspr, color1); | ||
Overlay* over = Overlay.CreateGraphical(100, 100, dynspr.Graphic, true); | ||
Wait(1); | ||
tap.ok( | ||
_TakeScreenshotAndCompareRect(over.X, over.Y, dynspr.Width, dynspr.Height, dynspr), | ||
"DynamicSprite recreate 2-1 (overlay) is matched"); | ||
|
||
dynspr.Delete(); | ||
dynspr = DynamicSprite.Create(10, 10, false); | ||
_FillSprite(dynspr, color2); | ||
over.Graphic = dynspr.Graphic; | ||
Wait(1); | ||
tap.ok( | ||
_TakeScreenshotAndCompareRect(over.X, over.Y, dynspr.Width, dynspr.Height, dynspr), | ||
"DynamicSprite recreate 2-2 (overlay) is matched"); | ||
|
||
over.Remove(); | ||
dynspr.Delete(); | ||
} | ||
|
||
tap.Comment("end EngineRender tests"); | ||
} |
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,11 @@ | ||
// Test EngineRender Module Header | ||
// | ||
// This module's purpose is to test engine's render, as much as possible | ||
// from the script. The objects and sprites may be tested on their own, but | ||
// engine may have mistakes in the drawing routine, which will not be reflected | ||
// in game object states. | ||
// The only available method of testing engine's render result at the moment | ||
// is by taking screenshots and analysing their contents. | ||
// | ||
import void TestEngineRender(); | ||
import int GetTestEngineRenderCount(); |