added BInputDevice test

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8806 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2004-09-02 21:40:01 +00:00
parent 88caa4a867
commit e07f3f03dc
2 changed files with 121 additions and 0 deletions

View File

@ -0,0 +1,18 @@
SubDir OBOS_TOP src tests servers input inputdevice ;
if $(COMPILE_FOR_R5) {
SubDirC++Flags -DCOMPILE_FOR_R5 ;
}
UsePrivateHeaders input ;
SimpleTest input_device_test :
main.cpp
Input.cpp
: be
;
SEARCH on [ FGristFiles Input.cpp ]
= [ FDirName $(OBOS_TOP) src kits interface ] ;

View File

@ -0,0 +1,103 @@
/*
** Copyright 2004, Jérôme Duval. All rights reserved.
**
** Distributed under the terms of the OpenBeOS License.
*/
#include <Input.h>
#include <List.h>
#include <string.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
BList list;
status_t err;
if ((err = get_input_devices(&list))!=B_OK)
printf("get_input_devices returned %s\n", strerror(err));
for (uint32 i=0; i<list.CountItems(); i++) {
BInputDevice *device = (BInputDevice*)list.ItemAt(i);
if (device == NULL) {
printf("device %ld is NULL\n", i);
continue;
}
printf("device %ld %s ", i, device->Name());
if (device->Type() == B_POINTING_DEVICE)
printf("B_POINTING_DEVICE\n");
if (device->Type() == B_KEYBOARD_DEVICE)
printf("B_KEYBOARD_DEVICE\n");
if (device->Type() == B_UNDEFINED_DEVICE)
printf("B_UNDEFINED_DEVICE\n");
device = find_input_device(device->Name());
if (device == NULL) {
printf("device %ld with find_input_device is NULL\n", i);
continue;
}
printf("device %ld with find_input_device %s ", i, device->Name());
if (device->Type() == B_POINTING_DEVICE)
printf("B_POINTING_DEVICE");
if (device->Type() == B_KEYBOARD_DEVICE)
printf("B_KEYBOARD_DEVICE");
if (device->Type() == B_UNDEFINED_DEVICE)
printf("B_UNDEFINED_DEVICE");
printf("\n");
printf(" %s", device->IsRunning() ? "true" : "false");
device->Stop();
printf(" %s", device->IsRunning() ? "true" : "false");
device->Start();
printf(" %s", device->IsRunning() ? "true" : "false");
device->Stop();
printf(" %s", device->IsRunning() ? "true" : "false");
device->Start();
printf(" %s", device->IsRunning() ? "true" : "false");
printf("\n");
}
if (find_input_device("blahha") != NULL )
printf("find_input_device(\"blahha\") not returned NULL\n");
else
printf("find_input_device(\"blahha\") returned NULL\n");
printf("\n");
BInputDevice::Start(B_POINTING_DEVICE);
for (uint32 i=0; i<list.CountItems(); i++) {
BInputDevice *device = (BInputDevice*)list.ItemAt(i);
printf(" %s", device->IsRunning() ? "true" : "false");
}
BInputDevice::Stop(B_POINTING_DEVICE);
for (uint32 i=0; i<list.CountItems(); i++) {
BInputDevice *device = (BInputDevice*)list.ItemAt(i);
printf(" %s", device->IsRunning() ? "true" : "false");
}
BInputDevice::Start(B_POINTING_DEVICE);
for (uint32 i=0; i<list.CountItems(); i++) {
BInputDevice *device = (BInputDevice*)list.ItemAt(i);
printf(" %s", device->IsRunning() ? "true" : "false");
}
BInputDevice::Stop(B_POINTING_DEVICE);
for (uint32 i=0; i<list.CountItems(); i++) {
BInputDevice *device = (BInputDevice*)list.ItemAt(i);
printf(" %s", device->IsRunning() ? "true" : "false");
}
BInputDevice::Start(B_POINTING_DEVICE);
for (uint32 i=0; i<list.CountItems(); i++) {
BInputDevice *device = (BInputDevice*)list.ItemAt(i);
printf(" %s", device->IsRunning() ? "true" : "false");
}
printf("\n");
return 0;
err:
return 0;
}