aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/runner.py28
-rw-r--r--tests/screenshot2.pngbin0 -> 203164 bytes
2 files changed, 18 insertions, 10 deletions
diff --git a/tests/runner.py b/tests/runner.py
index b14151a4..dd211bd3 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6340,18 +6340,26 @@ f.close()
open(os.path.join(self.get_dir(), 'sdl_image.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_image.c')).read()))
Popen([EMCC, os.path.join(self.get_dir(), 'sdl_image.c'), '--preload-file', 'screenshot.jpg', '-o', 'page.html']).communicate()
- self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?600')
+ self.run_browser('page.html', '', '/report_result?600')
def test_emcc_sdl_image_compressed(self):
- # load an image file, get pixel data
- shutil.copyfile(path_from_root('tests', 'screenshot.jpg'), os.path.join(self.get_dir(), 'screenshot.jpg'))
- open(os.path.join(self.get_dir(), 'sdl_image.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_image.c')).read()))
-
- Popen([EMCC, os.path.join(self.get_dir(), 'sdl_image.c'), '--preload-file', 'screenshot.jpg', '-o', 'page.html',
- '--compression', '%s,%s,%s' % (path_from_root('third_party', 'lzma.js', 'lzma-native'),
- path_from_root('third_party', 'lzma.js', 'lzma-decoder.js'),
- 'LZMA.decompress')]).communicate()
- self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?600')
+ for image, worth_compressing, width, height in [(path_from_root('tests', 'screenshot2.png'), True, 300, 225),
+ (path_from_root('tests', 'screenshot.jpg'), False, 600, 450)]:
+ self.clear()
+ print image, worth_compressing
+
+ basename = os.path.basename(image)
+ shutil.copyfile(image, os.path.join(self.get_dir(), basename))
+ open(os.path.join(self.get_dir(), 'sdl_image.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_image.c')).read()).replace('screenshot.jpg', basename).replace('600', str(width)).replace('450', str(height)))
+
+ Popen([EMCC, os.path.join(self.get_dir(), 'sdl_image.c'), '--preload-file', basename, '-o', 'page.html',
+ '--compression', '%s,%s,%s' % (path_from_root('third_party', 'lzma.js', 'lzma-native'),
+ path_from_root('third_party', 'lzma.js', 'lzma-decoder.js'),
+ 'LZMA.decompress')]).communicate()
+ assert ('.compress' in open('page.js').read()) == worth_compressing, 'do not compress image if not worth it'
+ if worth_compressing:
+ shutil.move(os.path.join(self.get_dir(), basename), basename + '.renamedsoitcannotbefound');
+ self.run_browser('page.html', '', '/report_result?' + str(width))
def test_emcc_worker(self):
# Test running in a web worker
diff --git a/tests/screenshot2.png b/tests/screenshot2.png
new file mode 100644
index 00000000..f8a29fbe
--- /dev/null
+++ b/tests/screenshot2.png
Binary files differ