diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-03-17 19:22:30 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-03-17 19:22:30 -0700 |
commit | 4eb81d21722e79d24321d52ff092bd09afbe141e (patch) | |
tree | 7535a3590174b325de885df8784862f885ad3c20 | |
parent | d918fd60d587f5934b03858e5473ee3606ac0271 (diff) |
complete test for image compression
-rwxr-xr-x | tests/runner.py | 28 | ||||
-rw-r--r-- | tests/screenshot2.png | bin | 0 -> 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 Binary files differnew file mode 100644 index 00000000..f8a29fbe --- /dev/null +++ b/tests/screenshot2.png |