summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/python/tests/base.py
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-03-30 17:51:55 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-03-30 17:51:55 +0100
commita8251d041ac323712a00d5fed3e51fa5ad7bc987 (patch)
tree1f09b6fd2589b3f896601de0c15c47fe96380c6c /src/gallium/state_trackers/python/tests/base.py
parentaf25470a5430c68e157489ff095baa5d548d8783 (diff)
python/test: Move the image comparison logic to the base test class.
Diffstat (limited to 'src/gallium/state_trackers/python/tests/base.py')
-rw-r--r--src/gallium/state_trackers/python/tests/base.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py
index 8477aa5fc9..2df2af0cdf 100644
--- a/src/gallium/state_trackers/python/tests/base.py
+++ b/src/gallium/state_trackers/python/tests/base.py
@@ -33,6 +33,8 @@ Loosely inspired on Python's unittest module.
"""
+import sys
+
from gallium import *
@@ -115,6 +117,23 @@ class Test:
self._run(result)
result.summary()
+ def assert_rgba(self, surface, x, y, w, h, expected_rgba, pixel_tol=4.0/256, surface_tol=0.85):
+ total = h*w
+ different = surface.compare_tile_rgba(x, y, w, h, expected_rgba, tol=pixel_tol)
+ if different:
+ sys.stderr.write("%u out of %u pixels differ\n" % (different, total))
+
+ if float(total - different)/float(total) < surface_tol:
+ if 0:
+ rgba = FloatArray(h*w*4)
+ surface.get_tile_rgba(x, y, w, h, rgba)
+ show_image(w, h, Result=rgba, Expected=expected_rgba)
+ save_image(w, h, rgba, "result.png")
+ save_image(w, h, expected_rgba, "expected.png")
+ #sys.exit(0)
+
+ raise TestFailure
+
class TestCase(Test):
@@ -190,4 +209,4 @@ class TestResult:
print "%u tests, %u passed, %u skipped, %u failed" % (self.tests, self.passed, self.skipped, self.failed)
for description in self.failed_descriptions:
print " %s" % description
- \ No newline at end of file
+