| 1 | // |
| 2 | // Unit tests for the Fast Light Tool Kit (FLTK). |
| 3 | // |
| 4 | // Copyright 1998-2022 by Bill Spitzak and others. |
| 5 | // |
| 6 | // This library is free software. Distribution and use rights are outlined in |
| 7 | // the file "COPYING" which should have been included with this file. If this |
| 8 | // file is missing or damaged, see the license at: |
| 9 | // |
| 10 | // https://www.fltk.org/COPYING.php |
| 11 | // |
| 12 | // Please see the following page on how to report bugs and issues: |
| 13 | // |
| 14 | // https://www.fltk.org/bugs.php |
| 15 | // |
| 16 | |
| 17 | #include "unittests.h" |
| 18 | |
| 19 | #include <FL/Fl_Box.H> |
| 20 | #include <FL/fl_draw.H> |
| 21 | |
| 22 | // |
| 23 | //------- test viewport clipping ---------- |
| 24 | // |
| 25 | class Ut_Viewport_Test : public Fl_Box { |
| 26 | public: |
| 27 | static Fl_Widget *create() { |
| 28 | return new Ut_Viewport_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H); |
| 29 | } |
| 30 | Ut_Viewport_Test(int x, int y, int w, int h) : Fl_Box(x, y, w, h) { |
| 31 | label("Testing Viewport Alignment\n\n" |
| 32 | "Only green lines should be visible.\n" |
| 33 | "If red lines are visible in the corners of this window,\n" |
| 34 | "your viewport alignment and clipping is off.\n" |
| 35 | "If there is a space between the green lines and the window border,\n" |
| 36 | "the viewport is off, but some clipping may be working.\n" |
| 37 | "Also, your window size may be off to begin with."); |
| 38 | align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER|FL_ALIGN_WRAP); |
| 39 | box(FL_BORDER_BOX); |
| 40 | } |
| 41 | void show() FL_OVERRIDE { |
| 42 | Fl_Box::show(); |
| 43 | mainwin->test_alignment(1); |
| 44 | } |
| 45 | void hide() FL_OVERRIDE { |
| 46 | Fl_Box::hide(); |
| 47 | mainwin->test_alignment(0); |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | UnitTest viewport(UT_TEST_VIEWPORT, "Viewport Test", Ut_Viewport_Test::create); |