diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 910ccd876..05333ee81 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -150,6 +150,7 @@ CREATE_EXAMPLE (wizard wizard.cxx fltk) SET (UNITTEST_SRCS unittests.cxx + unittests.h unittest_about.cxx unittest_points.cxx unittest_complex_shapes.cxx diff --git a/test/README-unittests.txt b/test/README-unittests.txt index 763d2b422..77489e86f 100644 --- a/test/README-unittests.txt +++ b/test/README-unittests.txt @@ -4,7 +4,7 @@ HOW TO CREATE A NEW UNIT TEST 1) Create your new test/unittest_xxx.cxx file (or use an existing one) 2) In your new cxx file, define a class derived from Fl_Group - for your test (e.g. TestFoo). + for your test (e.g. Ut_Test_Foo). The following should be a good starting template for the new file: @@ -19,44 +19,42 @@ HOW TO CREATE A NEW UNIT TEST #include // Your class to do the test - // Your test must do its work within the TESTAREA_XYWH area. + // Your test must do its work within the UT_TESTAREA_XYWH area. // - class TestFoo : public Fl_Group { + class Ut_Test_Foo : public Fl_Group { public: static Fl_Widget *create() { - return new TestFoo(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + return new Ut_Test_Foo(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); } - TestFoo(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { .. } + Ut_Test_Foo(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { .. } }; // Create an instance of your class and register it with the main app - UnitTest testfoo(kTestFoo, "My foo tester", TestFoo::create); + UnitTest testfoo(UT_TEST_FOO, "My foo tester", Ut_Test_Foo::create); * * * Note that the last line in the above is what "registers" your new test with the unittests main application: - UnitTest testfoo(kTestFoo, "My foo tester", TestFoo::create); - ------- -------- ------------- --------------- - | | | | - | | | Your class's static create() method - | | | - | | Text name for your test that shows up in unittests browser + UnitTest testfoo(UT_TEST_FOO, "My foo tester", Ut_Test_Foo::create); + ------- ----------- ------------- ------------------- + | | | | + | | | Your class's static create() method + | | | + | | Text name for your test that shows up in unittests browser | | - | Just put 'k' in front of your class name. - | (This will be defined as an enum constant in the next step) + | This will be defined as an enum constant in the next step | The global instance name for your test. - 3) Take the 'k' name you used above, e.g. kTestFoo, and add it to the enum {} - at the top of the unittests.h file. Example: + 3) Add an entry anywhere to the enum {} at the top of the unittests.h file. Example: enum { - kTestAbout = 0, - kTestPoints, + UT_TEST_ABOUT = 0, + UT_TEST_POINTS, ... - kTestFoo, <-- ADD YOUR TEST CLASS WITH THE 'k' PREFIX + UT_TEST_FOO, <-- ADD YOUR TEST CLASS NAME IN ALL CAPS ... }; @@ -81,7 +79,7 @@ HOW TO CREATE A NEW UNIT TEST GENERAL TEST PRACTICES ---------------------- - TESTAREA_X, Y, W, and H will be the position and size of the Group, + UT_TESTAREA_X, Y, W, and H will be the position and size of the Group, and that the Group must expect to be resized, but not any smaller than that area. diff --git a/test/fonts.cxx b/test/fonts.cxx index 694b1d7bf..ef161eae3 100644 --- a/test/fonts.cxx +++ b/test/fonts.cxx @@ -265,10 +265,10 @@ Fl_Window *create_editor() return win; } -class MainWindow : public Fl_Double_Window +class Ut_Main_Window : public Fl_Double_Window { public: - MainWindow(int w, int h, const char *l=0) + Ut_Main_Window(int w, int h, const char *l=0) : Fl_Double_Window(w, h, l) { } int handle(int event) { if (event==FL_KEYBOARD && Fl::event_key()==FL_F+1) { @@ -300,7 +300,7 @@ void create_the_forms() { label[i] = 0; // create the basic layout - form = new MainWindow(550,370); + form = new Ut_Main_Window(550,370); tile = new Fl_Tile(0, 0, 550, 370); diff --git a/test/unittest_about.cxx b/test/unittest_about.cxx index 4555643e4..5a6b6e4ea 100644 --- a/test/unittest_about.cxx +++ b/test/unittest_about.cxx @@ -21,12 +21,12 @@ // //------- Introduction to FLTK drawing test ------- // -class About : public Fl_Help_View { +class Ut_About_View : public Fl_Help_View { public: static Fl_Widget *create() { - return new About(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + return new Ut_About_View(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); } - About(int x, int y, int w, int h) : Fl_Help_View(x, y, w, h) { + Ut_About_View(int x, int y, int w, int h) : Fl_Help_View(x, y, w, h) { value( "

About Unit Testing...

