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
This commit is contained in:
parent
41975f20f0
commit
9ddbcfd383
@ -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 ;
|
||||
|
79
src/tests/apps/delay_shutdown/DelayShutdown.cpp
Normal file
79
src/tests/apps/delay_shutdown/DelayShutdown.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2009, Stephan Aßmus <superstippi@gmx.de>
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <Application.h>
|
||||
|
||||
|
||||
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 <x> - 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;
|
||||
}
|
3
src/tests/apps/delay_shutdown/DelayShutdown.rdef
Normal file
3
src/tests/apps/delay_shutdown/DelayShutdown.rdef
Normal file
@ -0,0 +1,3 @@
|
||||
resource app_signature "application/x-vnd.Haiku-DelayShutdown";
|
||||
|
||||
resource app_flags B_SINGLE_LAUNCH;
|
6
src/tests/apps/delay_shutdown/Jamfile
Normal file
6
src/tests/apps/delay_shutdown/Jamfile
Normal file
@ -0,0 +1,6 @@
|
||||
SubDir HAIKU_TOP src tests apps delay_shutdown ;
|
||||
|
||||
Application DelayShutdown :
|
||||
DelayShutdown.cpp
|
||||
: be
|
||||
;
|
Loading…
x
Reference in New Issue
Block a user