aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-02-12 11:47:43 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-02-12 11:47:43 -0800
commitf8cb7deeffa7c2bc79f938821759634e8dce0168 (patch)
tree636fa72d046ca4ed22be48fba8b21e61ead34735 /tests
parent61f0d198560a3ebcc074b29f7a01aa6ce63f0afa (diff)
parent35383300f4a420c3dbb878a83d944bb5506f7c7e (diff)
Merge pull request #2118 from inolen/sdl_lazy_init_fix
initialize pixel buffer inside of makeSurface for SDL_SWSURFACE
Diffstat (limited to 'tests')
-rw-r--r--tests/sdl_swsurface.c22
-rw-r--r--tests/test_browser.py3
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/sdl_swsurface.c b/tests/sdl_swsurface.c
new file mode 100644
index 00000000..93141857
--- /dev/null
+++ b/tests/sdl_swsurface.c
@@ -0,0 +1,22 @@
+#include <assert.h>
+#include <stdio.h>
+#include <SDL/SDL.h>
+
+int main(int argc, char** argv) {
+ SDL_Init(SDL_INIT_VIDEO);
+ SDL_Surface *screen = SDL_SetVideoMode(256, 256, 32, SDL_SWSURFACE);
+
+ // pixels should always be initialized for software surfaces,
+ // without having to call SDL_LockSurface / SDL_UnlockSurface
+ assert(screen->pixels != NULL);
+
+ SDL_Quit();
+
+#if EMSCRIPTEN
+ int result = 1;
+ REPORT_RESULT();
+#endif
+
+ return 0;
+}
+
diff --git a/tests/test_browser.py b/tests/test_browser.py
index 8bcd708e..275f41c6 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -660,6 +660,9 @@ If manually bisecting:
shutil.move(os.path.join(self.get_dir(), 'datafile.txt'), 'datafile.txt.renamedsoitcannotbefound');
self.run_browser('page.html', '', '/report_result?1')
+ def test_sdl_swsurface(self):
+ self.btest('sdl_swsurface.c', expected='1')
+
def test_sdl_image(self):
# load an image file, get pixel data. Also O2 coverage for --preload-file, and memory-init
shutil.copyfile(path_from_root('tests', 'screenshot.jpg'), os.path.join(self.get_dir(), 'screenshot.jpg'))