From e07f3f03dc04998f22c177759491f3fac2303041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Thu, 2 Sep 2004 21:40:01 +0000 Subject: [PATCH] added BInputDevice test git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8806 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/servers/input/inputdevice/Jamfile | 18 ++++ src/tests/servers/input/inputdevice/main.cpp | 103 +++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 src/tests/servers/input/inputdevice/Jamfile create mode 100644 src/tests/servers/input/inputdevice/main.cpp diff --git a/src/tests/servers/input/inputdevice/Jamfile b/src/tests/servers/input/inputdevice/Jamfile new file mode 100644 index 0000000000..53a185ce6e --- /dev/null +++ b/src/tests/servers/input/inputdevice/Jamfile @@ -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 ] ; diff --git a/src/tests/servers/input/inputdevice/main.cpp b/src/tests/servers/input/inputdevice/main.cpp new file mode 100644 index 0000000000..6bc2c65c76 --- /dev/null +++ b/src/tests/servers/input/inputdevice/main.cpp @@ -0,0 +1,103 @@ +/* +** Copyright 2004, Jérôme Duval. All rights reserved. +** +** Distributed under the terms of the OpenBeOS License. +*/ + +#include +#include + +#include +#include + +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; iName()); + 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; iIsRunning() ? "true" : "false"); + } + BInputDevice::Stop(B_POINTING_DEVICE); + for (uint32 i=0; iIsRunning() ? "true" : "false"); + } + BInputDevice::Start(B_POINTING_DEVICE); + for (uint32 i=0; iIsRunning() ? "true" : "false"); + } + BInputDevice::Stop(B_POINTING_DEVICE); + for (uint32 i=0; iIsRunning() ? "true" : "false"); + } + BInputDevice::Start(B_POINTING_DEVICE); + for (uint32 i=0; iIsRunning() ? "true" : "false"); + } + printf("\n"); + return 0; +err: + + return 0; +} +