Changeset 40:ec5dde8a6ff6 in xplra for test


Ignore:
Timestamp:
02/14/13 18:21:47 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented the client support for the new commands and updated the basic test programs with tests showing messages

Location:
test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • test/basicctest.c

    r36 r40  
    3333#include <stdio.h>
    3434#include <string.h>
     35
     36#ifdef _WIN32
     37#include <windows.h>
     38#else
     39#include <unistd.h>
     40#endif
     41
     42//------------------------------------------------------------------------------
     43
     44#ifdef _WIN32
     45void _sleep(int ms)
     46{
     47    Sleep(ms);
     48}
     49#else
     50void _sleep(int ms)
     51{
     52    usleep(ms*1000);
     53}
     54#endif
     55
    3556
    3657//------------------------------------------------------------------------------
     
    7495    }
    7596
     97    printf("Showing a message...\n");
     98    if (xplra_show_message(connectionID, "[basictest] Starting tests", 5.0)<0) goto error;
     99    printf("\n");
     100
    76101    printf("Querying the versions...\n");
    77102    if (xplra_get_versions(connectionID, &xplaneVersion,
     
    341366    printf("The tail number is: '%s'\n\n", (char*)tailNum);
    342367
     368    printf("Preparing for the message tests, sleeping for 5 seconds...\n");
     369    _sleep(5*1000);
     370
     371    printf("Showing a message for 10 seconds...\n");
     372    if (xplra_show_message(connectionID, "[basictest] this message appears for 10 seconds", 10.0)<0) {
     373        goto error;
     374    }
     375
     376    printf("Sleeping for 3 seconds...\n");
     377    _sleep(3*1000);
     378
     379    printf("Showing another message interrupting the previous one for 3 seconds");
     380    if (xplra_show_message(connectionID, "[basictest] but this message interrupts it, and is displayed for 3 seconds", 3.0)<0) {
     381        goto error;
     382    }
     383
     384    printf("Sleeping for 5 seconds...\n");
     385    _sleep(5*1000);
     386    if (xplra_show_message(connectionID, "[basictest] and the tests come to an end!", 5.0)<0) {
     387        goto error;
     388    }
     389
    343390    goto cleanup;
    344391error:
  • test/basictest.cc

    r36 r40  
    3131#include <hu/varadiistvan/xplra/XPlane.h>
    3232
     33#include <hu/varadiistvan/scpl/Thread.h>
     34
    3335#include <cstdio>
    3436#include <cstring>
     
    3941using hu::varadiistvan::xplra::Exception;
    4042using hu::varadiistvan::xplra::ProtocolException;
     43
     44using hu::varadiistvan::scpl::Thread;
    4145
    4246using std::string;
     
    5660        int xplmVersion = 0;
    5761        int xplraVersion = 0;
     62
     63        printf("Showing a message...\n");
     64        xplane.showMessage("[basictest] Starting tests", 5.0);
     65        printf("\n");
    5866
    5967        printf("Querying the versions...\n");
     
    242250        }
    243251
     252        printf("Preparing for the message tests, sleeping for 5 seconds...\n");
     253        Thread::sleep(5*1000);
     254
     255        printf("Showing a message for 10 seconds...\n");
     256        xplane.showMessage("[basictest] this message appears for 10 seconds", 10.0);
     257
     258        printf("Sleeping for 3 seconds...\n");
     259        Thread::sleep(3*1000);
     260
     261        printf("Showing another message interrupting the previous one for 3 seconds\n");
     262        xplane.showMessage("[basictest] but this message interrupts it, and is displayed for 3 seconds", 3.0);
     263
     264        printf("Sleeping for 5 seconds...\n");
     265        Thread::sleep(5*1000);
     266        xplane.showMessage("[basictest] and the tests come to an end!", 5.0);
    244267
    245268        return 0;
  • test/basictest.py

    r36 r40  
    11# Basic test program for the Python client library
     2
     3#------------------------------------------------------------------------------
     4
     5import time
    26
    37#------------------------------------------------------------------------------
     
    1216        xplane.connect()
    1317        print "Connected to X-Plane."
     18        print
     19
     20        print "Showing a message..."
     21        xplane.showMessage("[basictest] Starting tests", 5.0)
    1422        print
    1523
     
    133141        print
    134142
     143        print "Preparing for the message tests, sleeping for 5 seconds..."
     144        time.sleep(5.0)
     145
     146        print "Showing a message for 10 seconds..."
     147        xplane.showMessage("[basictest] this message appears for 10 seconds", 10.0)
     148
     149        print "Sleeping for 3 seconds..."
     150        time.sleep(3.0)
     151
     152        print "Showing another message interrupting the previous one for 3 seconds"
     153        xplane.showMessage("[basictest] but this message interrupts it, and is displayed for 3 seconds", 3.0)
     154
     155        print "Sleeping for 5 seconds..."
     156        time.sleep(5.0)
     157        xplane.showMessage("[basictest] and the tests come to an end!", 5.0)
    135158
    136159    except Exception as e:
Note: See TracChangeset for help on using the changeset viewer.