summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/.cvsignore14
-rw-r--r--tests/Makefile.am44
-rw-r--r--tests/test_addressbook.c150
-rw-r--r--tests/test_async.c53
-rw-r--r--tests/test_callbacks.c30
-rw-r--r--tests/test_calls.c19
-rw-r--r--tests/test_capabilities.c35
-rw-r--r--tests/test_comm.c48
-rw-r--r--tests/test_mailto.c28
-rw-r--r--tests/test_remotefile.c46
-rw-r--r--tests/test_runasuser.c19
-rw-r--r--tests/test_screensaving.c23
12 files changed, 0 insertions, 509 deletions
diff --git a/tests/.cvsignore b/tests/.cvsignore
deleted file mode 100644
index f7b5724..0000000
--- a/tests/.cvsignore
+++ /dev/null
@@ -1,14 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-test_async
-test_calls
-test_comm
-test_mailto
-test_remotefile
-test_runasuser
-test_screensaving
-test_capabilities
-test_callbacks
-test_fallback
diff --git a/tests/Makefile.am b/tests/Makefile.am
deleted file mode 100644
index f894e18..0000000
--- a/tests/Makefile.am
+++ /dev/null
@@ -1,44 +0,0 @@
-noinst_PROGRAMS = test_comm test_calls test_runasuser test_screensaving test_mailto test_remotefile test_async \
- test_capabilities test_callbacks test_addressbook
-
-test_comm_SOURCES = test_comm.c
-test_comm_LDADD = ../lib/libdapi.la
-test_comm_LDFLAGS = $(all_libraries)
-
-test_calls_SOURCES = test_calls.c
-test_calls_LDADD = ../lib/libdapi.la
-test_calls_LDFLAGS = $(all_libraries)
-
-test_runasuser_SOURCES = test_runasuser.c
-test_runasuser_LDADD = ../lib/libdapi.la
-test_runasuser_LDFLAGS = $(all_libraries)
-
-test_screensaving_SOURCES = test_screensaving.c
-test_screensaving_LDADD = ../lib/libdapi.la
-test_screensaving_LDFLAGS = $(all_libraries)
-
-test_mailto_SOURCES = test_mailto.c
-test_mailto_LDADD = ../lib/libdapi.la
-test_mailto_LDFLAGS = $(all_libraries)
-
-test_remotefile_SOURCES = test_remotefile.c
-test_remotefile_LDADD = ../lib/libdapi.la
-test_remotefile_LDFLAGS = $(all_libraries)
-
-test_async_SOURCES = test_async.c
-test_async_LDADD = ../lib/libdapi.la
-test_async_LDFLAGS = $(all_libraries)
-
-test_capabilities_SOURCES = test_capabilities.c
-test_capabilities_LDADD = ../lib/libdapi.la
-test_capabilities_LDFLAGS = $(all_libraries)
-
-test_callbacks_SOURCES = test_callbacks.c
-test_callbacks_LDADD = ../lib/libdapi.la
-test_callbacks_LDFLAGS = $(all_libraries)
-
-test_addressbook_SOURCES = test_addressbook.c
-test_addressbook_LDADD = ../lib/libdapi.la
-test_addressbook_LDFLAGS = $(all_libraries)
-
-INCLUDES = -I$(top_builddir)/include $(all_includes)
diff --git a/tests/test_addressbook.c b/tests/test_addressbook.c
deleted file mode 100644
index 5b7f192..0000000
--- a/tests/test_addressbook.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/******************************************************************************
- Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
- All Rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <dapi/comm.h>
-#include <dapi/calls.h>
-
-void printContact( DapiConnection* conn, int num, char* id );
-void printVCard( DapiConnection* conn, char* id );
-
-int main(int argc, char** argv)
- {
- DapiConnection* conn = dapi_connectAndInit();
- if( conn == NULL )
- {
- fprintf( stderr, "Cannot connect!\n" );
- return 1;
- }
-
- char* ownerID = NULL;
- if( dapi_AddressBookOwner( conn, &ownerID ) )
- {
- printf( "AddressBookOwner: contact for current user available:\n" );
- printContact( conn, 0, ownerID );
- free( ownerID );
- }
- else
- printf( "AddressBookOwner: no contact for the current user\n" );
- printf("\n");
-
- stringarr idlist;
- if( dapi_AddressBookList( conn, &idlist ) )
- printf( "AddressBookList: %d contact IDs\n", idlist.count );
- else
- printf( "AddressBookList: call failed\n" );
-
- int i;
- for( i = 0; i < idlist.count; ++i )
- printContact( conn, i, idlist.data[i] );
- dapi_freestringarr( idlist );
-
- if( argc <= 1 )
- printf( "\nNo commandline args, skipping FindByName\n" );
- else
- {
- for( i = 1; i < argc; ++i )
- {
- printf( "\nSearching for '%s'\n", argv[i] );
-
- stringarr foundlist;
- if( dapi_AddressBookFindByName( conn, argv[i], &foundlist ) )
- {
- if ( foundlist.count > 0 )
- {
- printf( "Found %d matches\n", foundlist.count );
-
- int j;
- for ( j = 0; j < foundlist.count; ++j )
- {
- printContact( conn, j, foundlist.data[j] );
- printVCard( conn, foundlist.data[j] );
- }
- dapi_freestringarr( foundlist );
- }
- else
- printf( "No matches in addressbook\n" );
- }
- else
- printf( "AddressBoolFindByName: call failed\n" );
- }
- }
-
- dapi_close( conn );
-
- return 0;
- }
-
-void printContact( DapiConnection* conn, int num, char* id )
- {
- char* givenname;
- char* familyname;
- char* fullname;
-
- if( dapi_AddressBookGetName( conn, id, &givenname, &familyname, &fullname ) )
- {
- printf( "Contact %d: '%s', %s', '%s'\n",
- num, givenname, familyname, fullname );
-
- free( givenname );
- free( familyname );
- free( fullname );
- }
- else
- printf( "AddressBookGetName: call failed\n" );
-
- stringarr emaillist;
- if( dapi_AddressBookGetEmails( conn, id, &emaillist ) )
- {
- if( emaillist.count > 0 )
- {
- int j;
- for( j = 0; j < emaillist.count; ++j )
- {
- printf( "\temail %d: '%s'\n", j, emaillist.data[j] );
- }
- dapi_freestringarr( emaillist );
- }
- else
- printf( "\tNo emails\n" );
- }
- else
- printf( "AddressBookGetEmails: call failed\n" );
- }
-
-void printVCard( DapiConnection* conn, char* id )
- {
- char* vcard;
- if( dapi_AddressBookGetVCard30( conn, id, &vcard ) )
- {
- printf("\n%s\n", vcard);
- free( vcard );
- }
- else
- printf( "AddressBookGetVCard30: call failed" );
- }
diff --git a/tests/test_async.c b/tests/test_async.c
deleted file mode 100644
index 8828eb9..0000000
--- a/tests/test_async.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <stdio.h>
-
-#include <dapi/comm.h>
-#include <dapi/calls.h>
-#include <dapi/callbacks.h>
-
-static int seq1;
-
-static void callback( DapiConnection* conn, int comm, int seq )
- {
- if( comm != DAPI_REPLY_BUTTONORDER
- || seq != seq1 )
- {
- fprintf( stderr, "Unexpected async reply, ignoring.\n" );
- }
- else
- {
- int ord;
- if( !dapi_readReplyButtonOrder( conn, &ord ))
- {
- fprintf( stderr, "Failed to read async reply!\n" );
- }
- else
- {
- printf( "Order async: %d (%s)\n", ord, ord == 0 ? "Failed" : ord == 1 ? "Ok/Cancel" : "Cancel/Ok" );
- }
- }
- }
-
-int main()
- {
- int ord;
- DapiConnection* conn = dapi_connect();
- if( conn == NULL )
- {
- fprintf( stderr, "Cannot connect!\n" );
- return 1;
- }
- dapi_setGenericCallback( conn, callback );
- if( !dapi_Init( conn ))
- {
- fprintf( stderr, "Initialization failed!\n" );
- return 2;
- }
- /* first write a command request without waiting for a reply, this
- means that the following blocking dapi_ButtonOrder() call will first need to process
- an async answer */
- seq1 = dapi_writeCommandButtonOrder( conn );
- ord = dapi_ButtonOrder( conn );
- printf( "Order: %d (%s)\n", ord, ord == 0 ? "Failed" : ord == 1 ? "Ok/Cancel" : "Cancel/Ok" );
- dapi_close( conn );
- return 0;
- }
diff --git a/tests/test_callbacks.c b/tests/test_callbacks.c
deleted file mode 100644
index 6f4cd40..0000000
--- a/tests/test_callbacks.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-
-#include <dapi/comm.h>
-#include <dapi/calls.h>
-#include <dapi/callbacks.h>
-
-static void callback( DapiConnection* conn, int seq, int ord )
- {
- printf( "Order async: %d %d (%s)\n", seq, ord, ord == 0 ? "Failed" : ord == 1 ? "Ok/Cancel" : "Cancel/Ok" );
- }
-
-int main()
- {
- int seq;
- DapiConnection* conn = dapi_connectAndInit();
- if( conn == NULL )
- {
- fprintf( stderr, "Cannot connect!\n" );
- return 1;
- }
- seq = dapi_callbackButtonOrder( conn, callback );
- printf( "Order call1: %d\n", seq );
- seq = dapi_callbackButtonOrder( conn, callback );
- printf( "Order call2: %d\n", seq );
- sleep( 1 ); /* give time to process */
- dapi_processData( conn );
- dapi_close( conn );
- return 0;
- }
diff --git a/tests/test_calls.c b/tests/test_calls.c
deleted file mode 100644
index b53fcd6..0000000
--- a/tests/test_calls.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <stdio.h>
-
-#include <dapi/comm.h>
-#include <dapi/calls.h>
-
-int main()
- {
- int ord;
- DapiConnection* conn = dapi_connectAndInit();
- if( conn == NULL )
- {
- fprintf( stderr, "Cannot connect!\n" );
- return 1;
- }
- ord = dapi_ButtonOrder( conn );
- printf( "Order: %d (%s)\n", ord, ord == 0 ? "Failed" : ord == 1 ? "Ok/Cancel" : "Cancel/Ok" );
- dapi_close( conn );
- return 0;
- }
diff --git a/tests/test_capabilities.c b/tests/test_capabilities.c
deleted file mode 100644
index 7d12955..0000000
--- a/tests/test_capabilities.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <dapi/comm.h>
-#include <dapi/calls.h>
-
-int main()
- {
- intarr capabilities;
- int i;
- DapiConnection* conn = dapi_connectAndInit();
- if( conn == NULL )
- {
- fprintf( stderr, "Cannot connect!\n" );
- return 1;
- }
- if( dapi_Capabilities( conn, &capabilities ))
- {
- int has_mailto = 0;
- printf( "Capabilities:" );
- for( i = 0;
- i < capabilities.count;
- ++i )
- {
- printf( " %d", capabilities.data[ i ] );
- if( capabilities.data[ i ] == DAPI_COMMAND_MAILTO )
- has_mailto = 1;
- }
- printf( "\nHas mailto: %d\n", has_mailto );
- }
- else
- fprintf( stderr, "Capabilities call failed!\n" );
- dapi_close( conn );
- return 0;
- }
diff --git a/tests/test_comm.c b/tests/test_comm.c
deleted file mode 100644
index 15fcab0..0000000
--- a/tests/test_comm.c
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <stdio.h>
-
-#include <dapi/comm.h>
-
-int main( int argc, char* argv[] )
- {
- int command, seq, seq2;
- int ok;
- DapiWindowInfo winfo;
- DapiConnection* conn = dapi_connect();
- if( conn == NULL )
- {
- fprintf( stderr, "Cannot connect!\n" );
- return 1;
- }
- seq = dapi_writeCommandInit( conn );
- if( !dapi_readCommand( conn, &command, &seq2 ) || seq != seq2 )
- {
- fprintf( stderr, "Incorrect init reply!\n" );
- return 2;
- }
- if( !dapi_readReplyInit( conn, &ok ))
- {
- fprintf( stderr, "Incorrect init reply data!\n" );
- return 2;
- }
- if( !ok )
- {
- fprintf( stderr, "Initialization failed!\n" );
- return 2;
- }
- dapi_windowInfoInitWindow( &winfo, 0 ); /* no mainwindow */
- seq = dapi_writeCommandOpenUrl( conn, "http://kde.org", winfo );
- if( !dapi_readCommand( conn, &command, &seq2 ) || seq != seq2 )
- {
- fprintf( stderr, "Incorrect open url reply!\n" );
- return 2;
- }
- dapi_freeWindowInfo( winfo );
- if( !dapi_readReplyOpenUrl( conn, &ok ))
- {
- fprintf( stderr, "Incorrect open url reply data!\n" );
- return 2;
- }
- printf( "Result: %s\n", ok ? "Ok" : "failed" );
- dapi_close( conn );
- return 0;
- }
diff --git a/tests/test_mailto.c b/tests/test_mailto.c
deleted file mode 100644
index 3c54e27..0000000
--- a/tests/test_mailto.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <dapi/comm.h>
-#include <dapi/calls.h>
-
-int main()
- {
- int ok;
- stringarr attachments;
- char* attachments_data[] = { "/tmp/mailtotest.txt" };
- DapiConnection* conn = dapi_connectAndInit();
- if( conn == NULL )
- {
- fprintf( stderr, "Cannot connect!\n" );
- return 1;
- }
- if(system( "touch /tmp/mailtotest.txt" ))
- return perror("system()"), 1;
- attachments.count = 1;
- attachments.data = attachments_data;
- ok = dapi_MailTo_Window( conn, "Test mail", "Hi,\n\nthis is a test mail.\n",
- "l.lunak@suse.cz, l.lunak@kde.org", NULL, "portland@lists.freedesktop.org", attachments,
- 0 ); /* no mainwindow */
- printf( "Result: %s\n", ok == 1 ? "Ok" : "Failed" );
- dapi_close( conn );
- return 0;
- }
diff --git a/tests/test_remotefile.c b/tests/test_remotefile.c
deleted file mode 100644
index 303e32b..0000000
--- a/tests/test_remotefile.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <dapi/comm.h>
-#include <dapi/calls.h>
-
-int main()
- {
- char* local;
- int ok;
- DapiConnection* conn = dapi_connectAndInit();
- if( conn == NULL )
- {
- fprintf( stderr, "Cannot connect!\n" );
- return 1;
- }
- local = dapi_LocalFile_Window( conn, "http://kde.org", "", 0, 0 ); /* no download, should fail */
- printf( "Local file1: %s - %s\n", local ? local : "?", local ? "Failed" : "Ok" );
- if( local )
- free( local );
- local = dapi_LocalFile_Window( conn, "http://kde.org", "", 1, 0 );
- printf( "Local file2: %s\n", local != NULL ? local : "Failed" );
- if( local != NULL )
- {
- ok = dapi_UploadFile_Window( conn, local, "http://kde.org", 0, 0 ); /* will fail */
- printf( "Upload2: %s\n", ok ? "Ok - ???" : "Failed - ok" );
- ok = dapi_RemoveTemporaryLocalFile( conn, local );
- printf( "Temporary2: %s\n", ok ? "Ok" : "Failed" );
- free( local );
- }
- if(system( "touch /tmp/remotefiletest.txt" ))
- return perror("system()"), 1;
- /* local temporary will be ignored */
- local = dapi_LocalFile_Window( conn, "file:///tmp/remotefiletest.txt", "/tmp/remotefiletest2.txt", 1, 0 );
- printf( "Local file3: %s\n", local != NULL ? local : "Failed" );
- if( local != NULL )
- {
- /* should be a no-op, as it's the same file */
- ok = dapi_UploadFile_Window( conn, local, "file:///tmp/remotefiletest.txt", 1, 0 );
- printf( "Upload3: %s\n", ok ? "Ok" : "Failed" );
- free( local );
- }
- dapi_close( conn );
- return 0;
- }
diff --git a/tests/test_runasuser.c b/tests/test_runasuser.c
deleted file mode 100644
index 5fe4f1a..0000000
--- a/tests/test_runasuser.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <stdio.h>
-
-#include <dapi/comm.h>
-#include <dapi/calls.h>
-
-int main()
- {
- int ok;
- DapiConnection* conn = dapi_connectAndInit();
- if( conn == NULL )
- {
- fprintf( stderr, "Cannot connect!\n" );
- return 1;
- }
- ok = dapi_RunAsUser_Window( conn, "", "xterm -title test", 0 ); /* no mainwindow */
- printf( "Result: %s\n", ok == 1 ? "Ok" : "Failed" );
- dapi_close( conn );
- return 0;
- }
diff --git a/tests/test_screensaving.c b/tests/test_screensaving.c
deleted file mode 100644
index 2224eeb..0000000
--- a/tests/test_screensaving.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-
-#include <dapi/comm.h>
-#include <dapi/calls.h>
-
-int main()
- {
- int ok;
- DapiConnection* conn = dapi_connectAndInit();
- if( conn == NULL )
- {
- fprintf( stderr, "Cannot connect!\n" );
- return 1;
- }
- ok = dapi_SuspendScreensaving( conn, 1 );
- printf( "Result1: %s\n", ok == 1 ? "Ok" : "Failed" );
- sleep( 10 );
- ok = dapi_SuspendScreensaving( conn, 0 );
- printf( "Result2: %s\n", ok == 1 ? "Ok" : "Failed" );
- dapi_close( conn );
- return 0;
- }