kekw
This commit is contained in:
45
minilibx-linux/test/Makefile.mk
Normal file
45
minilibx-linux/test/Makefile.mk
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
INC=%%%%
|
||||
|
||||
INCLIB=$(INC)/../lib
|
||||
|
||||
UNAME := $(shell uname)
|
||||
|
||||
CFLAGS= -I$(INC) -O3 -I.. -g
|
||||
|
||||
NAME= mlx-test
|
||||
SRC = main.c
|
||||
OBJ = $(SRC:%.c=%.o)
|
||||
|
||||
LFLAGS = -L.. -lmlx -L$(INCLIB) -lXext -lX11 -lm
|
||||
|
||||
ifeq ($(UNAME), Darwin)
|
||||
# mac
|
||||
CC = clang
|
||||
else ifeq ($(UNAME), FreeBSD)
|
||||
# FreeBSD
|
||||
CC = clang
|
||||
else
|
||||
#Linux and others...
|
||||
CC = gcc
|
||||
LFLAGS += -lbsd
|
||||
endif
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
$(NAME): $(OBJ)
|
||||
$(CC) -o $(NAME) $(OBJ) $(LFLAGS)
|
||||
|
||||
show:
|
||||
@printf "UNAME : $(UNAME)\n"
|
||||
@printf "NAME : $(NAME)\n"
|
||||
@printf "CC : $(CC)\n"
|
||||
@printf "CFLAGS : $(CFLAGS)\n"
|
||||
@printf "LFLAGS : $(LFLAGS)\n"
|
||||
@printf "SRC :\n $(SRC)\n"
|
||||
@printf "OBJ :\n $(OBJ)\n"
|
||||
|
||||
clean:
|
||||
rm -f $(NAME) $(OBJ) *~ core *.core
|
||||
|
||||
re: clean all
|
287
minilibx-linux/test/main.c
Normal file
287
minilibx-linux/test/main.c
Normal file
@ -0,0 +1,287 @@
|
||||
|
||||
#include "mlx.h"
|
||||
#include "mlx_int.h"
|
||||
|
||||
#define WIN1_SX 242
|
||||
#define WIN1_SY 242
|
||||
#define IM1_SX 42
|
||||
#define IM1_SY 42
|
||||
#define IM3_SX 242
|
||||
#define IM3_SY 242
|
||||
|
||||
void *mlx;
|
||||
void *win1;
|
||||
void *win2;
|
||||
void *win3;
|
||||
void *im1;
|
||||
void *im2;
|
||||
void *im3;
|
||||
void *im4;
|
||||
int bpp1;
|
||||
int bpp2;
|
||||
int bpp3;
|
||||
int bpp4;
|
||||
int sl1;
|
||||
int sl2;
|
||||
int sl3;
|
||||
int sl4;
|
||||
int endian1;
|
||||
int endian2;
|
||||
int endian3;
|
||||
int endian4;
|
||||
char *data1;
|
||||
char *data2;
|
||||
char *data3;
|
||||
char *data4;
|
||||
int xpm1_x;
|
||||
int xpm1_y;
|
||||
|
||||
int local_endian;
|
||||
|
||||
int color_map_1(void *win,int w,int h);
|
||||
int color_map_2(unsigned char *data,int bpp,int sl,int w,int h,int endian, int type);
|
||||
|
||||
int expose_win1(void *p)
|
||||
{
|
||||
mlx_put_image_to_window(mlx,win1,im3,0,0);
|
||||
}
|
||||
|
||||
int expose_win2(void *p)
|
||||
{
|
||||
mlx_put_image_to_window(mlx,win2,im4,0,0);
|
||||
mlx_put_image_to_window(mlx,win2,im2,0,0);
|
||||
}
|
||||
|
||||
int key_win1(int key,void *p)
|
||||
{
|
||||
printf("Key in Win1 : %d\n",key);
|
||||
if (key==0xFF1B)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int key_win2(int key,void *p)
|
||||
{
|
||||
printf("Key in Win2 : %d\n",key);
|
||||
if (key==0xFF1B)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int key_win3(int key,void *p)
|
||||
{
|
||||
printf("Key in Win3 : %d\n",key);
|
||||
if (key==0xFF1B)
|
||||
mlx_destroy_window(mlx,win3);
|
||||
}
|
||||
|
||||
int mouse_win1(int button,int x,int y, void *p)
|
||||
{
|
||||
printf("Mouse in Win1, button %d at %dx%d.\n",button,x,y);
|
||||
}
|
||||
|
||||
int mouse_win2(int button,int x,int y, void *p)
|
||||
{
|
||||
printf("Mouse in Win2, button %d at %dx%d.\n",button,x,y);
|
||||
}
|
||||
|
||||
int mouse_win3(int x,int y, void *p)
|
||||
{
|
||||
printf("Mouse moving in Win3, at %dx%d.\n",x,y);
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
|
||||
printf("MinilibX Test Program\n");
|
||||
a = 0x11223344;
|
||||
if (((unsigned char *)&a)[0] == 0x11)
|
||||
local_endian = 1;
|
||||
else
|
||||
local_endian = 0;
|
||||
printf(" => Local Endian : %d\n",local_endian);
|
||||
|
||||
printf(" => Connection ...");
|
||||
if (!(mlx = mlx_init()))
|
||||
{
|
||||
printf(" !! KO !!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("OK (use_xshm %d pshm_format %d)\n",((t_xvar *)mlx)->use_xshm,((t_xvar *)mlx)->pshm_format);
|
||||
|
||||
printf(" => Window1 %dx%d \"Title 1\" ...",WIN1_SX,WIN1_SY);
|
||||
if (!(win1 = mlx_new_window(mlx,WIN1_SX,WIN1_SY,"Title1")))
|
||||
{
|
||||
printf(" !! KO !!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
printf(" => Colormap sans event ...");
|
||||
color_map_1(win1,WIN1_SX,WIN1_SY);
|
||||
printf("OK\n");
|
||||
sleep(2);
|
||||
|
||||
printf(" => Clear Window ...");
|
||||
mlx_clear_window(mlx,win1);
|
||||
printf("OK\n");
|
||||
sleep(2);
|
||||
|
||||
printf(" => Image1 ZPixmap %dx%d ...",IM1_SX,IM1_SY);
|
||||
if (!(im1 = mlx_new_image(mlx,IM1_SX,IM1_SY)))
|
||||
{
|
||||
printf(" !! KO !!\n");
|
||||
exit(1);
|
||||
}
|
||||
data1 = mlx_get_data_addr(im1,&bpp1,&sl1,&endian1);
|
||||
printf("OK (bpp1: %d, sizeline1: %d endian: %d type: %d)\n",bpp1,sl1,endian1,
|
||||
((t_img *)im1)->type);
|
||||
|
||||
printf(" => Fill Image1 ...");
|
||||
color_map_2(data1,bpp1,sl1,IM1_SX,IM1_SY,endian1, 1);
|
||||
printf("OK (pixmap : %d)\n",(int)((t_img *)im1)->pix);
|
||||
|
||||
printf(" => Put Image1 ...");
|
||||
mlx_put_image_to_window(mlx,win1,im1,20,20);
|
||||
printf("OK\n");
|
||||
sleep(2);
|
||||
|
||||
printf(" => Destroy Image1 ... ");
|
||||
mlx_destroy_image(mlx, im1);
|
||||
printf("OK\n");
|
||||
sleep(2);
|
||||
|
||||
printf(" => Image3 ZPixmap %dx%d ...",IM3_SX,IM3_SY);
|
||||
if (!(im3 = mlx_new_image(mlx,IM3_SX,IM3_SY)))
|
||||
{
|
||||
printf(" !! KO !!\n");
|
||||
exit(1);
|
||||
}
|
||||
data3 = mlx_get_data_addr(im3,&bpp3,&sl3,&endian3);
|
||||
printf("OK (bpp3 %d, sizeline3 %d endian3 %d type %d)\n",bpp3,sl3,endian3,
|
||||
((t_img *)im3)->type);
|
||||
|
||||
printf(" => Fill Image3 ...");
|
||||
color_map_2(data3,bpp3,sl3,IM3_SX,IM3_SY,endian3, 1);
|
||||
printf("OK (pixmap : %d)\n",(int)((t_img *)im3)->pix);
|
||||
|
||||
printf(" => Put Image3 ...");
|
||||
mlx_put_image_to_window(mlx,win1,im3,20,20);
|
||||
printf("OK\n");
|
||||
sleep(2);
|
||||
|
||||
printf(" => String ...");
|
||||
mlx_string_put(mlx,win1,5,WIN1_SY/2,0xFF99FF,"String output");
|
||||
mlx_string_put(mlx,win1,15,WIN1_SY/2+20,0x00FFFF,"MinilibX test");
|
||||
printf("OK\n");
|
||||
sleep(2);
|
||||
|
||||
printf(" => Xpm from file ...");
|
||||
if (!(im2 = mlx_xpm_file_to_image(mlx,"open.xpm",&xpm1_x,&xpm1_y)))
|
||||
{
|
||||
printf(" !! KO !!\n");
|
||||
exit(1);
|
||||
}
|
||||
data2 = mlx_get_data_addr(im2,&bpp2,&sl2,&endian2);
|
||||
printf("OK (xpm %dx%d)(img bpp2: %d, sizeline2: %d endian: %d type: %d)\n",
|
||||
xpm1_x,xpm1_y,bpp2,sl2,endian2,((t_img *)im2)->type);
|
||||
sleep(2);
|
||||
|
||||
printf(" => Put xpm ...");
|
||||
mlx_put_image_to_window(mlx,win1,im2,0,0);
|
||||
mlx_put_image_to_window(mlx,win1,im2,100,100);
|
||||
printf("OK\n");
|
||||
sleep(2);
|
||||
|
||||
printf(" => 2nd window,");
|
||||
win2 = mlx_new_window(mlx,WIN1_SX,WIN1_SY,"Title2");
|
||||
if (!(im4 = mlx_new_image(mlx,IM3_SX, IM3_SY)))
|
||||
{
|
||||
printf(" !! KO !!\n");
|
||||
exit(1);
|
||||
}
|
||||
data4 = mlx_get_data_addr(im4,&bpp4,&sl4,&endian4);
|
||||
color_map_2(data4,bpp4,sl4,IM3_SX,IM3_SY,endian4, 2);
|
||||
|
||||
printf(" 3rd window, Installing hooks ...");
|
||||
win3 = mlx_new_window(mlx,WIN1_SX,WIN1_SY,"Title3");
|
||||
mlx_expose_hook(win1,expose_win1,0);
|
||||
mlx_mouse_hook(win1,mouse_win1,0);
|
||||
mlx_key_hook(win1,key_win1,0);
|
||||
mlx_expose_hook(win2,expose_win2,0);
|
||||
mlx_mouse_hook(win2,mouse_win2,0);
|
||||
mlx_key_hook(win2,key_win2,0);
|
||||
mlx_key_hook(win3,key_win3,0);
|
||||
|
||||
mlx_hook(win3, MotionNotify, PointerMotionMask, mouse_win3, 0);
|
||||
|
||||
printf("OK\nNow in Loop. Just play. Esc in 3 to destroy, 1&2 to quit.\n");
|
||||
|
||||
mlx_loop(mlx);
|
||||
}
|
||||
|
||||
|
||||
int color_map_1(void *win,int w,int h)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int color;
|
||||
|
||||
x = w;
|
||||
while (x--)
|
||||
{
|
||||
y = h;
|
||||
while (y--)
|
||||
{
|
||||
color = (x*255)/w+((((w-x)*255)/w)<<16)+(((y*255)/h)<<8);
|
||||
mlx_pixel_put(mlx,win,x,y,color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int color_map_2(unsigned char *data,int bpp,int sl,int w,int h,int endian, int type)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int opp;
|
||||
int dec;
|
||||
int color;
|
||||
int color2;
|
||||
unsigned char *ptr;
|
||||
|
||||
opp = bpp/8;
|
||||
printf("(opp : %d) ",opp);
|
||||
y = h;
|
||||
while (y--)
|
||||
{
|
||||
ptr = data+y*sl;
|
||||
x = w;
|
||||
while (x--)
|
||||
{
|
||||
if (type==2)
|
||||
color = (y*255)/w+((((w-x)*255)/w)<<16)
|
||||
+(((y*255)/h)<<8);
|
||||
else
|
||||
color = (x*255)/w+((((w-x)*255)/w)<<16)+(((y*255)/h)<<8);
|
||||
color2 = mlx_get_color_value(mlx,color);
|
||||
dec = opp;
|
||||
while (dec--)
|
||||
if (endian==local_endian)
|
||||
{
|
||||
if (endian)
|
||||
*(ptr+x*opp+dec) = ((unsigned char *)(&color2))[4-opp+dec];
|
||||
else
|
||||
*(ptr+x*opp+dec) = ((unsigned char *)(&color2))[dec];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (endian)
|
||||
*(ptr+x*opp+dec) = ((unsigned char *)(&color2))[opp-1-dec];
|
||||
else
|
||||
*(ptr+x*opp+dec) = ((unsigned char *)(&color2))[3-dec];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
31
minilibx-linux/test/new_win.c
Normal file
31
minilibx-linux/test/new_win.c
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
|
||||
|
||||
#include "mlx.h"
|
||||
|
||||
|
||||
void *mlx;
|
||||
void *win1;
|
||||
void *win2;
|
||||
|
||||
|
||||
|
||||
int gere_mouse(int x,int y,int button,void*toto)
|
||||
{
|
||||
printf("Mouse event - new win\n");
|
||||
mlx_destroy_window(mlx,win1);
|
||||
win1 = mlx_new_window(mlx,random()%500,random()%500,"new win");
|
||||
mlx_mouse_hook(win1,gere_mouse,0);
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
srandom(time(0));
|
||||
mlx = mlx_init();
|
||||
win1 = mlx_new_window(mlx,300,300,"win1");
|
||||
win2 = mlx_new_window(mlx,600,600,"win2");
|
||||
mlx_mouse_hook(win1,gere_mouse,0);
|
||||
mlx_mouse_hook(win2,gere_mouse,0);
|
||||
mlx_loop(mlx);
|
||||
}
|
1439
minilibx-linux/test/open.xpm
Normal file
1439
minilibx-linux/test/open.xpm
Normal file
File diff suppressed because it is too large
Load Diff
230
minilibx-linux/test/open24.xpm
Normal file
230
minilibx-linux/test/open24.xpm
Normal file
@ -0,0 +1,230 @@
|
||||
/* XPM */
|
||||
static char *open[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 45 55 168 2",
|
||||
/* colors */
|
||||
".. s None c None",
|
||||
".# c #450304",
|
||||
".a c #ce7e7c",
|
||||
".b c #b94344",
|
||||
".c c #b65254",
|
||||
".d c #780204",
|
||||
".e c #b04c4c",
|
||||
".f c #b00204",
|
||||
".g c #8a8a64",
|
||||
".h c #969a24",
|
||||
".i c #b6b60c",
|
||||
".j c #cac614",
|
||||
".k c #cece34",
|
||||
".l c #cace54",
|
||||
".m c #caca94",
|
||||
".n c #c24e4c",
|
||||
".o c #aa0204",
|
||||
".p c #9e4244",
|
||||
".q c #bc0204",
|
||||
".r c #a40204",
|
||||
".s c #9e262c",
|
||||
".t c #8c3a3c",
|
||||
".u c #5c1414",
|
||||
".v c #5b0204",
|
||||
".w c #700204",
|
||||
".x c #722214",
|
||||
".y c #b52624",
|
||||
".z c #8e3234",
|
||||
".A c #b60204",
|
||||
".B c #c20204",
|
||||
".C c #860204",
|
||||
".D c #560304",
|
||||
".E c #800204",
|
||||
".F c #9e0204",
|
||||
".G c #920204",
|
||||
".H c #620204",
|
||||
".I c #a41314",
|
||||
".J c #996a6c",
|
||||
".K c #920d09",
|
||||
".L c #c80204",
|
||||
".M c #690204",
|
||||
".N c #980204",
|
||||
".O c #984c4c",
|
||||
".P c #e2dedc",
|
||||
".Q c #ae5e5c",
|
||||
".R c #bc6a6c",
|
||||
".S c #a21a1c",
|
||||
".T c #8a0a04",
|
||||
".U c #671e1c",
|
||||
".V c #941b1c",
|
||||
".W c #b8b4b4",
|
||||
".X c #e8e6e4",
|
||||
".Y c #ccb4b4",
|
||||
".Z c #c07c7c",
|
||||
".0 c #f3f2eb",
|
||||
".1 c #b49696",
|
||||
".2 c #521614",
|
||||
".3 c #9e5a5c",
|
||||
".4 c #d4d4d4",
|
||||
".5 c #a7a5a1",
|
||||
".6 c #dec4c4",
|
||||
".7 c #e4d6d4",
|
||||
".8 c #f4f2f4",
|
||||
".9 c #cccac4",
|
||||
"#. c #9a161c",
|
||||
"## c #8c0204",
|
||||
"#a c #862c2c",
|
||||
"#b c #7e5e5c",
|
||||
"#c c #a39694",
|
||||
"#d c #6b6667",
|
||||
"#e c #322624",
|
||||
"#f c #b09e9c",
|
||||
"#g c #b23234",
|
||||
"#h c #500304",
|
||||
"#i c #222224",
|
||||
"#j c #2e322c",
|
||||
"#k c #925c5c",
|
||||
"#l c #721a1c",
|
||||
"#m c #6e6e6c",
|
||||
"#n c #0a0a0c",
|
||||
"#o c #b2b2b4",
|
||||
"#p c #8e6264",
|
||||
"#q c #884444",
|
||||
"#r c #8c5c5c",
|
||||
"#s c #121214",
|
||||
"#t c #b2aeac",
|
||||
"#u c #c21e1c",
|
||||
"#v c #6e0e0c",
|
||||
"#w c #623e3c",
|
||||
"#x c #b64e4c",
|
||||
"#y c #bc3634",
|
||||
"#z c #624e1c",
|
||||
"#A c #6e727c",
|
||||
"#B c #824e4c",
|
||||
"#C c #8b8d87",
|
||||
"#D c #a09674",
|
||||
"#E c #766844",
|
||||
"#F c #7a663c",
|
||||
"#G c #828c90",
|
||||
"#H c #beb6a4",
|
||||
"#I c #3a0204",
|
||||
"#J c #8e9298",
|
||||
"#K c #562529",
|
||||
"#L c #7c3838",
|
||||
"#M c #bab294",
|
||||
"#N c #7e4644",
|
||||
"#O c #929a9c",
|
||||
"#P c #762a2c",
|
||||
"#Q c #a60e0c",
|
||||
"#R c #ae1e1c",
|
||||
"#S c #460a0c",
|
||||
"#T c #a6aaa4",
|
||||
"#U c #6a4a4c",
|
||||
"#V c #784c50",
|
||||
"#W c #761214",
|
||||
"#X c #9e1e1c",
|
||||
"#Y c #988c90",
|
||||
"#Z c #821e1c",
|
||||
"#0 c #7a1618",
|
||||
"#1 c #7a6e74",
|
||||
"#2 c #7e7a77",
|
||||
"#3 c #808688",
|
||||
"#4 c #828284",
|
||||
"#5 c #828279",
|
||||
"#6 c #827a64",
|
||||
"#7 c #7e765c",
|
||||
"#8 c #864a34",
|
||||
"#9 c #825a44",
|
||||
"a. c #766e54",
|
||||
"a# c #7e7e74",
|
||||
"aa c #806464",
|
||||
"ab c #7e724c",
|
||||
"ac c #766634",
|
||||
"ad c #765a2c",
|
||||
"ae c #8e7e54",
|
||||
"af c #a69e8c",
|
||||
"ag c #c7c2ac",
|
||||
"ah c #9a2a1c",
|
||||
"ai c #aa3a3c",
|
||||
"aj c #979894",
|
||||
"ak c #70684c",
|
||||
"al c #62522c",
|
||||
"am c #6e5e3c",
|
||||
"an c #92866c",
|
||||
"ao c #968e6c",
|
||||
"ap c #826e54",
|
||||
"aq c #84765c",
|
||||
"ar c #86522c",
|
||||
"as c #7e4624",
|
||||
"at c #7e3614",
|
||||
"au c #6e5254",
|
||||
"av c #712e2c",
|
||||
"aw c #7a5654",
|
||||
"ax c #82727c",
|
||||
"ay c #a63634",
|
||||
"az c #8a6a6c",
|
||||
"aA c #863534",
|
||||
"aB c #5c1a18",
|
||||
"aC c #6a2c2c",
|
||||
"aD c #5e0e14",
|
||||
"aE c #868684",
|
||||
"aF c #922624",
|
||||
"aG c #901614",
|
||||
"aH c #c21614",
|
||||
"aI c #520e0c",
|
||||
"aJ c #805654",
|
||||
"aK c #b00c0c",
|
||||
"aL c #c2221c",
|
||||
/* pixels */
|
||||
"..........................................................................................",
|
||||
"..........................................................................................",
|
||||
".....................................#.a.#................................................",
|
||||
"...................................#.b.c.#.#.#.#...........#.d............................",
|
||||
".................................#.e.f.f.#.g.h.i.j.k.l.m...f.n............................",
|
||||
".................................d.f.o.f.#.#.#.d.d.#.#.#...f.f.d..........................",
|
||||
".................................p.q.q.r.s.t.u.v.w.x.d.d.#.d.r.y.d........................",
|
||||
".................................z.A.B.q.C.D.E.F.G.E.H.E.I.F.q.A.d........................",
|
||||
".................................J.G.f.G.w.K.f.L.B.B.r.M.f.B.L.A.d........................",
|
||||
".................................d.w.N.M.O.P.Q.B.B.o.R.S.E.q.q.T.d........................",
|
||||
".................................d.U.M.V.W.X.Y.q.B.Z.0.1.E.r.N.d..........................",
|
||||
".................................d.2.r.3.4.5.6.A.f.7.8.9#.###a.#..........................",
|
||||
"................................#b.d.L#c#d#e#f.N.V.5#d.4#g.E.d............................",
|
||||
"...............................d#h.r.L#f#i#j#k.M#l#m#n#o.b.r.d............................",
|
||||
"...............................d#h##.q#g#p#q##.q.N#r#s#t#u.q#v.#..........................",
|
||||
"..............#j................#w.w.C.r.q##.r.B.f.T#x#y.L.r.M.d..........................",
|
||||
"............#j#z#j#A#A#j.........d.D.r.M.C.f.r.r.r.q.B.C.N.E#B............................",
|
||||
"..........#j#C#D#E#z#F#G#j.......d.d.#.G##.w.M.M.C.C.d.G.r.u.d............................",
|
||||
"....................#E#H#C#j.........d#I.w.F.f.o.o.o.N.M.#.d..............................",
|
||||
"......................#E#j#J#j......#K.M.#.#.v.w.M.v.##h.H#L.d............................",
|
||||
"..........................#M#j.......v.F.q.r.d.w.w.C.E.M.v.M#N.d..........................",
|
||||
"..........................#E#O#j#j#K##.f.L.L.L.B.q.f##.M.v.w.w#P.d.#...d.d................",
|
||||
"............................#C#E.#.v.o.B.L.L.q.q.q.q.N.M.D#h.M.N.r#Q#R#S.H.J.#............",
|
||||
"............................#j#T#U.C.q.q.o.G.F.f.q.A.N.d.v.v##.o.q.L.r.C.A###k............",
|
||||
"..............................#C#V.N.A.N.f.q.F.C.E.f.F.E.H#n#W.K.I#X#a.z.V.q.d#p.d........",
|
||||
"................................#Y.r.K#Z.K.q.A.G.w#0#b#1#2#3#4#5#5#6#6#7#8.q.G#9..........",
|
||||
"..................#j#oa..5#j..#J#Ja##4#4aa.o.A##.E.xabacadae#Daf#M#Magah.r.qai.#..........",
|
||||
"................aja#akalamanaoapaqaaarasat.r.o.E.w.T.T.E.H.#...........#.d.d.#............",
|
||||
"...........E....#j#j#C#M#j#n#naa#V.O.f.N.F.q.G.d.w.r.C.d.H.#...............#..............",
|
||||
"...........#.F.F.J#n#n#n#n#n#nauav#p.q.N.d.d.w.M.F.F.E.d.U................................",
|
||||
".........E.F.E.E.d.z#n.d#n#n#naw.Uax.r##.d.w.D.M.r.N.E.w.d................................",
|
||||
".........E.F.......d.Fay.E.F#naz.2#A.D#h.r.f.w##.r##.d.H.M................................",
|
||||
".........F.#...........E.E.F.baAaB#A.#.E.f.r.w.N.N.E.waC.#................................",
|
||||
".........F.#...............d.F.E#K#d.H.G.F.G.w.N##.d.D.#..................................",
|
||||
".........F.#....................#Aau.v.E##.w.E.E.w.H.d.......d..av.d......................",
|
||||
".........E.#..................#j#GaC.M.H.M.d.d.w.H.#.d.d.#aC.w.C##.E.d....................",
|
||||
"...........F.................5#O...#aD.w.d.w.H.D.M######.G.F.o.f.o.N.3....................",
|
||||
"...........F.E...........5aEakak.....#.##h#h.v.N.o.f.q.L.L.L.L.L.q.faF....................",
|
||||
"...........E.E......#E#C.5aq#j.....#.v.N.F.d.N.r.F.r.F#Q.I.o.q.L.L.L.y....................",
|
||||
".............E.....................#.E.B.qaG.d.d.d.....#.#.....d#x.b......................",
|
||||
".............E.F...................E.w.L.LaG.#............................................",
|
||||
"...............E.E.................EaA.q.qaG.#............................................",
|
||||
"...............E.F.E.................E.r.r#Z.#............................................",
|
||||
".................E.F.E...............E.G.NaA..............................................",
|
||||
".................E#uaH.................w.dav..............................................",
|
||||
"...................E.E.............EaI.M.w.v.#............................................",
|
||||
"...................................E.D.d.E.waJ............................................",
|
||||
".....................................C.N.N##.M............................................",
|
||||
"..................................#W.f.q.A.f.G#q..........................................",
|
||||
".....................................q.L.L.L.q.V.#........................................",
|
||||
"...................................#.daK.q.qaL.d..........................................",
|
||||
".......................................#.#.#..............................................",
|
||||
"..........................................................................................",
|
||||
"..........................................................................................",
|
||||
".........................................................................................."
|
||||
};
|
1439
minilibx-linux/test/open30.xpm
Normal file
1439
minilibx-linux/test/open30.xpm
Normal file
File diff suppressed because it is too large
Load Diff
94
minilibx-linux/test/run_tests.sh
Executable file
94
minilibx-linux/test/run_tests.sh
Executable file
@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# This very basic script simulate user inputs for the CI
|
||||
# Feel free to update, improve or remove it if proper
|
||||
# intergration tests and/or unit tests are added.
|
||||
|
||||
set -e
|
||||
|
||||
BOLD="\033[1m"
|
||||
RESET="\033[0m"
|
||||
LIGHT_RED="\033[91m"
|
||||
LIGHT_GREEN="\033[92m"
|
||||
LIGHT_CYAN="\033[96m"
|
||||
|
||||
logging(){
|
||||
local type=$1; shift
|
||||
printf "${LIGHT_CYAN}${BOLD}run_tests${RESET} [%b] : %b\n" "$type" "$*"
|
||||
}
|
||||
log_info(){
|
||||
logging "${LIGHT_GREEN}info${RESET}" "$@"
|
||||
}
|
||||
log_error(){
|
||||
logging "${LIGHT_RED}error${RESET}" "$@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
PID=""
|
||||
|
||||
# to properly kill child process executed in background on exit
|
||||
at_exit() {
|
||||
status=$?
|
||||
[ $status -eq 0 ] && log_info "Seem all went well" && exit 0
|
||||
# Code for non-zero exit:
|
||||
if ! kill -s TERM "$PID" 2>/dev/null || ! wait "$PID" ; then
|
||||
log_error "Pid [$PID] died with status $status "
|
||||
fi
|
||||
log_error "Something went wrong. Pid [$PID] has been killed. Status code $status"
|
||||
}
|
||||
# to properly quit from ctrl+c (SIGINT Signal)
|
||||
sigint_handler(){
|
||||
kill -s TERM "$PID"
|
||||
wait
|
||||
log_info "Tests abort"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# look at test/main.c and run ./mlx-test to understand what this function does
|
||||
test_default_main(){
|
||||
${MAKE} -f Makefile.gen all
|
||||
./mlx-test &
|
||||
PID="$!"
|
||||
log_info "./mlx-test running in background, pid:" $PID
|
||||
|
||||
i=25 # waiting 25s mlx-test to be ready for inputs.
|
||||
while [ $i -gt 0 ]; do
|
||||
if ! ps -p $PID > /dev/null ; then
|
||||
wait $PID
|
||||
fi
|
||||
log_info "countdown" $i
|
||||
sleep 1
|
||||
i=$((i - 1))
|
||||
done
|
||||
log_info "Ready to \"just play\" using xdotool"
|
||||
wid1=$(xdotool search --name Title1)
|
||||
wid2=$(xdotool search --name Title2)
|
||||
wid3=$(xdotool search --name Title3)
|
||||
|
||||
xdotool windowfocus $wid3
|
||||
log_info "Focus Win3: Testing move mouse 100 100"
|
||||
xdotool mousemove 100 100
|
||||
log_info "Focus Win3: Testing move mouse 200 200"
|
||||
xdotool mousemove 200 200
|
||||
log_info "Focus Win3: Pressing escape to destroy window \"Win3\""
|
||||
xdotool key Escape
|
||||
|
||||
log_info "Focus Win2: Pressing escape to stop program"
|
||||
xdotool windowfocus $wid2
|
||||
xdotool key Escape
|
||||
}
|
||||
|
||||
main(){
|
||||
case $(uname) in
|
||||
FreeBSD) MAKE=gmake ;;
|
||||
*) MAKE=make ;;
|
||||
esac
|
||||
cd $(dirname $0)
|
||||
trap at_exit EXIT
|
||||
trap sigint_handler INT
|
||||
|
||||
test_default_main
|
||||
}
|
||||
|
||||
main "$@"
|
Reference in New Issue
Block a user