Ejemplo n.º 1
0
Archivo: main.c Proyecto: hharte/vttest
int
tst_doublesize(MENU_ARGS)
{
  /* Test of:
     DECSWL  (Single Width Line)
     DECDWL  (Double Width Line)
     DECDHL  (Double Height Line) (also implicit double width)
   */

  int col, i, w, w1;

  /* Print the test pattern in both 80 and 132 character width  */

  for (w = 0; w <= 1; w++) {
    w1 = 13 * w;

    ed(2);
    cup(1, 1);
    if (w) {
      deccolm(TRUE);
      printf("%3d column mode", max_cols);
    } else {
      deccolm(FALSE);
      printf("%3d column mode", min_cols);
    }

    cup(5, 3 + 2 * w1);
    printf("v------- left margin");

    cup(7, 3 + 2 * w1);
    printf("This is a normal-sized line");

    decdhl(0);
    decdhl(1);
    decdwl();
    decswl();
    cup(9, 2 + w1);
    printf("This is a Double-width line");

    decswl();
    decdhl(0);
    decdhl(1);
    decdwl();

    cup(11, 2 + w1);
    decdwl();
    decswl();
    decdhl(1);
    decdhl(0);
    printf("This is a Double-width-and-height line");

    cup(12, 2 + w1);
    decdwl();
    decswl();
    decdhl(0);
    decdhl(1);
    printf("This is a Double-width-and-height line");

    cup(14, 2 + w1);
    decdwl();
    decswl();
    decdhl(1);
    decdhl(0);
    el(2);
    printf("This is another such line");

    cup(15, 2 + w1);
    decdwl();
    decswl();
    decdhl(0);
    decdhl(1);
    printf("This is another such line");

    cup(17, 3 + 2 * w1);
    printf("^------- left margin");

    cup(21, 1);
    printf("This is not a double-width line");
    for (i = 0; i <= 1; i++) {
      cup(21, 6);
      if (i) {
        printf("**is**");
        decdwl();
      } else {
        printf("is not");
        decswl();
      }
      cup(max_lines - 1, 1);
      holdit();
    }
  }
  /* Set vanilla tabs for next test */
  cup(1, 1);
  tbc(3);
  for (col = 1; col <= max_cols; col += TABWIDTH) {
    cuf(TABWIDTH);
    hts();
  }
  deccolm(FALSE);
  ed(2);
  /* *INDENT-OFF* */
  scs_graphics();
  cup( 8,1); decdhl(0); printf("lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk");
  cup( 9,1); decdhl(1); printf("lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk");
  cup(10,1); decdhl(0); printf("x%c%c%c%c%cx",9,9,9,9,9);
  cup(11,1); decdhl(1); printf("x%c%c%c%c%cx",9,9,9,9,9);
  cup(12,1); decdhl(0); printf("x%c%c%c%c%cx",9,9,9,9,9);
  cup(13,1); decdhl(1); printf("x%c%c%c%c%cx",9,9,9,9,9);
  scs(1, '0');  /* should look the same as scs_graphics() */
  cup(14,1); decdhl(0); printf("x                                      x");
  cup(15,1); decdhl(1); printf("x                                      x");
  cup(16,1); decdhl(0); printf("mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj");
  cup(17,1); decdhl(1); printf("mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj");
  scs_normal();
  /* *INDENT-ON* */

  sgr("1;5");
  cup(12, 3);
  printf("* The mad programmer strikes again * ");

  cup(13, 3);
  printf("%c", 9);

  cub(6);
  printf("* The mad programmer strikes again *");
  sgr("0");

  cup(max_lines - 2, 1);
  println("Another test pattern...  a frame with blinking bold text,");
  printf("all in double-height double-width size. ");
  holdit();

  decstbm(8, max_lines);  /* Absolute origin mode, so cursor is set at (1,1) */
  cup(8, 1);
  for (i = 1; i <= 12; i++)
    ri();
  decstbm(0, 0);  /* No scroll region     */
  cup(1, 1);
  printf("%s", "Exactly half of the box should remain. ");
  return MENU_HOLD;
}
Ejemplo n.º 2
0
int main()
{

    boost::asio::io_service io_service;
    Eris::Logged.connect(sigc::ptr_fun(writeLog));

    Atlas::Objects::Factories * f = Atlas::Objects::Factories::instance();
    assert(!f->hasFactory("unseen"));

    {
        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);
    }

    // Make sure the op classes have been installed, and the initial
    // constructor code path has been tested.
    assert(f->hasFactory("unseen"));
    assert(f->hasFactory("attack"));

    // Test the other code path when a second connection is created.
    {
        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);
    }

    // Test isConnected.
    {
        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);

        assert(!tbc.isConnected());
    }

    // Test getStatus().
    {
        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);

        assert(tbc.getStatus() == Eris::BaseConnection::DISCONNECTED);
    }

    // Test setStatus().
    {
        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);

        assert(tbc.getStatus() == Eris::BaseConnection::DISCONNECTED);

        tbc.test_setStatus(Eris::BaseConnection::CONNECTED);

        assert(tbc.getStatus() == Eris::BaseConnection::CONNECTED);

        tbc.test_setStatus(Eris::BaseConnection::DISCONNECTED);
    }

    // Test connect() and verify getStatus() changes.
    {
        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);

        assert(tbc.getStatus() == Eris::BaseConnection::DISCONNECTED);

        int ret = tbc.connect("localhost", 6723);

        assert(ret == 0);

        assert(tbc.getStatus() == Eris::BaseConnection::CONNECTING);
    }

    // Test onConnect() does nothing.
    {
        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);

        tbc.test_onConnect();
    }

    // Test onConnect() emits the signal.
    {
        SignalFlagger onConnect_checker;

        assert(!onConnect_checker.flagged());

        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);

        tbc.Connected.connect(sigc::mem_fun(onConnect_checker,
                                            &SignalFlagger::set));

        assert(!onConnect_checker.flagged());

        tbc.test_onConnect();

        assert(onConnect_checker.flagged());
    }

    // Test hardDisconnect() does nothing.
    {
        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);

        tbc.test_hardDisconnect(true);
    }

