From 9ddbcfd3839d3c3ab235d75013a923389831a493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 25 Nov 2009 21:58:20 +0000 Subject: [PATCH] Small test app for testing the shutdown process. I didn't search long if something like this already exists... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34263 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/apps/Jamfile | 1 + .../apps/delay_shutdown/DelayShutdown.cpp | 79 +++++++++++++++++++ .../apps/delay_shutdown/DelayShutdown.rdef | 3 + src/tests/apps/delay_shutdown/Jamfile | 6 ++ 4 files changed, 89 insertions(+) create mode 100644 src/tests/apps/delay_shutdown/DelayShutdown.cpp create mode 100644 src/tests/apps/delay_shutdown/DelayShutdown.rdef create mode 100644 src/tests/apps/delay_shutdown/Jamfile diff --git a/src/tests/apps/Jamfile b/src/tests/apps/Jamfile index 65d8f0d62b..35b936da9c 100644 --- a/src/tests/apps/Jamfile +++ b/src/tests/apps/Jamfile @@ -1,5 +1,6 @@ SubDir HAIKU_TOP src tests apps ; +SubInclude HAIKU_TOP src tests apps delay_shutdown ; SubInclude HAIKU_TOP src tests apps fake_app_server ; SubInclude HAIKU_TOP src tests apps installer ; SubInclude HAIKU_TOP src tests apps miniterminal ; diff --git a/src/tests/apps/delay_shutdown/DelayShutdown.cpp b/src/tests/apps/delay_shutdown/DelayShutdown.cpp new file mode 100644 index 0000000000..15f828fa97 --- /dev/null +++ b/src/tests/apps/delay_shutdown/DelayShutdown.cpp @@ -0,0 +1,79 @@ +/* + * Copyright 2009, Stephan Aßmus + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include +#include +#include + +#include + + +class DelayShutdownApp : public BApplication { +public: + DelayShutdownApp() + : + BApplication("application/x-vnd.Haiku-DelayShutdown"), + fDelay(5LL), + fQuit(false) + { + } + + virtual void ArgvReceived(int32 argc, char* argv[]) + { + if (argc <= 1) { + _PrintUsageAndQuit(); + return; + } + + int32 index = 1; + + while (index < argc) { + if (strcmp(argv[index], "-d") == 0) { + if (index + 1 < argc) + fDelay = atoi(argv[++index]); + else { + _PrintUsageAndQuit(); + return; + } + } else if (strcmp(argv[index], "-q") == 0) { + fQuit = true; + } else { + _PrintUsageAndQuit(); + return; + } + index++; + } + } + + virtual bool QuitRequested() + { + snooze(fDelay * 1000000); + return fQuit; + } + +private: + void _PrintUsageAndQuit() + { + printf("usage:\n" + "\t-d - wait x seconds before replying the quit\n" + "\t request.\n" + "\t-q - respond positively to the quit request\n" + "\t (default: don't quit).\n"); + PostMessage(B_QUIT_REQUESTED); + } + + bigtime_t fDelay; + bool fQuit; +}; + + +int +main(int argc, char* argv[]) +{ + DelayShutdownApp app; + app.Run(); + + return 0; +} diff --git a/src/tests/apps/delay_shutdown/DelayShutdown.rdef b/src/tests/apps/delay_shutdown/DelayShutdown.rdef new file mode 100644 index 0000000000..df80e736b4 --- /dev/null +++ b/src/tests/apps/delay_shutdown/DelayShutdown.rdef @@ -0,0 +1,3 @@ +resource app_signature "application/x-vnd.Haiku-DelayShutdown"; + +resource app_flags B_SINGLE_LAUNCH; diff --git a/src/tests/apps/delay_shutdown/Jamfile b/src/tests/apps/delay_shutdown/Jamfile new file mode 100644 index 0000000000..366245aa28 --- /dev/null +++ b/src/tests/apps/delay_shutdown/Jamfile @@ -0,0 +1,6 @@ +SubDir HAIKU_TOP src tests apps delay_shutdown ; + +Application DelayShutdown : + DelayShutdown.cpp + : be + ;