added BInputDevice test
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8806 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
88caa4a867
commit
e07f3f03dc
18
src/tests/servers/input/inputdevice/Jamfile
Normal file
18
src/tests/servers/input/inputdevice/Jamfile
Normal 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 ] ;
|
103
src/tests/servers/input/inputdevice/main.cpp
Normal file
103
src/tests/servers/input/inputdevice/main.cpp
Normal 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user