//    // Test hardDisconnect() throws in polldefault when connected
//    {
//        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);
//
//        // Add members to be consistent with connected state.
//        tbc.setup_stream();
//        tbc.setup_codec();
//        tbc.setup_encode();
//        // Make the state different
//        tbc.test_setStatus(Eris::BaseConnection::CONNECTED);
//
//        try {
//            tbc.test_hardDisconnect(true);
//        }
//        catch (Eris::InvalidOperation & eio) {
//        }
//
//        // Make it disconnected again, or we crash on destructor
//        tbc.test_setStatus(Eris::BaseConnection::DISCONNECTED);
//    }
//
//    // Test hardDisconnect() throws in polldefault when disconnecting
//    {
//        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);
//
//        // Add members to be consistent with disconnecting state.
//        tbc.setup_stream();
//        tbc.setup_codec();
//        tbc.setup_encode();
//        // Make the state different
//        tbc.test_setStatus(Eris::BaseConnection::DISCONNECTING);
//
//        try {
//            tbc.test_hardDisconnect(true);
//        }
//        catch (Eris::InvalidOperation & eio) {
//        }
//
//        // Make it disconnected again, or we crash on destructor
//        tbc.test_setStatus(Eris::BaseConnection::DISCONNECTED);
//    }
//
//    // Test hardDisconnect() throws in polldefault when negotiating
//    {
//        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);
//
//        // Add members to be consistent with negotiating state.
//        tbc.setup_stream();
//        tbc.setup_sc();
//        // Make the state different
//        tbc.test_setStatus(Eris::BaseConnection::NEGOTIATE);
//
//        try {
//            tbc.test_hardDisconnect(true);
//        }
//        catch (Eris::InvalidOperation & eio) {
//        }
//
//        // Make it disconnected again, or we crash on destructor
//        tbc.test_setStatus(Eris::BaseConnection::DISCONNECTED);
//    }
//
//    // Test hardDisconnect() throws in polldefault when negotiating
//    {
//        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);
//
//        // Add members to be consistent with connecting state.
//        tbc.setup_stream();
//        // Make the state different
//        tbc.test_setStatus(Eris::BaseConnection::CONNECTING);
//
//        try {
//            tbc.test_hardDisconnect(true);
//        }
//        catch (Eris::InvalidOperation & eio) {
//        }
//
//        // Make it disconnected again, or we crash on destructor
//        tbc.test_setStatus(Eris::BaseConnection::DISCONNECTED);
//    }

    // Test hardDisconnect() throws in polldefault when negotiating
    {
        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);

        // Add members to be consistent with connecting state.
        tbc.setup_socket();
        // Make the state different
        tbc.test_setStatus(Eris::BaseConnection::INVALID_STATUS);

        try {
            tbc.test_hardDisconnect(true);
        }
        catch (Eris::InvalidOperation & eio) {
        }

        // Make it disconnected again, or we crash on destructor
        tbc.test_setStatus(Eris::BaseConnection::DISCONNECTED);
    }

    // Test onConnectTimeout()
    {
        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);

        tbc.test_onConnectTimeout();

        assert(tbc.timeout);
    }

    // Test onNegotiateTimeout()
    {
        TestBaseConnection tbc(io_service, new Atlas::Message::QueuedDecoder);

        tbc.test_onNegotiateTimeout();

        assert(tbc.timeout);
    }

    return 0;
}
Ejemplo n.º 3
0
Archivo: main.c Proyecto: hharte/vttest
int
tst_screen(MENU_ARGS)
{
  /* Test of:
     - DECSTBM (Set Top and Bottom Margins)
     - TBC     (Tabulation Clear)
     - HTS     (Horizontal Tabulation Set)
     - SM RM   (Set/Reset mode): - 80/132 chars
     .                           - Origin: Relative/absolute
     .                           - Scroll: Smooth/jump
     .                           - Wraparound
     - SGR     (Select Graphic Rendition)
     - SM RM   (Set/Reset Mode) - Inverse
     - DECSC   (Save Cursor)
     - DECRC   (Restore Cursor)
   */

  int i, j, cset, row, col, background;

  static const char *tststr = "*qx`";
  static const char *attr[5] =
  {
    ";0", ";1", ";4", ";5", ";7"
  };

  set_tty_crmod(TRUE);  /* want to disable tab/space conversion */

  cup(1, 1);
  decawm(TRUE); /* DECAWM: Wrap Around ON */
  for (col = 1; col <= min_cols * 2; col++)
    printf("*");
  decawm(FALSE);  /* DECAWM: Wrap Around OFF */
  cup(3, 1);
  for (col = 1; col <= min_cols * 2; col++)
    printf("*");
  decawm(TRUE); /* DECAWM: Wrap Around ON */
  cup(5, 1);
  println("This should be three identical lines of *'s completely filling");
  println("the top of the screen without any empty lines between.");
  println("(Test of WRAP AROUND mode setting.)");
  holdit();

  ed(2);
  tbc(3);
  cup(1, 1);
  for (col = 1; col <= min_cols - 2; col += 3) {
    cuf(3);
    hts();
  }
  cup(1, 4);
  for (col = 4; col <= min_cols - 2; col += 6) {
    tbc(0);
    cuf(6);
  }
  cup(1, 7);
  tbc(1);
  tbc(2);       /* no-op */
  cup(1, 1);
  for (col = 1; col <= min_cols - 2; col += 6)
    printf("%c*", TAB);
  cup(2, 2);
  for (col = 2; col <= min_cols - 2; col += 6)
    printf("     *");
  cup(4, 1);
  println("Test of TAB setting/resetting. These two lines");
  printf("should look the same. ");
  holdit();
  for (background = 0; background <= 1; background++) {
    if (background)
      decscnm(FALSE);
    else
      decscnm(TRUE);
    deccolm(TRUE);  /* 132 cols */
    ed(2);      /* VT100 clears screen on SM3/RM3, but not obviously, so... */
    cup(1, 1);
    tbc(3);
    for (col = 1; col <= max_cols; col += TABWIDTH) {
      cuf(TABWIDTH);
      hts();
    }
    cup(1, 1);
    for (col = 1; col <= max_cols; col += 10)
      printf("%.*s", (max_cols > col) ? (max_cols - col) : 10, "1234567890");
    for (row = 3; row <= 20; row++) {
      cup(row, row);
      printf("This is %d column mode, %s background.", max_cols,
             background ? "dark" : "light");
    }
    holdit();
    deccolm(FALSE);   /* 80 cols */
    ed(2);      /* VT100 clears screen on SM3/RM3, but not obviously, so... */
    cup(1, 1);
    for (col = 1; col <= min_cols; col += 10)
      printf("%.*s", (min_cols > col) ? (min_cols - col) : 10, "1234567890");
    for (row = 3; row <= 20; row++) {
      cup(row, row);
      printf("This is %d column mode, %s background.", min_cols,
             background ? "dark" : "light");
    }
    holdit();
  }
  do_scrolling();
  ed(2);
  decstbm(max_lines - 1, max_lines);
  printf(
          "\nOrigin mode test. This line should be at the bottom of the screen.");
  cup(1, 1);
  printf("%s",
         "This line should be the one above the bottom of the screen. ");
  holdit();
  ed(2);
  decom(FALSE); /* Origin mode (absolute) */
  cup(max_lines, 1);
  printf(
          "Origin mode test. This line should be at the bottom of the screen.");
  cup(1, 1);
  printf("%s", "This line should be at the top of the screen. ");
  holdit();
  decstbm(1, max_lines);

  ed(2);
  /* *INDENT-OFF* */
  cup( 1,20); printf("Graphic rendition test pattern:");
  cup( 4, 1); sgr("0");         printf("vanilla");
  cup( 4,40); sgr("0;1");       printf("bold");
  cup( 6, 6); sgr(";4");        printf("underline");
  cup( 6,45);sgr(";1");sgr("4");printf("bold underline");
  cup( 8, 1); sgr("0;5");       printf("blink");
  cup( 8,40); sgr("0;5;1");     printf("bold blink");
  cup(10, 6); sgr("0;4;5");     printf("underline blink");
  cup(10,45); sgr("0;1;4;5");   printf("bold underline blink");
  cup(12, 1); sgr("1;4;5;0;7"); printf("negative");
  cup(12,40); sgr("0;1;7");     printf("bold negative");
  cup(14, 6); sgr("0;4;7");     printf("underline negative");
  cup(14,45); sgr("0;1;4;7");   printf("bold underline negative");
  cup(16, 1); sgr("1;4;;5;7");  printf("blink negative");
  cup(16,40); sgr("0;1;5;7");   printf("bold blink negative");
  cup(18, 6); sgr("0;4;5;7");   printf("underline blink negative");
  cup(18,45); sgr("0;1;4;5;7"); printf("bold underline blink negative");
  /* *INDENT-ON* */

  sgr("");

  decscnm(FALSE);   /* Inverse video off */
  cup(max_lines - 1, 1);
  el(0);
  printf("Dark background. ");
  holdit();

  decscnm(TRUE);  /* Inverse video */
  cup(max_lines - 1, 1);
  el(0);
  printf("Light background. ");
  holdit();

  decscnm(FALSE);

  ed(2);
  /* *INDENT-OFF* */
  cup(8,12); printf("normal");
  cup(8,24); printf("bold");
  cup(8,36); printf("underscored");
  cup(8,48); printf("blinking");
  cup(8,60); printf("reversed");
  cup(10,1); printf("stars:");
  cup(12,1); printf("line:");
  cup(14,1); printf("x'es:");
  cup(16,1); printf("diamonds:");
  /* *INDENT-ON* */

  for (cset = 0; cset <= 3; cset++) {
    for (i = 0; i <= 4; i++) {
      cup(10 + 2 * cset, 12 + 12 * i);
      sgr(attr[i]);
      if (cset == 0 || cset == 2)
        scs_normal();
      else
        scs_graphics();
      for (j = 0; j <= 4; j++) {
        printf("%c", tststr[cset]);
      }
      decsc();
      cup(cset + 1, i + 1);
      sgr("");
      scs_normal();
      printf("A");
      decrc();
      for (j = 0; j <= 4; j++) {
        printf("%c", tststr[cset]);
      }
    }
  }

  sgr("0");
  scs_normal();
  cup(21, 1);
  println("Test of the SAVE/RESTORE CURSOR feature. There should");
  println("be ten characters of each flavour, and a rectangle");
  println("of 5 x 4 A's filling the top left of the screen.");

  restore_ttymodes();
  return MENU_HOLD;
}