aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runner.py8
-rw-r--r--tests/sdl_canvas.c (renamed from tests/sdl_font.c)20
2 files changed, 16 insertions, 12 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 7691d41b..bf4161da 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6375,11 +6375,11 @@ f.close()
shutil.move(os.path.join(self.get_dir(), basename), basename + '.renamedsoitcannotbefound');
self.run_browser('page.html', '', '/report_result?' + str(width))
- def test_sdl_font(self):
- open(os.path.join(self.get_dir(), 'sdl_font.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_font.c')).read()))
+ def test_sdl_canvas(self):
+ open(os.path.join(self.get_dir(), 'sdl_canvas.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_canvas.c')).read()))
- Popen(['python', EMCC, os.path.join(self.get_dir(), 'sdl_font.c'), '-o', 'page.html']).communicate()
- self.run_browser('page.html', '', '/report_result?80')
+ Popen(['python', EMCC, os.path.join(self.get_dir(), 'sdl_canvas.c'), '-o', 'page.html']).communicate()
+ self.run_browser('page.html', '', '/report_result?3900')
def test_sdl_key(self):
open(os.path.join(self.get_dir(), 'pre.js'), 'w').write('''
diff --git a/tests/sdl_font.c b/tests/sdl_canvas.c
index f4f26355..a73c4351 100644
--- a/tests/sdl_font.c
+++ b/tests/sdl_canvas.c
@@ -15,13 +15,6 @@ int main() {
SDL_Color color = { 0xff, 0x99, 0x00, 0x77 };
SDL_Surface *text = TTF_RenderText_Solid(font, "hello orange world", color);
- SDL_LockSurface(text);
- int sum = 0;
- for (int i = 0; i < text->h; i++) {
- sum += *((char*)text->pixels + i*text->w*4 + i*4 + 0);
- }
- printf("Sum: %d\n", sum);
- SDL_UnlockSurface(text);
SDL_Color color2 = { 0xbb, 0, 0xff, 0 };
SDL_Surface *text2 = TTF_RenderText_Solid(font, "a second line, purple", color2);
@@ -32,9 +25,20 @@ int main() {
dest.y = 100;
SDL_BlitSurface (text2, NULL, screen, &dest);
+ // fill stuff
+ SDL_Rect rect = { 200, 200, 175, 125 };
+ SDL_FillRect(screen, &rect, 0x2222ff00);
+
SDL_Flip(screen);
- printf("you should see two lines of text in different colors.\n");
+ SDL_LockSurface(screen);
+ int sum = 0;
+ for (int i = 0; i < screen->h; i++) {
+ sum += *((char*)screen->pixels + i*screen->w*4 + i*4 + 0);
+ }
+ printf("Sum: %d\n", sum);
+
+ printf("you should see two lines of text in different colors and a blue rectangle\n");
SDL_Quit();