linux-joystick/test/test.cpp

Go to the documentation of this file.
00001 /*
00002  * test.cpp
00003  *
00004  * Copyright (C) 2011  Thomas A. Vaughan
00005  * All rights reserved.
00006  *
00007  * Test of the linux joystick source device
00008  */
00009 
00010 // includes --------------------------------------------------------------------
00011 #include <iostream>
00012 #include <time.h>
00013 
00014 #include "common/common.h"
00015 #include "linux-joystick/linux-joystick.h"
00016 #include "perf/perf.h"
00017 #include "source-device/sd-test.h"
00018 #include "util/file.h"
00019 
00020 
00021 ////////////////////////////////////////////////////////////////////////////////
00022 //
00023 //      static helper methods
00024 //
00025 ////////////////////////////////////////////////////////////////////////////////
00026 
00027 static void
00028 doTest
00029 (
00030 void
00031 )
00032 {
00033         smart_ptr<gamepad::SourceDeviceFactory> factory =
00034             gamepad::getLinuxJoystickSourceDeviceFactory();
00035         ASSERT(factory,
00036             "failed to retrieve linux joystick source device factory");
00037 
00038         DPRINTF("Created source device factory!");
00039         DPRINTF("  name: '%s'", factory->getName());
00040 
00041         gamepad::testSourceDeviceFactory(factory);
00042 }
00043 
00044 
00045 
00046 ////////////////////////////////////////////////////////////////////////////////
00047 //
00048 //      entry point
00049 //
00050 ////////////////////////////////////////////////////////////////////////////////
00051 
00052 int
00053 main
00054 (
00055 IN int argc,
00056 IN const char * argv[]
00057 )
00058 {
00059 
00060         int retval = 0;
00061         try {
00062                 perf::Timer timer("overall timer");
00063 
00064                 doTest();
00065 
00066         } catch (std::exception& e) {
00067                 DPRINTF("EXCEPTION: %s", e.what());
00068                 retval = 1;
00069         }
00070 
00071         perf::dumpTimingSummary(std::cerr);
00072 
00073         return retval;
00074 }
00075