\n" "The Unit Testing application can be used to verify correct graphics rendering " @@ -53,4 +53,4 @@ public: } }; -UnitTest about(kTestAbout, "About...", About::create); +UnitTest about(UT_TEST_ABOUT, "About...", Ut_About_View::create); diff --git a/test/unittest_circles.cxx b/test/unittest_circles.cxx index 13759a0cb..e6027527c 100644 --- a/test/unittest_circles.cxx +++ b/test/unittest_circles.cxx @@ -75,18 +75,18 @@ void draw_circles() { b+=44; // ---- 2: draw arcs and pies fl_color(FL_RED); -// arc(a-5, b-5, w+10, h+10, 45.0, 315.0); + // arc(a-5, b-5, w+10, h+10, 45.0, 315.0); arc(a+1, b+1, w-2, h-2, 45.0, 315.0); -// arc(a+5, b+5, w-10, h-10, 45.0, 315.0); -// arc(a+10, b+10, w-20, h-20, 45.0, 315.0); + // arc(a+5, b+5, w-10, h-10, 45.0, 315.0); + // arc(a+10, b+10, w-20, h-20, 45.0, 315.0); fl_color(FL_GREEN); arc(a, b, w, h, 45.0, 315.0); arc(a+2, b+2, w-4, h-4, 45.0, 315.0); fl_color(FL_BLACK); -// fl_arc(a-5, b-5, w+10, h+10, 45.0, 315.0); + // fl_arc(a-5, b-5, w+10, h+10, 45.0, 315.0); fl_arc(a+1, b+1, w-1, h-1, 45.0, 315.0); -// fl_arc(a+5, b+5, w-10, h-10, 45.0, 315.0); -// fl_arc(a+10, b+10, w-20, h-20, 45.0, 315.0); + // fl_arc(a+5, b+5, w-10, h-10, 45.0, 315.0); + // fl_arc(a+10, b+10, w-20, h-20, 45.0, 315.0); fl_color(FL_RED); // ---- arc(a+1+50, b+1, w-2, h-2, 45.0, 315.0); @@ -102,10 +102,10 @@ void draw_circles() { #if HAVE_GL -class GLCircleTest : public Fl_Gl_Window { +class Ut_GL_Circle_Test : public Fl_Gl_Window { public: - GLCircleTest(int x, int y, int w, int h) - : Fl_Gl_Window(x, y, w, h) { + Ut_GL_Circle_Test(int x, int y, int w, int h) + : Fl_Gl_Window(x, y, w, h) { box(FL_FLAT_BOX); } void draw() { @@ -118,10 +118,10 @@ public: #endif -class NativeCircleTest : public Fl_Window { +class Ut_Native_Circle_Test : public Fl_Window { public: - NativeCircleTest(int x, int y, int w, int h) - : Fl_Window(x, y, w, h) { + Ut_Native_Circle_Test(int x, int y, int w, int h) + : Fl_Window(x, y, w, h) { box(FL_FLAT_BOX); end(); } @@ -134,12 +134,13 @@ public: // //------- test the circle drawing capabilities of this implementation ---------- // -class CircleTest : public Fl_Group { +class Ut_Circle_Test : public Fl_Group { public: static Fl_Widget *create() { - return new CircleTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + return new Ut_Circle_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); } - CircleTest(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { + Ut_Circle_Test(int x, int y, int w, int h) + : Fl_Group(x, y, w, h) { label("Testing fast circle, arc, and pie drawing\n\n" "No red lines should be visible. " "The green outlines should not be overwritten by circle drawings."); @@ -147,10 +148,10 @@ public: box(FL_BORDER_BOX); int a = x+16, b = y+34; - Fl_Box *t = new Fl_Box(a, b-24, 80, 18, "native"); + Fl_Box* t = new Fl_Box(a, b-24, 80, 18, "native"); t->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); - /* NativeCircleTest *nr = */ new NativeCircleTest(a+23, b-1, 200, 200); + /* NativeCircleTest *nr = */ new Ut_Native_Circle_Test(a+23, b-1, 200, 200); t = new Fl_Box(a, b, 18, 18, "1"); t->box(FL_ROUNDED_BOX); t->color(FL_YELLOW); @@ -180,7 +181,7 @@ public: t = new Fl_Box(a, b-24, 80, 18, "OpenGL"); t->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); - /* GLCircleTest *glr = */ new GLCircleTest(a+31, b-1, 200, 200); + /* GLCircleTest *glr = */ new Ut_GL_Circle_Test(a+31, b-1, 200, 200); t = new Fl_Box(a, b, 26, 18, "1a"); t->box(FL_ROUNDED_BOX); t->color(FL_YELLOW); @@ -210,4 +211,4 @@ public: } }; -UnitTest circle(kTestCircles, "Circles and Arcs", CircleTest::create); +UnitTest circle(UT_TEST_CIRCLES, "Circles and Arcs", Ut_Circle_Test::create); diff --git a/test/unittest_complex_shapes.cxx b/test/unittest_complex_shapes.cxx index 4362086ae..fbfc64906 100644 --- a/test/unittest_complex_shapes.cxx +++ b/test/unittest_complex_shapes.cxx @@ -31,70 +31,70 @@ // --- test drawing circles and arcs ------ // -class ComplexShapesTest; +class Ut_Complex_Shapes_Test; -void draw_complex(ComplexShapesTest *p); +void draw_complex(Ut_Complex_Shapes_Test *p); #if HAVE_GL -class GLComplexShapesTest : public Fl_Gl_Window { +class Ut_GL_Complex_Shapes_Test : public Fl_Gl_Window { public: - GLComplexShapesTest(int x, int y, int w, int h) - : Fl_Gl_Window(x, y, w, h) { + Ut_GL_Complex_Shapes_Test(int x, int y, int w, int h) + : Fl_Gl_Window(x, y, w, h) { box(FL_FLAT_BOX); end(); } void draw() { draw_begin(); Fl_Window::draw(); - draw_complex((ComplexShapesTest*)parent()); + draw_complex((Ut_Complex_Shapes_Test*)parent()); draw_end(); } }; #endif -class NativeComplexShapesTest : public Fl_Window { +class Ut_Native_Complex_Shapes_Test : public Fl_Window { public: - NativeComplexShapesTest(int x, int y, int w, int h) - : Fl_Window(x, y, w, h) { + Ut_Native_Complex_Shapes_Test(int x, int y, int w, int h) + : Fl_Window(x, y, w, h) { box(FL_FLAT_BOX); end(); } void draw() { Fl_Window::draw(); - draw_complex((ComplexShapesTest*)parent()); + draw_complex((Ut_Complex_Shapes_Test*)parent()); } }; // //------- test the compelx shape drawing capabilities of this implementation ---------- // -class ComplexShapesTest : public Fl_Group { - NativeComplexShapesTest *native_test_window; +class Ut_Complex_Shapes_Test : public Fl_Group { + Ut_Native_Complex_Shapes_Test* native_test_window; #if HAVE_GL - GLComplexShapesTest *gl_test_window; + Ut_GL_Complex_Shapes_Test* gl_test_window; #endif - static void update_cb(Fl_Widget *, void *v) { - ComplexShapesTest *This = (ComplexShapesTest*)v; + static void update_cb(Fl_Widget*, void *v) { + Ut_Complex_Shapes_Test* This = (Ut_Complex_Shapes_Test*)v; This->native_test_window->redraw(); #if HAVE_GL This->gl_test_window->redraw(); #endif } public: - Fl_Hor_Value_Slider *scale; - Fl_Dial *rotate; - Fl_Positioner *position; + Fl_Hor_Value_Slider* scale; + Fl_Dial* rotate; + Fl_Positioner* position; void set_transformation() { fl_translate(position->xvalue(), position->yvalue()); fl_rotate(-rotate->value()); fl_scale(scale->value(), scale->value()); } - static Fl_Widget *create() { - return new ComplexShapesTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + static Fl_Widget* create() { + return new Ut_Complex_Shapes_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); } - ComplexShapesTest(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { + Ut_Complex_Shapes_Test(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { label("Testing complex shape drawing."); align(FL_ALIGN_INSIDE|FL_ALIGN_BOTTOM|FL_ALIGN_LEFT|FL_ALIGN_WRAP); box(FL_BORDER_BOX); @@ -103,7 +103,7 @@ public: Fl_Box *t = new Fl_Box(a, b-24, 80, 18, "native"); t->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); - native_test_window = new NativeComplexShapesTest(a+23, b-1, 200, 200); + native_test_window = new Ut_Native_Complex_Shapes_Test(a+23, b-1, 200, 200); t = new Fl_Box(a, b, 18, 18, "1"); t->box(FL_ROUNDED_BOX); t->color(FL_YELLOW); @@ -146,7 +146,7 @@ public: t = new Fl_Box(a, b-24, 80, 18, "OpenGL"); t->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); - gl_test_window = new GLComplexShapesTest(a+31, b-1, 200, 200); + gl_test_window = new Ut_GL_Complex_Shapes_Test(a+31, b-1, 200, 200); t = new Fl_Box(a, b, 26, 18, "1a"); t->box(FL_ROUNDED_BOX); t->color(FL_YELLOW); @@ -185,8 +185,8 @@ public: ); #endif - a = TESTAREA_X+TESTAREA_W-250; - b = TESTAREA_Y+TESTAREA_H-50; + a = UT_TESTAREA_X+UT_TESTAREA_W-250; + b = UT_TESTAREA_Y+UT_TESTAREA_H-50; scale = new Fl_Hor_Value_Slider(a, b+10, 120, 20, "Scale:"); scale->align(FL_ALIGN_TOP_LEFT); @@ -265,7 +265,7 @@ void complex_shape_with_hole(int w, int h) { fl_vertex( w2, -h2); } -void draw_complex(ComplexShapesTest *p) { +void draw_complex(Ut_Complex_Shapes_Test *p) { int a = 0, b = 0, dx = 20, dy = 20, w = 10, h = 10; int w2 = w/3, h2 = h/3; // ---- 1: draw a random shape @@ -430,15 +430,6 @@ void draw_complex(ComplexShapesTest *p) { fl_vertex(w, h); fl_vertex(-w, h); fl_end_loop(); fl_pop_matrix(); - - - // Test fl_begin_points(), fl_end_points() - // Test fl_begin_line() fl_end_line() - // Test fl_begin_loop() fl_end_loop() - // Test fl_begin_polygon() fl_end_polygon() - // Test fl_begin_complex_polygon() fl_gap() fl_arc() void fl_end_complex_polygon() - // Test fl_curve() - // Test translate, rotate, scale, push, pop } -UnitTest complex_shapes(kTestComplexShapes, "Complex Shapes", ComplexShapesTest::create); +UnitTest complex_shapes(UT_TEST_COMPLEX_SHAPES, "Complex Shapes", Ut_Complex_Shapes_Test::create); diff --git a/test/unittest_fast_shapes.cxx b/test/unittest_fast_shapes.cxx index 7dcb05aa5..1572b2be7 100644 --- a/test/unittest_fast_shapes.cxx +++ b/test/unittest_fast_shapes.cxx @@ -25,7 +25,7 @@ #if 0 -// TODO: +// not testing yet: void fl_line(int x, int y, int x1, int y1) void fl_line(int x, int y, int x1, int y1, int x2, int y2) @@ -186,10 +186,10 @@ void draw_fast_shapes() { #if HAVE_GL -class GLRectTest : public Fl_Gl_Window { +class Ut_GL_Rect_Test : public Fl_Gl_Window { public: - GLRectTest(int x, int y, int w, int h) - : Fl_Gl_Window(x, y, w, h) { + Ut_GL_Rect_Test(int x, int y, int w, int h) + : Fl_Gl_Window(x, y, w, h) { box(FL_FLAT_BOX); } void draw() { @@ -203,10 +203,10 @@ public: #endif -class NativeRectTest : public Fl_Window { +class Ut_Native_Rect_Test : public Fl_Window { public: - NativeRectTest(int x, int y, int w, int h) - : Fl_Window(x, y, w, h) { + Ut_Native_Rect_Test(int x, int y, int w, int h) + : Fl_Window(x, y, w, h) { box(FL_FLAT_BOX); end(); } @@ -216,12 +216,13 @@ public: } }; -class RectTest : public Fl_Group { // 520 x 365 +class Ut_Rect_Test : public Fl_Group { // 520 x 365 public: static Fl_Widget *create() { - return new RectTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + return new Ut_Rect_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); } - RectTest(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { + Ut_Rect_Test(int x, int y, int w, int h) + : Fl_Group(x, y, w, h) { label("Testing FLTK fast shape calls.\n" "These calls draw horizontal and vertical lines, frames, and rectangles.\n\n" "No red pixels should be visible. " @@ -234,7 +235,7 @@ public: Fl_Box *t = new Fl_Box(a, b-24, 80, 18, "native"); t->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); - /* NativeRectTest *nr = */ new NativeRectTest(a+23, b-1, 200, 200); + /* NativeRectTest *nr = */ new Ut_Native_Rect_Test(a+23, b-1, 200, 200); t = new Fl_Box(a, b, 18, 18, "1"); t->box(FL_ROUNDED_BOX); t->color(FL_YELLOW); @@ -306,7 +307,7 @@ public: t = new Fl_Box(a, b-24, 80, 18, "OpenGL"); t->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); - /*GLRectTest *glr = */ new GLRectTest(a+31, b-1, 200, 200); + /*GLRectTest *glr = */ new Ut_GL_Rect_Test(a+31, b-1, 200, 200); t = new Fl_Box(a, b, 26, 18, "1a"); t->box(FL_ROUNDED_BOX); t->color(FL_YELLOW); @@ -380,4 +381,4 @@ public: } }; -UnitTest rects(kTestFastShapes, "Fast Shapes", RectTest::create); +UnitTest rects(UT_TEST_FAST_SHAPES, "Fast Shapes", Ut_Rect_Test::create); diff --git a/test/unittest_images.cxx b/test/unittest_images.cxx index 3f2a6ef25..cccde78e7 100644 --- a/test/unittest_images.cxx +++ b/test/unittest_images.cxx @@ -35,41 +35,41 @@ // Parameters for fine tuning for developers. // Default values: CB=1, DX=0, IMG=1, LX=0, FLIPH=0 -static int CB = 1; // 1 to show the checker board background for alpha images, - // 0 otherwise -static int DX = 0; // additional (undefined (0)) pixels per line, must be >= 0 - // ignored (irrelevant), if LX == 0 (see below) -static int IMG = 1; // 1 to use Fl_RGB_Image for drawing images with transparency, - // 0 to use fl_draw_image() instead. - // Note: as of Feb 2016, only 1 (Fl_RGB_Image) works with - // alpha channel, 0 (fl_draw_image()) ignores the alpha - // channel (FLTK 1.3.x). - // There are plans to support transparency (alpha channel) - // in fl_draw_image() in FLTK 1.4.0 and/or later. -static int LX = 0; // 0 for default: ld() = 0, i.e. ld() defaults (internally) to w()*d() - // +1: ld() = (w() + DX) * d() - // -1 to flip image vertically: ld() = - ((w() + DX) * d()) -static int FLIPH = 0; // 1 = Flip image horizontally (only if IMG == 0) - // 0 = Draw image normal, w/o horizontal flipping +static int cb = 1; // 1 to show the checker board background for alpha images, + // 0 otherwise +static int dx = 0; // additional (undefined (0)) pixels per line, must be >= 0 + // ignored (irrelevant), if LX == 0 (see below) +static int img = 1; // 1 to use Fl_RGB_Image for drawing images with transparency, + // 0 to use fl_draw_image() instead. + // Note: as of Feb 2016, only 1 (Fl_RGB_Image) works with + // alpha channel, 0 (fl_draw_image()) ignores the alpha + // channel (FLTK 1.3.x). + // There are plans to support transparency (alpha channel) + // in fl_draw_image() in FLTK 1.4.0 and/or later. +static int lx = 0; // 0 for default: ld() = 0, i.e. ld() defaults (internally) to w()*d() + // +1: ld() = (w() + DX) * d() + // -1 to flip image vertically: ld() = - ((w() + DX) * d()) +static int flip_h = 0; // 1 = Flip image horizontally (only if IMG == 0) + // 0 = Draw image normal, w/o horizontal flipping // ---------------------------------------------------------------------- // Test scenario for fl_draw_image() with pos. and neg. d and ld args: // ---------------------------------------------------------------------- -// (1) set IMG = 0: normal, but w/o transparency: no checker board -// (2) set LX = -1: images flipped vertically -// (3) set FLIPH = 1: images flipped vertically and horizontally -// (4) set LX = 0: images flipped horizontally -// (5) set FLIPH = 0, IMG = 1: back to default (with transparency) +// (1) set img = 0: normal, but w/o transparency: no checker board +// (2) set lx = -1: images flipped vertically +// (3) set flip_h = 1: images flipped vertically and horizontally +// (4) set lx = 0: images flipped horizontally +// (5) set flip_h = 0, IMG = 1: back to default (with transparency) // ---------------------------------------------------------------------- -class ImageTest : public Fl_Group { +class Ut_Image_Test : public Fl_Group { static void build_imgs() { int x, y; uchar *dg, *dga, *drgb, *drgba; - dg = img_gray = img_gray_base = (uchar*)malloc((128+DX)*128*1); - dga = img_gray_a = img_gray_a_base = (uchar*)malloc((128+DX)*128*2); - drgb = img_rgb = img_rgb_base = (uchar*)malloc((128+DX)*128*3); - drgba = img_rgba = img_rgba_base = (uchar*)malloc((128+DX)*128*4); + dg = img_gray = img_gray_base = (uchar*)malloc((128+dx)*128*1); + dga = img_gray_a = img_gray_a_base = (uchar*)malloc((128+dx)*128*2); + drgb = img_rgb = img_rgb_base = (uchar*)malloc((128+dx)*128*3); + drgba = img_rgba = img_rgba_base = (uchar*)malloc((128+dx)*128*4); for (y=0; y<128; y++) { for (x=0; x<128; x++) { *drgba++ = *drgb++ = *dga++ = *dg++ = y<<1; @@ -77,29 +77,29 @@ class ImageTest : public Fl_Group { *drgba++ = *drgb++ = (127-x)<<1; *drgba++ = *dga++ = x+y; } - if (DX > 0 && LX != 0) { - memset(dg, 0,1*DX); dg += 1*DX; - memset(dga, 0,2*DX); dga += 2*DX; - memset(drgb, 0,3*DX); drgb += 3*DX; - memset(drgba,0,4*DX); drgba += 4*DX; + if (dx > 0 && lx != 0) { + memset(dg, 0,1*dx); dg += 1*dx; + memset(dga, 0,2*dx); dga += 2*dx; + memset(drgb, 0,3*dx); drgb += 3*dx; + memset(drgba,0,4*dx); drgba += 4*dx; } } - if (LX<0) { - img_gray += 127*(128+DX); - img_gray_a += 127*(128+DX)*2; - img_rgb += 127*(128+DX)*3; - img_rgba += 127*(128+DX)*4; + if (lx<0) { + img_gray += 127*(128+dx); + img_gray_a += 127*(128+dx)*2; + img_rgb += 127*(128+dx)*3; + img_rgba += 127*(128+dx)*4; } - if (FLIPH && !IMG ) { + if (flip_h && !img ) { img_gray += 127; img_gray_a += 127*2; img_rgb += 127*3; img_rgba += 127*4; } - i_g = new Fl_RGB_Image (img_gray ,128,128,1,LX*(128+DX)); - i_ga = new Fl_RGB_Image (img_gray_a,128,128,2,LX*(128+DX)*2); - i_rgb = new Fl_RGB_Image (img_rgb, 128,128,3,LX*(128+DX)*3); - i_rgba = new Fl_RGB_Image (img_rgba, 128,128,4,LX*(128+DX)*4); + i_g = new Fl_RGB_Image (img_gray ,128,128,1,lx*(128+dx)); + i_ga = new Fl_RGB_Image (img_gray_a,128,128,2,lx*(128+dx)*2); + i_rgb = new Fl_RGB_Image (img_rgb, 128,128,3,lx*(128+dx)*3); + i_rgba = new Fl_RGB_Image (img_rgba, 128,128,4,lx*(128+dx)*4); } // build_imgs method ends void free_images() { @@ -114,16 +114,16 @@ class ImageTest : public Fl_Group { } // end of free_images method static void refresh_imgs_CB(Fl_Widget*,void *data) { - ImageTest *it = (ImageTest*)data; + Ut_Image_Test* it = (Ut_Image_Test*)data; it->free_images(); // release the previous images // determine the state for the next images - CB = it->ck_CB->value(); - IMG = it->ck_IMG->value(); - FLIPH = it->ck_FLIPH->value(); + cb = it->ck_CB->value(); + img = it->ck_IMG->value(); + flip_h = it->ck_FLIPH->value(); // read the LX state radio buttons - if (it->rb_LXp1->value()) { LX = 1; } - else if (it->rb_LXm1->value()) { LX = (-1); } - else { LX = 0; } + if (it->rb_LXp1->value()) { lx = 1; } + else if (it->rb_LXm1->value()) { lx = (-1); } + else { lx = 0; } // construct the next images build_imgs(); it->redraw(); @@ -132,7 +132,7 @@ class ImageTest : public Fl_Group { public: static Fl_Widget *create() { build_imgs(); - return new ImageTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + return new Ut_Image_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); } // create method ends static uchar *img_gray_base; @@ -158,7 +158,9 @@ public: Fl_Radio_Button *rb_LXp1; Fl_Button *refresh; - ImageTest(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { + Ut_Image_Test(int x, int y, int w, int h) + : Fl_Group(x, y, w, h) + { label("Testing Image Drawing\n\n" "This test renders four images, two of them with a checker board\n" "visible through the graphics. Color and gray gradients should be\n" @@ -166,34 +168,46 @@ public: align(FL_ALIGN_INSIDE|FL_ALIGN_BOTTOM|FL_ALIGN_LEFT|FL_ALIGN_WRAP); box(FL_BORDER_BOX); int cw = 90; - int ch = 270; + int ch = 200; int cx = x + w - cw - 5; int cy = y + 10; ctr_grp = new Fl_Group(cx, cy, cw, ch); ck_CB = new Fl_Check_Button(cx+10, cy+10, cw-20, 30, "CB"); - ck_CB->value(CB); + ck_CB->callback(refresh_imgs_CB, (void*)this); + ck_CB->value(cb); + ck_CB->tooltip("1 to show the checker board background for alpha images,\n" + "0 otherwise"); ck_IMG = new Fl_Check_Button(cx+10, cy+40, cw-20, 30, "IMG"); - ck_IMG->value(IMG); + ck_IMG->callback(refresh_imgs_CB, (void*)this); + ck_IMG->value(img); + ck_IMG->tooltip("1 to use Fl_RGB_Image for drawing images with transparency,\n" + "0 to use fl_draw_image() instead."); ck_FLIPH = new Fl_Check_Button(cx+10, cy+70, cw-20, 30, "FLIPH"); - ck_FLIPH->value(FLIPH); + ck_FLIPH->callback(refresh_imgs_CB, (void*)this); + ck_FLIPH->value(flip_h); + ck_FLIPH->tooltip("1 = Flip image horizontally (only if IMG == 0)\n" + "0 = Draw image normal, w/o horizontal flipping"); Fl_Group *rd_grp = new Fl_Group(cx+10, cy+100, cw-20, 90, "LX"); rb_LXp1 = new Fl_Radio_Button(cx+15, cy+105, cw-30, 20, "+1"); + rb_LXp1->callback(refresh_imgs_CB, (void*)this); rb_LX0 = new Fl_Radio_Button(cx+15, cy+125, cw-30, 20, "0"); + rb_LX0->callback(refresh_imgs_CB, (void*)this); + rb_LX0->tooltip("0 for default: ld() = 0, i.e. ld() defaults (internally) to w()*d()\n" + "+1: ld() = (w() + DX) * d()\n" + "-1 to flip image vertically: ld() = - ((w() + DX) * d())"); rb_LXm1 = new Fl_Radio_Button(cx+15, cy+145, cw-30, 20, "-1"); + rb_LXm1->callback(refresh_imgs_CB, (void*)this); rb_LX0->value(1); rd_grp->box(FL_BORDER_BOX); rd_grp->align(FL_ALIGN_INSIDE|FL_ALIGN_BOTTOM|FL_ALIGN_CENTER); rd_grp->end(); - refresh = new Fl_Button(cx+10, cy+ch-40, cw-20, 30, "Refresh"); - refresh->callback(refresh_imgs_CB, (void*)this); - ctr_grp->box(FL_BORDER_BOX); ctr_grp->end(); end(); // make sure this ImageTest group is closed @@ -206,15 +220,15 @@ public: int xx = x()+10, yy = y()+10; fl_color(FL_BLACK); fl_rect(xx, yy, 130, 130); - if (IMG) { + if (img) { i_rgb->draw(xx+1,yy+1); } else { - if (!FLIPH) { - fl_draw_image(img_rgb, xx+1, yy+1, 128, 128, 3, LX*((128+DX)*3)); + if (!flip_h) { + fl_draw_image(img_rgb, xx+1, yy+1, 128, 128, 3, lx*((128+dx)*3)); } else { - fl_draw_image(img_rgb, xx+1, yy+1, 128, 128,-3, LX*((128+DX)*3)); + fl_draw_image(img_rgb, xx+1, yy+1, 128, 128,-3, lx*((128+dx)*3)); } } fl_draw("RGB", xx+134, yy+64); @@ -224,19 +238,19 @@ public: xx = x()+10; yy = y()+10+134; fl_color(FL_BLACK); fl_rect(xx, yy, 130, 130); // black frame fl_color(FL_WHITE); fl_rectf(xx+1, yy+1, 128, 128); // white background - if (CB) { // checker board + if (cb) { // checker board fl_color(FL_BLACK); fl_rectf(xx+65, yy+1, 64, 64); fl_color(FL_BLACK); fl_rectf(xx+1, yy+65, 64, 64); } - if (IMG) { + if (img) { i_rgba->draw(xx+1,yy+1); } else { - if (!FLIPH) { - fl_draw_image(img_rgba, xx+1, yy+1, 128, 128, 4, LX*((128+DX)*4)); + if (!flip_h) { + fl_draw_image(img_rgba, xx+1, yy+1, 128, 128, 4, lx*((128+dx)*4)); } else { - fl_draw_image(img_rgba, xx+1, yy+1, 128, 128,-4, LX*((128+DX)*4)); + fl_draw_image(img_rgba, xx+1, yy+1, 128, 128,-4, lx*((128+dx)*4)); } } fl_color(FL_BLACK); fl_draw("RGBA", xx+134, yy+64); @@ -245,15 +259,15 @@ public: xx = x()+10+200; yy = y()+10; fl_color(FL_BLACK); fl_rect(xx, yy, 130, 130); - if (IMG) { + if (img) { i_g->draw(xx+1,yy+1); } else { - if (!FLIPH) { - fl_draw_image(img_gray, xx+1, yy+1, 128, 128, 1, LX*((128+DX)*1)); + if (!flip_h) { + fl_draw_image(img_gray, xx+1, yy+1, 128, 128, 1, lx*((128+dx)*1)); } else { - fl_draw_image(img_gray, xx+1, yy+1, 128, 128,-1, LX*((128+DX)*1)); + fl_draw_image(img_gray, xx+1, yy+1, 128, 128,-1, lx*((128+dx)*1)); } } fl_draw("Gray", xx+134, yy+64); @@ -263,36 +277,36 @@ public: xx = x()+10+200; yy = y()+10+134; fl_color(FL_BLACK); fl_rect(xx, yy, 130, 130); // black frame fl_color(FL_WHITE); fl_rectf(xx+1, yy+1, 128, 128); // white background - if (CB) { // checker board + if (cb) { // checker board fl_color(FL_BLACK); fl_rectf(xx+65, yy+1, 64, 64); fl_color(FL_BLACK); fl_rectf(xx+1, yy+65, 64, 64); } - if (IMG) { + if (img) { i_ga->draw(xx+1,yy+1); } else { - if (!FLIPH) { - fl_draw_image(img_gray_a, xx+1, yy+1, 128, 128, 2, LX*((128+DX)*2)); + if (!flip_h) { + fl_draw_image(img_gray_a, xx+1, yy+1, 128, 128, 2, lx*((128+dx)*2)); } else { - fl_draw_image(img_gray_a, xx+1, yy+1, 128, 128,-2, LX*((128+DX)*2)); + fl_draw_image(img_gray_a, xx+1, yy+1, 128, 128,-2, lx*((128+dx)*2)); } } fl_color(FL_BLACK); fl_draw("Gray+Alpha", xx+134, yy+64); } // draw method end }; -uchar *ImageTest::img_gray_base = 0; -uchar *ImageTest::img_gray_a_base = 0; -uchar *ImageTest::img_rgb_base = 0; -uchar *ImageTest::img_rgba_base = 0; -uchar *ImageTest::img_gray = 0; -uchar *ImageTest::img_gray_a = 0; -uchar *ImageTest::img_rgb = 0; -uchar *ImageTest::img_rgba = 0; -Fl_RGB_Image *ImageTest::i_g = 0; -Fl_RGB_Image *ImageTest::i_ga = 0; -Fl_RGB_Image *ImageTest::i_rgb = 0; -Fl_RGB_Image *ImageTest::i_rgba = 0; +uchar *Ut_Image_Test::img_gray_base = 0; +uchar *Ut_Image_Test::img_gray_a_base = 0; +uchar *Ut_Image_Test::img_rgb_base = 0; +uchar *Ut_Image_Test::img_rgba_base = 0; +uchar *Ut_Image_Test::img_gray = 0; +uchar *Ut_Image_Test::img_gray_a = 0; +uchar *Ut_Image_Test::img_rgb = 0; +uchar *Ut_Image_Test::img_rgba = 0; +Fl_RGB_Image *Ut_Image_Test::i_g = 0; +Fl_RGB_Image *Ut_Image_Test::i_ga = 0; +Fl_RGB_Image *Ut_Image_Test::i_rgb = 0; +Fl_RGB_Image *Ut_Image_Test::i_rgba = 0; -UnitTest images(kTestImages, "Drawing Images", ImageTest::create); +UnitTest images(UT_TEST_IMAGES, "Drawing Images", Ut_Image_Test::create); diff --git a/test/unittest_points.cxx b/test/unittest_points.cxx index cf116477d..91a9fda23 100644 --- a/test/unittest_points.cxx +++ b/test/unittest_points.cxx @@ -27,10 +27,12 @@ //------- test the point drawing capabilities of this implementation ---------- // -class PointTestWin : public Fl_Window { +class Ut_Native_Point_Test : public Fl_Window { public: - PointTestWin(int x, int y, int w, int h) : - Fl_Window(x, y, w, h) { end(); } + Ut_Native_Point_Test(int x, int y, int w, int h) + : Fl_Window(x, y, w, h) { + end(); + } void draw() { int i; fl_color(FL_WHITE); @@ -49,10 +51,10 @@ public: #if HAVE_GL -class GLTestWin : public Fl_Gl_Window { +class Ut_GL_Point_Test : public Fl_Gl_Window { public: - GLTestWin(int x, int y, int w, int h) : - Fl_Gl_Window(x, y, w, h) { + Ut_GL_Point_Test(int x, int y, int w, int h) + : Fl_Gl_Window(x, y, w, h) { box(FL_FLAT_BOX); end(); } @@ -131,17 +133,18 @@ public: #endif -class PointTest : public Fl_Group { - PointTestWin *align_test_win; +class Ut_Point_Test : public Fl_Group { + Ut_Native_Point_Test *align_test_win; #if HAVE_GL - GLTestWin *gl_test_win; + Ut_GL_Point_Test *gl_test_win; #endif public: static Fl_Widget *create() { - return new PointTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + return new Ut_Point_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); // 520x365, resizable } - PointTest(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { + Ut_Point_Test(int x, int y, int w, int h) + : Fl_Group(x, y, w, h) { label("Testing the fl_point call."); align(FL_ALIGN_INSIDE|FL_ALIGN_BOTTOM|FL_ALIGN_LEFT|FL_ALIGN_WRAP); box(FL_BORDER_BOX); @@ -179,7 +182,7 @@ public: // Things to look out for: "If parts of the black frame are clipped by the window and not visible, pixel offsets must be adjusted." ); - align_test_win = new PointTestWin(a+24, b+2*24+2*16+9-5, 10, 10); + align_test_win = new Ut_Native_Point_Test(a+24, b+2*24+2*16+9-5, 10, 10); t = new Fl_Box(a, b+3*24+2*16, 18, 18, "4"); t->box(FL_ROUNDED_BOX); t->color(FL_YELLOW); @@ -238,7 +241,7 @@ public: "If red pixels are visible or black pixels are missing, graphics clipping is misaligned." ); - gl_test_win = new GLTestWin(a+24+8, b+9-5, 10, 4*24+2*16); + gl_test_win = new Ut_GL_Point_Test(a+24+8, b+9-5, 10, 4*24+2*16); #endif t = new Fl_Box(x+w-1,y+h-1, 1, 1); @@ -303,4 +306,4 @@ public: } }; -UnitTest points(kTestPoints, "Drawing Points", PointTest::create); +UnitTest points(UT_TEST_POINTS, "Drawing Points", Ut_Point_Test::create); diff --git a/test/unittest_schemes.cxx b/test/unittest_schemes.cxx index d37362b5e..4baec44d8 100644 --- a/test/unittest_schemes.cxx +++ b/test/unittest_schemes.cxx @@ -44,12 +44,12 @@ #include #include -class SchemesTest : public Fl_Group { - Fl_Choice *schemechoice; +class Ut_Schemes_Test : public Fl_Group { + Fl_Choice *scheme_choice_; - static void SchemeChoice_CB(Fl_Widget*,void *data) { - SchemesTest *st = (SchemesTest*)data; - const char *name = st->schemechoice->text(); + static void scheme_choice_cb(Fl_Widget*,void *data) { + Ut_Schemes_Test *st = (Ut_Schemes_Test*)data; + const char *name = st->scheme_choice_->text(); if ( name ) { Fl::scheme(name); // change scheme st->window()->redraw(); // redraw window @@ -78,25 +78,26 @@ class SchemesTest : public Fl_Group { public: static Fl_Widget *create() { - return new SchemesTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + return new Ut_Schemes_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); } - SchemesTest(int X,int Y,int W,int H) : Fl_Group(X,Y,W,H) { - schemechoice = new Fl_Choice(X+125,Y,140,25,"FLTK Scheme"); - schemechoice->add("none"); - schemechoice->add("plastic"); - schemechoice->add("gtk+"); - schemechoice->add("gleam"); - schemechoice->add("oxy"); - schemechoice->value(0); - schemechoice->labelfont(FL_HELVETICA_BOLD); + Ut_Schemes_Test(int X,int Y,int W,int H) + : Fl_Group(X,Y,W,H) { + scheme_choice_ = new Fl_Choice(X+125,Y,140,25,"FLTK Scheme"); + scheme_choice_->add("none"); + scheme_choice_->add("plastic"); + scheme_choice_->add("gtk+"); + scheme_choice_->add("gleam"); + scheme_choice_->add("oxy"); + scheme_choice_->value(0); + scheme_choice_->labelfont(FL_HELVETICA_BOLD); const char *name = Fl::scheme(); if ( name ) { - if ( strcmp(name, "plastic") == 0) { schemechoice->value(1); } - else if ( strcmp(name, "gtk+") == 0) { schemechoice->value(2); } - else if ( strcmp(name, "gleam") == 0) { schemechoice->value(3); } - else if ( strcmp(name, "oxy") == 0) { schemechoice->value(4); } + if ( strcmp(name, "plastic") == 0) { scheme_choice_->value(1); } + else if ( strcmp(name, "gtk+") == 0) { scheme_choice_->value(2); } + else if ( strcmp(name, "gleam") == 0) { scheme_choice_->value(3); } + else if ( strcmp(name, "oxy") == 0) { scheme_choice_->value(4); } } - schemechoice->callback(SchemeChoice_CB, (void*)this); + scheme_choice_->callback(scheme_choice_cb, (void*)this); Fl_Light_Button *active = new Fl_Light_Button(X + 300, Y, 100, 25, "active"); active->value(1); @@ -355,4 +356,4 @@ public: } }; -UnitTest schemestest(kTestSchemes, "Schemes Test", SchemesTest::create); +UnitTest schemestest(UT_TEST_SCHEMES, "Schemes Test", Ut_Schemes_Test::create); diff --git a/test/unittest_scrollbarsize.cxx b/test/unittest_scrollbarsize.cxx index 8f2b30311..ef685b3e6 100644 --- a/test/unittest_scrollbarsize.cxx +++ b/test/unittest_scrollbarsize.cxx @@ -27,7 +27,7 @@ // // Test new 1.3.x global vs. local scrollbar sizing // -class MyTable : public Fl_Table { +class Ut_Table : public Fl_Table { // Handle drawing table's cells // Fl_Table calls this function to draw each visible cell in the table. // It's up to us to use FLTK's drawing functions to draw the cells the way we want. @@ -57,7 +57,8 @@ class MyTable : public Fl_Table { // Constructor // Make our data array, and initialize the table options. // - MyTable(int X, int Y, int W, int H, const char *L=0) : Fl_Table(X,Y,W,H,L) { + Ut_Table(int X, int Y, int W, int H, const char *L=0) + : Fl_Table(X,Y,W,H,L) { // Rows rows(13); // how many rows row_height_all(10); // default height of rows @@ -66,7 +67,7 @@ class MyTable : public Fl_Table { col_width_all(10); // default width of columns end(); // end the Fl_Table group } - ~MyTable() { } + ~Ut_Table() { } }; static const char *phonetics[] = { @@ -76,10 +77,10 @@ static const char *phonetics[] = { "Uniform", "Victor", "Whiskey", "X-ray", "Yankee", "Zulu", NULL }; -class ScrollBarSizeTest : public Fl_Group { +class Ut_Scrollbar_Size_Test : public Fl_Group { Fl_Browser *brow_a, *brow_b, *brow_c; Fl_Tree *tree_a, *tree_b, *tree_c; - MyTable *table_a,*table_b,*table_c; + Ut_Table *table_a,*table_b,*table_c; Fl_Text_Display *text_a, *text_b, *text_c; Fl_Browser *makebrowser(int X,int Y,int W,int H,const char*L=0) { @@ -102,8 +103,8 @@ class ScrollBarSizeTest : public Fl_Group { } return(b); } - MyTable *maketable(int X,int Y,int W,int H,const char*L=0) { - MyTable *mta = new MyTable(X,Y,W,H,L); + Ut_Table *maketable(int X,int Y,int W,int H,const char*L=0) { + Ut_Table *mta = new Ut_Table(X,Y,W,H,L); mta->align(FL_ALIGN_TOP); mta->end(); return(mta); @@ -133,16 +134,17 @@ class ScrollBarSizeTest : public Fl_Group { in->window()->redraw(); } static void slide_cb(Fl_Widget *w, void *data) { - ScrollBarSizeTest *o = (ScrollBarSizeTest*)data; + Ut_Scrollbar_Size_Test *o = (Ut_Scrollbar_Size_Test*)data; o->slide_cb2((Fl_Value_Slider*)w); } public: static Fl_Widget *create() { - return(new ScrollBarSizeTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H)); + return(new Ut_Scrollbar_Size_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H)); } // CTOR - ScrollBarSizeTest(int X, int Y, int W, int H) : Fl_Group(X,Y,W,H) { + Ut_Scrollbar_Size_Test(int X, int Y, int W, int H) + : Fl_Group(X,Y,W,H) { begin(); // _____________ _______________ // |_____________| |_______________| @@ -219,4 +221,4 @@ public: } }; -UnitTest scrollbarsize(kTestScrollbarsize, "Scrollbar Size", ScrollBarSizeTest::create); +UnitTest scrollbarsize(UT_TEST_SCROLLBARSIZE, "Scrollbar Size", Ut_Scrollbar_Size_Test::create); diff --git a/test/unittest_simple_terminal.cxx b/test/unittest_simple_terminal.cxx index 06c376fe9..9e8324926 100644 --- a/test/unittest_simple_terminal.cxx +++ b/test/unittest_simple_terminal.cxx @@ -23,11 +23,11 @@ // //------- test the Fl_Simple_Terminal drawing capabilities ---------- // -class SimpleTerminal : public Fl_Group { +class Ut_Simple_Terminal_Test : public Fl_Group { Fl_Simple_Terminal *tty1; Fl_Simple_Terminal *tty2; Fl_Simple_Terminal *tty3; - void AnsiTestPattern(Fl_Simple_Terminal *tty) { + void ansi_test_pattern(Fl_Simple_Terminal *tty) { tty->append("\033[30mBlack Courier 14\033[0m Normal text\n" "\033[31mRed Courier 14\033[0m Normal text\n" "\033[32mGreen Courier 14\033[0m Normal text\n" @@ -50,7 +50,7 @@ class SimpleTerminal : public Fl_Group { "\033[41mRed\033[42mGreen\033[43mYellow\033[44mBlue\033[45mMagenta\033[46mCyan\033[47mWhite\033[0m - " "\033[41mX\033[42mX\033[43mX\033[44mX\033[45mX\033[46mX\033[47mX\033[0m\n"); } - void GrayTestPattern(Fl_Simple_Terminal *tty) { + void gray_test_pattern(Fl_Simple_Terminal *tty) { tty->append("Grayscale Test Pattern\n" "--------------------------\n" "\033[0m 100% white Courier 14\n" @@ -65,17 +65,18 @@ class SimpleTerminal : public Fl_Group { "\033[9m 10% white Courier 14\n" "\033[0m"); } - static void DateTimer_CB(void *data) { + static void date_timer_cb(void *data) { Fl_Simple_Terminal *tty = (Fl_Simple_Terminal*)data; time_t lt = time(NULL); tty->printf("The time and date is now: %s", ctime(<)); - Fl::repeat_timeout(3.0, DateTimer_CB, data); + Fl::repeat_timeout(3.0, date_timer_cb, data); } public: static Fl_Widget *create() { - return new SimpleTerminal(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + return new Ut_Simple_Terminal_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); } - SimpleTerminal(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { + Ut_Simple_Terminal_Test(int x, int y, int w, int h) + : Fl_Group(x, y, w, h) { static Fl_Text_Display::Style_Table_Entry my_stable[] = { // 10 entry grayscale // Font Color Font Face Font Size ANSI Sequence // ---------- ---------------- --------- ------------- @@ -98,23 +99,23 @@ public: // TTY1 tty1 = new Fl_Simple_Terminal(x, tty_y1, w, tty_h,"Tty 1: ANSI off"); tty1->ansi(false); - Fl::add_timeout(0.5, DateTimer_CB, (void*)tty1); + Fl::add_timeout(0.5, date_timer_cb, (void*)tty1); // TTY2 tty2 = new Fl_Simple_Terminal(x, tty_y2, w, tty_h,"Tty 2: ANSI on"); tty2->ansi(true); - AnsiTestPattern(tty2); - Fl::add_timeout(0.5, DateTimer_CB, (void*)tty2); + ansi_test_pattern(tty2); + Fl::add_timeout(0.5, date_timer_cb, (void*)tty2); // TTY3 tty3 = new Fl_Simple_Terminal(x, tty_y3, w, tty_h, "Tty 3: Grayscale Style Table"); tty3->style_table(my_stable, sizeof(my_stable), 0); tty3->ansi(true); - GrayTestPattern(tty3); - Fl::add_timeout(0.5, DateTimer_CB, (void*)tty3); + gray_test_pattern(tty3); + Fl::add_timeout(0.5, date_timer_cb, (void*)tty3); end(); } }; -UnitTest simple_terminal(kTestSimpleTerminal, "Simple Terminal", SimpleTerminal::create); +UnitTest simple_terminal(UT_TEST_SIMPLE_TERMINAL, "Simple Terminal", Ut_Simple_Terminal_Test::create); diff --git a/test/unittest_symbol.cxx b/test/unittest_symbol.cxx index e45b62317..e6506ae4d 100644 --- a/test/unittest_symbol.cxx +++ b/test/unittest_symbol.cxx @@ -22,9 +22,9 @@ // // Test symbol rendering // -class SymbolTest : public Fl_Widget +class Ut_Symbol_Test : public Fl_Widget { - void DrawTextAndBoxes(const char *txt, int X, int Y) { + void draw_text_and_boxes(const char *txt, int X, int Y) { int wo = 0, ho = 0; fl_measure(txt, wo, ho, 1); // Draw fl_measure() rect @@ -46,9 +46,11 @@ class SymbolTest : public Fl_Widget } public: static Fl_Widget *create() { - return new SymbolTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + return new Ut_Symbol_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); + } + Ut_Symbol_Test(int x, int y, int w, int h) + : Fl_Widget(x, y, w, h) { } - SymbolTest(int x, int y, int w, int h) : Fl_Widget(x, y, w, h) {} void draw(void) { int x0 = x(); // origin is current window position for Fl_Box int y0 = y(); @@ -63,22 +65,22 @@ public: fl_font(FL_HELVETICA, fsize); int xx = x0+10; int yy = y0+10; - DrawTextAndBoxes("Text" ,xx,yy); yy += fsize+10; // check no symbols - DrawTextAndBoxes("@->" ,xx,yy); yy += fsize+10; // check symbol alone - DrawTextAndBoxes("@-> " ,xx,yy); yy += fsize+10; // check symbol with trailing space - DrawTextAndBoxes("@-> Rt Arrow" ,xx,yy); yy += fsize+10; // check symbol at left edge - DrawTextAndBoxes("Lt Arrow @<-" ,xx,yy); yy += fsize+10; // check symbol at right edge - DrawTextAndBoxes("@-> Rt/Lt @<-" ,xx,yy); yy += fsize+10; // check symbol at lt+rt edges - DrawTextAndBoxes("@@ At/Lt @<-" ,xx,yy); yy += fsize+10; // check @@ at left, symbol at right - DrawTextAndBoxes("@-> Lt/At @@" ,xx,yy); yy += fsize+10; // check symbol at left, @@ at right - DrawTextAndBoxes("@@ At/At @@" ,xx,yy); yy += fsize+10; // check @@ at left+right + draw_text_and_boxes("Text" ,xx,yy); yy += fsize+10; // check no symbols + draw_text_and_boxes("@->" ,xx,yy); yy += fsize+10; // check symbol alone + draw_text_and_boxes("@-> " ,xx,yy); yy += fsize+10; // check symbol with trailing space + draw_text_and_boxes("@-> Rt Arrow" ,xx,yy); yy += fsize+10; // check symbol at left edge + draw_text_and_boxes("Lt Arrow @<-" ,xx,yy); yy += fsize+10; // check symbol at right edge + draw_text_and_boxes("@-> Rt/Lt @<-" ,xx,yy); yy += fsize+10; // check symbol at lt+rt edges + draw_text_and_boxes("@@ At/Lt @<-" ,xx,yy); yy += fsize+10; // check @@ at left, symbol at right + draw_text_and_boxes("@-> Lt/At @@" ,xx,yy); yy += fsize+10; // check symbol at left, @@ at right + draw_text_and_boxes("@@ At/At @@" ,xx,yy); yy += fsize+10; // check @@ at left+right xx = x0+200; yy = y0+10; - DrawTextAndBoxes("Line1\nLine2" ,xx,yy); yy += (fsize+10)*2; // check 2 lines, no symbol - DrawTextAndBoxes("@-> Line1\nLine2 @<-" ,xx,yy); yy += (fsize+10)*2; // check 2 lines, lt+rt symbols - DrawTextAndBoxes("@-> Line1\nLine2\nLine3 @<-",xx,yy); yy += (fsize+10)*3; // check 3 lines, lt+rt symbols - DrawTextAndBoxes("@@@@" ,xx,yy); yy += (fsize+10); // check abutting @@'s - DrawTextAndBoxes("@@ @@" ,xx,yy); yy += (fsize+10); // check @@'s with space sep + draw_text_and_boxes("Line1\nLine2" ,xx,yy); yy += (fsize+10)*2; // check 2 lines, no symbol + draw_text_and_boxes("@-> Line1\nLine2 @<-" ,xx,yy); yy += (fsize+10)*2; // check 2 lines, lt+rt symbols + draw_text_and_boxes("@-> Line1\nLine2\nLine3 @<-",xx,yy); yy += (fsize+10)*3; // check 3 lines, lt+rt symbols + draw_text_and_boxes("@@@@" ,xx,yy); yy += (fsize+10); // check abutting @@'s + draw_text_and_boxes("@@ @@" ,xx,yy); yy += (fsize+10); // check @@'s with space sep fl_font(FL_HELVETICA, 14); fl_color(FL_RED); @@ -88,4 +90,4 @@ public: } }; -UnitTest symbolExtents(kTestSymbol, "Symbol Text", SymbolTest::create); +UnitTest symbolExtents(UT_TEST_SYBOL, "Symbol Text", Ut_Symbol_Test::create); diff --git a/test/unittest_text.cxx b/test/unittest_text.cxx index 544bb9950..c8c91a588 100644 --- a/test/unittest_text.cxx +++ b/test/unittest_text.cxx @@ -26,11 +26,11 @@ static void cb_base_bt(Fl_Widget *bt, void*) { bt->parent()->redraw(); } // -class TextExtentsTest : public Fl_Group +class Ut_Text_Extents_Test : public Fl_Group { Fl_Check_Button *base_bt; - void DrawTextAndBoxes(const char *txt, int X, int Y) { + void draw_text_and_boxes(const char *txt, int X, int Y) { int wm = 0, hm = 0, wt = 0, ht = 0; int dx, dy; // measure text so we can draw the baseline first @@ -55,9 +55,9 @@ class TextExtentsTest : public Fl_Group } public: static Fl_Widget *create() { - return new TextExtentsTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + return new Ut_Text_Extents_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); } - TextExtentsTest(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { + Ut_Text_Extents_Test(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { base_bt = new Fl_Check_Button(x + w - 150, 50, 130, 20, "Show Baseline"); base_bt->box(FL_FLAT_BOX); base_bt->down_box(FL_DOWN_BOX); @@ -83,12 +83,12 @@ public: fl_font(FL_HELVETICA, 30); int xx = x0+55; int yy = y0+40; - DrawTextAndBoxes("!abcdeABCDE\"#A", xx, yy); yy += 50; // mixed string - DrawTextAndBoxes("oacs", xx, yy); xx += 100; // small glyphs - DrawTextAndBoxes("qjgIPT", xx, yy); yy += 50; xx -= 100; // glyphs with descenders - DrawTextAndBoxes("````````", xx, yy); yy += 50; // high small glyphs - DrawTextAndBoxes("--------", xx, yy); yy += 50; // mid small glyphs - DrawTextAndBoxes("________", xx, yy); yy += 50; // low small glyphs + draw_text_and_boxes("!abcdeABCDE\"#A", xx, yy); yy += 50; // mixed string + draw_text_and_boxes("oacs", xx, yy); xx += 100; // small glyphs + draw_text_and_boxes("qjgIPT", xx, yy); yy += 50; xx -= 100; // glyphs with descenders + draw_text_and_boxes("````````", xx, yy); yy += 50; // high small glyphs + draw_text_and_boxes("--------", xx, yy); yy += 50; // mid small glyphs + draw_text_and_boxes("________", xx, yy); yy += 50; // low small glyphs fl_font(FL_HELVETICA, 14); fl_color(FL_RED); fl_draw("fl_measure bounding box in RED", xx, yy); yy += 20; @@ -104,4 +104,4 @@ public: } }; -UnitTest textExtents(kTestText, "Rendering Text", TextExtentsTest::create); +UnitTest textExtents(UT_TEST_TEXT, "Rendering Text", Ut_Text_Extents_Test::create); diff --git a/test/unittest_unicode.cxx b/test/unittest_unicode.cxx index 65cea5628..0f6865a6b 100644 --- a/test/unittest_unicode.cxx +++ b/test/unittest_unicode.cxx @@ -45,7 +45,7 @@ static const char *helptext = "be visible and not touching. All the above should be unaffected " "by different font sizes and font settings."; -class UnicodeBoxTest : public Fl_Group { +class Ut_Unicode_Box_Test : public Fl_Group { Fl_Text_Buffer *textbuffer; Fl_Text_Display *textdisplay; Fl_Multiline_Input *multilineinput; @@ -53,20 +53,20 @@ class UnicodeBoxTest : public Fl_Group { Fl_Hor_Value_Slider *fontsize_slider; // Font choice callback - void FontChoice_CB2() { + void font_choice_cb2() { switch ( font_choice->value() ) { case 0: textdisplay->textfont(FL_COURIER); break; case 1: textdisplay->textfont(FL_SCREEN); break; } parent()->redraw(); } - static void FontChoice_CB(Fl_Widget*, void *userdata) { - UnicodeBoxTest *o = (UnicodeBoxTest*)userdata; - o->FontChoice_CB2(); + static void foant_choice_cb(Fl_Widget*, void *userdata) { + Ut_Unicode_Box_Test *o = (Ut_Unicode_Box_Test*)userdata; + o->font_choice_cb2(); } // Slider callback - apply new font size to widgets - void FontSizeSlider_CB2() { + void font_size_slider_cb2() { // Get font size from slider value, apply to widgets int fontsize = (int)fontsize_slider->value(); textdisplay->textsize(fontsize); @@ -74,17 +74,17 @@ class UnicodeBoxTest : public Fl_Group { multilineinput->position(0); // keep scrolled to top parent()->redraw(); } - static void FontSizeSlider_CB(Fl_Widget*, void *userdata) { - UnicodeBoxTest *o = (UnicodeBoxTest*)userdata; - o->FontSizeSlider_CB2(); + static void font_size_slider_cb(Fl_Widget*, void *userdata) { + Ut_Unicode_Box_Test *o = (Ut_Unicode_Box_Test*)userdata; + o->font_size_slider_cb2(); } public: static Fl_Widget *create() { - return new UnicodeBoxTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + return new Ut_Unicode_Box_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); } - UnicodeBoxTest(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { + Ut_Unicode_Box_Test(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { // Fl_Text_Display textbuffer = new Fl_Text_Buffer(); textbuffer->text(utf8_box_test); @@ -104,16 +104,16 @@ public: font_choice->add("FL_COURIER"); font_choice->add("FL_SCREEN"); font_choice->value(0); - font_choice->callback(FontChoice_CB, (Fl_Widget*)this); + font_choice->callback(foant_choice_cb, (Fl_Widget*)this); // Font size slider fontsize_slider = new Fl_Hor_Value_Slider(x+150, y+h-50, 200, 25, "Font size"); fontsize_slider->align(FL_ALIGN_LEFT); fontsize_slider->range(1.0, 50.0); fontsize_slider->step(1.0); fontsize_slider->value(14.0); - fontsize_slider->callback(FontSizeSlider_CB, (Fl_Widget*)this); + fontsize_slider->callback(font_size_slider_cb, (Fl_Widget*)this); end(); } }; -UnitTest unicode_font_test(kUnicodeBoxTest, "Unicode Boxes", UnicodeBoxTest::create); +UnitTest unicode_font_test(UT_TEST_UNICODE, "Unicode Boxes", Ut_Unicode_Box_Test::create); diff --git a/test/unittest_viewport.cxx b/test/unittest_viewport.cxx index 417a9cfa5..a4424ace8 100644 --- a/test/unittest_viewport.cxx +++ b/test/unittest_viewport.cxx @@ -22,12 +22,12 @@ // //------- test viewport clipping ---------- // -class ViewportTest : public Fl_Box { +class Ut_Viewport_Test : public Fl_Box { public: static Fl_Widget *create() { - return new ViewportTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + return new Ut_Viewport_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); } - ViewportTest(int x, int y, int w, int h) : Fl_Box(x, y, w, h) { + Ut_Viewport_Test(int x, int y, int w, int h) : Fl_Box(x, y, w, h) { label("Testing Viewport Alignment\n\n" "Only green lines should be visible.\n" "If red lines are visible in the corners of this window,\n" @@ -40,12 +40,12 @@ public: } void show() { Fl_Box::show(); - mainwin->testAlignment(1); + mainwin->test_alignment(1); } void hide() { Fl_Box::hide(); - mainwin->testAlignment(0); + mainwin->test_alignment(0); } }; -UnitTest viewport(kTestViewport, "Viewport Test", ViewportTest::create); +UnitTest viewport(UT_TEST_VIEWPORT, "Viewport Test", Ut_Viewport_Test::create); diff --git a/test/unittests.cxx b/test/unittests.cxx index fcbfe5b9e..e393613fb 100644 --- a/test/unittests.cxx +++ b/test/unittests.cxx @@ -31,99 +31,99 @@ #include #include #include -#include // fl_text_extents() +#include // fl_text_extents() #include // fl_strdup() -#include // malloc, free +#include // malloc, free -class MainWindow *mainwin = 0; -class Fl_Hold_Browser *browser = 0; +class Ut_Main_Window *mainwin = NULL; +class Fl_Hold_Browser *browser = NULL; -UnitTest::UnitTest(int index, const char *label, Fl_Widget* (*create)()) : - fWidget(0L) +int UnitTest::num_tests_ = 0; +UnitTest *UnitTest::test_list_[200] = { 0 }; + +UnitTest::UnitTest(int index, const char* label, Fl_Widget* (*create)()) + : widget_(0L) { - fLabel = fl_strdup(label); - fCreate = create; + label_ = fl_strdup(label); + create_ = create; add(index, this); } UnitTest::~UnitTest() { - delete fWidget; - free(fLabel); + delete widget_; + free(label_); } const char *UnitTest::label() { - return fLabel; + return label_; } void UnitTest::create() { - fWidget = fCreate(); - if (fWidget) fWidget->hide(); + widget_ = create_(); + if (widget_) widget_->hide(); } void UnitTest::show() { - if (fWidget) fWidget->show(); + if (widget_) widget_->show(); } void UnitTest::hide() { - if (fWidget) fWidget->hide(); + if (widget_) widget_->hide(); } -void UnitTest::add(int index, UnitTest *t) { - fTest[index] = t; - if (index>=nTest) - nTest = index+1; +void UnitTest::add(int index, UnitTest* t) { + test_list_[index] = t; + if (index >= num_tests_) + num_tests_ = index+1; } -int UnitTest::nTest = 0; -UnitTest *UnitTest::fTest[200] = { 0 }; - -MainWindow::MainWindow(int w, int h, const char *l) : -Fl_Double_Window(w, h, l), -fTestAlignment(0) +Ut_Main_Window::Ut_Main_Window(int w, int h, const char *l) + : Fl_Double_Window(w, h, l), + draw_alignment_test_(0) { } -void MainWindow::drawAlignmentIndicators() { - const int sze = 16; +void Ut_Main_Window::draw_alignment_indicators() { + const int SZE = 16; // top left corner - fl_color(FL_GREEN); fl_yxline(0, sze, 0, sze); - fl_color(FL_RED); fl_yxline(-1, sze, -1, sze); - fl_color(FL_WHITE); fl_rectf(3, 3, sze-2, sze-2); - fl_color(FL_BLACK); fl_rect(3, 3, sze-2, sze-2); + fl_color(FL_GREEN); fl_yxline(0, SZE, 0, SZE); + fl_color(FL_RED); fl_yxline(-1, SZE, -1, SZE); + fl_color(FL_WHITE); fl_rectf(3, 3, SZE-2, SZE-2); + fl_color(FL_BLACK); fl_rect(3, 3, SZE-2, SZE-2); // bottom left corner - fl_color(FL_GREEN); fl_yxline(0, h()-sze-1, h()-1, sze); - fl_color(FL_RED); fl_yxline(-1, h()-sze-1, h(), sze); - fl_color(FL_WHITE); fl_rectf(3, h()-sze-1, sze-2, sze-2); - fl_color(FL_BLACK); fl_rect(3, h()-sze-1, sze-2, sze-2); + fl_color(FL_GREEN); fl_yxline(0, h()-SZE-1, h()-1, SZE); + fl_color(FL_RED); fl_yxline(-1, h()-SZE-1, h(), SZE); + fl_color(FL_WHITE); fl_rectf(3, h()-SZE-1, SZE-2, SZE-2); + fl_color(FL_BLACK); fl_rect(3, h()-SZE-1, SZE-2, SZE-2); // bottom right corner - fl_color(FL_GREEN); fl_yxline(w()-1, h()-sze-1, h()-1, w()-sze-1); - fl_color(FL_RED); fl_yxline(w(), h()-sze-1, h(), w()-sze-1); - fl_color(FL_WHITE); fl_rectf(w()-sze-1, h()-sze-1, sze-2, sze-2); - fl_color(FL_BLACK); fl_rect(w()-sze-1, h()-sze-1, sze-2, sze-2); + fl_color(FL_GREEN); fl_yxline(w()-1, h()-SZE-1, h()-1, w()-SZE-1); + fl_color(FL_RED); fl_yxline(w(), h()-SZE-1, h(), w()-SZE-1); + fl_color(FL_WHITE); fl_rectf(w()-SZE-1, h()-SZE-1, SZE-2, SZE-2); + fl_color(FL_BLACK); fl_rect(w()-SZE-1, h()-SZE-1, SZE-2, SZE-2); // top right corner - fl_color(FL_GREEN); fl_yxline(w()-1, sze, 0, w()-sze-1); - fl_color(FL_RED); fl_yxline(w(), sze, -1, w()-sze-1); - fl_color(FL_WHITE); fl_rectf(w()-sze-1, 3, sze-2, sze-2); - fl_color(FL_BLACK); fl_rect(w()-sze-1, 3, sze-2, sze-2); + fl_color(FL_GREEN); fl_yxline(w()-1, SZE, 0, w()-SZE-1); + fl_color(FL_RED); fl_yxline(w(), SZE, -1, w()-SZE-1); + fl_color(FL_WHITE); fl_rectf(w()-SZE-1, 3, SZE-2, SZE-2); + fl_color(FL_BLACK); fl_rect(w()-SZE-1, 3, SZE-2, SZE-2); } -void MainWindow::draw() { +void Ut_Main_Window::draw() { Fl_Double_Window::draw(); - if (fTestAlignment) { - drawAlignmentIndicators(); + if (draw_alignment_test_) { + draw_alignment_indicators(); } } -void MainWindow::testAlignment(int v) { - fTestAlignment = v; +void Ut_Main_Window::test_alignment(int v) { + draw_alignment_test_ = v; redraw(); } //------- include the various unit tests as inline code ------- // callback whenever the browser value changes -void Browser_CB(Fl_Widget*, void*) { +void UT_BROWSER_CB(Fl_Widget*, void*) { for ( int t=1; t<=browser->size(); t++ ) { - UnitTest *ti = (UnitTest*)browser->data(t); + UnitTest* ti = (UnitTest*)browser->data(t); if ( browser->selected(t) ) { ti->show(); } else { @@ -135,22 +135,22 @@ void Browser_CB(Fl_Widget*, void*) { // This is the main call. It creates the window and adds all previously // registered tests to the browser widget. -int main(int argc, char **argv) { - Fl::args(argc,argv); +int main(int argc, char** argv) { + Fl::args(argc, argv); Fl::get_system_colors(); Fl::scheme(Fl::scheme()); // init scheme before instantiating tests Fl::visual(FL_RGB); Fl::use_high_res_GL(1); - mainwin = new MainWindow(MAINWIN_W, MAINWIN_H, "FLTK Unit Tests"); - mainwin->size_range(MAINWIN_W, MAINWIN_H); - browser = new Fl_Hold_Browser(BROWSER_X, BROWSER_Y, BROWSER_W, BROWSER_H, "Unit Tests"); + mainwin = new Ut_Main_Window(UT_MAINWIN_W, UT_MAINWIN_H, "FLTK Unit Tests"); + mainwin->size_range(UT_MAINWIN_W, UT_MAINWIN_H); + browser = new Fl_Hold_Browser(UT_BROWSER_X, UT_BROWSER_Y, UT_BROWSER_W, UT_BROWSER_H, "Unit Tests"); browser->align(FL_ALIGN_TOP|FL_ALIGN_LEFT); browser->when(FL_WHEN_CHANGED); - browser->callback(Browser_CB); + browser->callback(UT_BROWSER_CB); - int i, n = UnitTest::numTest(); + int i, n = UnitTest::num_tests(); for (i=0; ibegin(); t->create(); @@ -160,9 +160,9 @@ int main(int argc, char **argv) { } mainwin->resizable(mainwin); - mainwin->show(argc,argv); + mainwin->show(argc, argv); // Select first test in browser, and show that test. - browser->select(kTestAbout+1); - Browser_CB(browser,0); - return(Fl::run()); + browser->select(UT_TEST_ABOUT+1); + UT_BROWSER_CB(browser, 0); + return Fl::run(); } diff --git a/test/unittests.h b/test/unittests.h index 6b870df6d..475065d7c 100644 --- a/test/unittests.h +++ b/test/unittests.h @@ -21,36 +21,36 @@ #include // WINDOW/WIDGET SIZES -#define MAINWIN_W 700 // main window w() -#define MAINWIN_H 400 // main window h() -#define BROWSER_X 10 // browser x() -#define BROWSER_Y 25 // browser y() -#define BROWSER_W 150 // browser w() -#define BROWSER_H MAINWIN_H-35 // browser h() -#define TESTAREA_X (BROWSER_W + 20) // test area x() -#define TESTAREA_Y 25 // test area y() -#define TESTAREA_W (MAINWIN_W - BROWSER_W - 30) // test area w() -#define TESTAREA_H BROWSER_H // test area h() +const int UT_MAINWIN_W = 700; // main window w() +const int UT_MAINWIN_H = 400; // main window h() +const int UT_BROWSER_X = 10; // browser x() +const int UT_BROWSER_Y = 25; // browser y() +const int UT_BROWSER_W = 150; // browser w() +const int UT_BROWSER_H = (UT_MAINWIN_H-35); // browser h() +const int UT_TESTAREA_X = (UT_BROWSER_W + 20); // test area x() +const int UT_TESTAREA_Y = 25; // test area y() +const int UT_TESTAREA_W = (UT_MAINWIN_W - UT_BROWSER_W - 30); // test area w() +const int UT_TESTAREA_H = UT_BROWSER_H; // test area h() typedef void (*UnitTestCallback)(const char*, class Fl_Group*); -extern class MainWindow *mainwin; -extern class Fl_Hold_Browser *browser; +extern class Ut_Main_Window* mainwin; +extern class Fl_Hold_Browser* browser; enum { - kTestAbout = 0, - kTestPoints, - kTestFastShapes, - kTestCircles, - kTestComplexShapes, - kTestText, - kUnicodeBoxTest, - kTestSymbol, - kTestImages, - kTestViewport, - kTestScrollbarsize, - kTestSchemes, - kTestSimpleTerminal + UT_TEST_ABOUT = 0, + UT_TEST_POINTS, + UT_TEST_FAST_SHAPES, + UT_TEST_CIRCLES, + UT_TEST_COMPLEX_SHAPES, + UT_TEST_TEXT, + UT_TEST_UNICODE, + UT_TEST_SYBOL, + UT_TEST_IMAGES, + UT_TEST_VIEWPORT, + UT_TEST_SCROLLBARSIZE, + UT_TEST_SCHEMES, + UT_TEST_SIMPLE_TERMINAL }; // This class helps to automatically register a new test with the unittest app. @@ -59,30 +59,31 @@ class UnitTest { public: UnitTest(int index, const char *label, Fl_Widget* (*create)()); ~UnitTest(); - const char *label(); + const char* label(); void create(); void show(); void hide(); - static int numTest() { return nTest; } - static UnitTest *test(int i) { return fTest[i]; } + static int num_tests() { return num_tests_; } + static UnitTest* test(int i) { return test_list_[i]; } private: - char *fLabel; - Fl_Widget *(*fCreate)(); - Fl_Widget *fWidget; - static void add(int index, UnitTest *t); - static int nTest; - static UnitTest *fTest[]; + char* label_; + Fl_Widget* (*create_)(); + Fl_Widget* widget_; + static void add(int index, UnitTest* t); + static int num_tests_; + static UnitTest* test_list_[]; }; // The main window needs an additional drawing feature in order to support // the viewport alignment test. -class MainWindow : public Fl_Double_Window { +class Ut_Main_Window : public Fl_Double_Window { public: - MainWindow(int w, int h, const char *l=0L); - void drawAlignmentIndicators(); + Ut_Main_Window(int w, int h, const char *l=0L); + void draw_alignment_indicators(); void draw(); - void testAlignment(int v); - int fTestAlignment; + void test_alignment(int v); +private: + int draw_alignment_test_; }; #endif