diff options
author | Björn-Egil Dahlberg <[email protected]> | 2009-11-26 01:58:24 +0100 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2009-12-03 14:42:46 +0100 |
commit | 998ccfc3dbef52b2470c73a1a03d2d0b95a3acd7 (patch) | |
tree | 81b48d48f42d5c094fd21e4316189afa01d5162c /lib | |
parent | 8d2bc786caa82be22d0259cd4a8720a101775eb4 (diff) | |
download | otp-998ccfc3dbef52b2470c73a1a03d2d0b95a3acd7.tar.gz otp-998ccfc3dbef52b2470c73a1a03d2d0b95a3acd7.tar.bz2 otp-998ccfc3dbef52b2470c73a1a03d2d0b95a3acd7.zip |
Add test cases for egd_primitives
Diffstat (limited to 'lib')
-rw-r--r-- | lib/percept/test/egd_SUITE.erl | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/lib/percept/test/egd_SUITE.erl b/lib/percept/test/egd_SUITE.erl index 603ad628d3..a2595400dd 100644 --- a/lib/percept/test/egd_SUITE.erl +++ b/lib/percept/test/egd_SUITE.erl @@ -29,6 +29,7 @@ -export([ image_create_and_destroy/1, image_shape/1, + image_primitives/1, image_colors/1, image_font/1, image_png_compliant/1 @@ -38,8 +39,7 @@ -define(default_timeout, ?t:minutes(1)). init_per_suite(Config) when is_list(Config) -> - {A1,A2,A3} = now(), - random:seed(A1, A2, A3), + random:seed(now()), Config. end_per_suite(Config) when is_list(Config) -> @@ -59,6 +59,7 @@ all(suite) -> [ image_create_and_destroy, image_shape, + image_primitives, image_colors, image_font, image_png_compliant @@ -145,7 +146,43 @@ image_shape(Config) when is_list(Config) -> ?line ok = egd:destroy(Im), erase(image_size), ok. - + +image_primitives(suite) -> + []; +image_primitives(doc) -> + ["Image shape api test."]; +image_primitives(Config) when is_list(Config) -> + {W,H} = get_size(?config(max_size, Config)), + put(image_size, {W,H}), + + ?line Im0 = egd_primitives:create(W, H), + ?line Fgc = egd:color({25,25,255}), + ?line Bgc = egd:color({0,250,25}), + + ?line Im1 = lists:foldl(fun + ({Function, Arguments}, Im) -> + ?line erlang:apply(egd_primitives, Function, [Im|Arguments]) + end, Im0, + [{Fs, [get_point(), get_point(), Bgc]} || Fs <- [line, rectangle, filledEllipse, arc]] ++ + [{pixel, [get_point(), Bgc]}, + {filledTriangle, [get_point(), get_point(), get_point(), Bgc]}]), + + Pt1 = get_point(), + Pt2 = get_point(), + + ?line Im2 = egd_primitives:filledRectangle(Im1, Pt1, Pt2, Fgc), + + ?line Bitmap = egd_render:binary(Im2, opaque), + + ?line ok = bitmap_point_has_color(Bitmap, {W,H}, Pt2, Fgc), + ?line ok = bitmap_point_has_color(Bitmap, {W,H}, Pt1, Fgc), + + erase(image_size), + ok. + + + + image_font(suite) -> []; image_font(doc) -> |