summaryrefslogtreecommitdiffstats
path: root/dcop/tests/driver.cpp
blob: 18b983829ac7c8a2207e69dbedc5cd0080a5c146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "driver.h"
#include <tdeapplication.h>
#include <iostream>
#include <dcopclient.h>
#include <tdecmdlineargs.h>
#include <tqtimer.h>
#include <tqtimer.h>

using namespace std;

#ifdef _MSC_VER
#define __PRETTY_FUNCTION__ __FUNCTION__
#endif

Driver::Driver(const char* app)
	:Test_stub( app, "TestInterface" ),
	 DCOPStub( app, "TestInterface" ), // DCOPStub is *virtual* inherited
	count( 0 )
{

}

TQTextStream output(  fopen( "driver.returns", "w" ) , IO_WriteOnly );	
#include <iostream>
void Driver::test()
{
	// This is written like this to allow the potentially ASYNC calls to be syncronized
	// Just sleeping would mean that no errors were reported until much later
	// I could improve it, so that we don't sleep after a synchronous call, but I will
	// leave it for later
	
	std::cerr  << __PRETTY_FUNCTION__ << " count: " << count << '\n';
	
	Driver* object = this;
	switch ( count ) {
#include "driver.generated"
		default:
			exit( 0 );
	}

	++count;
	TQTimer::singleShot( 100, this, TQT_SLOT( test() ) );
}

#include "driver.moc"

#ifdef Q_OS_WIN
# define main kdemain
#endif

int main(int argc, char** argv)
{
	if ( argc < 2 ) { tqWarning("Usage: driver <appid>"); return 1; }
	const char* appname = strdup( argv[ 1 ] );
	argv[ 1 ] = 0; // sue me
	TDECmdLineArgs::init( argc, argv, "TestAppDriver", "Tests the dcop familly of tools + libraries", "1.0" ); // FIXME
	TDEApplication app;
	app.dcopClient()->attach(  );
	app.dcopClient()->registerAs( "TestAppDriver" );
	Driver * object = new Driver( appname );
	TQTimer::singleShot( 10, object, TQT_SLOT( test() ) );
	return app.exec();
}