tags:

views:

81

answers:

3

I'm trying to do some testing and it requires the Windows system to be up and running for 15 Real-Time minutes before a certain action can ever occur. However, this is very time consuming to HAVE to wait the 15 real-time minutes.

Is there a way to change the value GetTickCount() returns so as to make it appear that the system has been running for 15 real-time minutes?

Edit: There is an app that does something close to what I want, but it doesn't quite seem to work and I have to deal with hexadecimal values instead of straight decimal values: http://ysgyfarnog.co.uk/utilities/AdjustTickCount/

+4  A: 

Not directly.

Why not just mock the call, or replace the chunk of code that does the time check with a strategy object?

struct Waiter
{
    virtual void Wait() = 0;
    virtual ~Waiter() {};
};

struct 15MinWaiter : public Waiter
{
    virtual void Wait()
    {
        //Do something that waits for 15 mins
    }
};

struct NothingWaiter : public Waiter
{
    virtual void Wait()
    {
        //Nill
    } 
};

You could do similar to mock out a call to GetTickCount, but doing this at the higher level of abstraction of whatever is doing the wait is probably better.

Billy ONeal
Yeah ... that would be ideal. However, I'm not the developer and don't have access to change the code. I was hoping to do this externally. I guess I could try to make a case for the developer to make this adjustable so during testing I can choose to not wait.
Brian T Hannan
Have you tried simply setting the time ahead on the test machine after starting the app? I don't know if this affects the value returned by GetTickCount() but it would be easy to test.
Blastfurnace
No, the system clock has nothing to do with GetTickCount() unfortunately ... it just stores a value for the number of milliseconds since the system started and increments it as time goes by. Thanks for the suggestion though.
Brian T Hannan
+2  A: 

For debugging purposes, you can just replace all the calls to GetTickCount() with _GetTickCount(), which can implement to return with GetTickCount() or GetTickCount()+15min, depending whether or not you are debugging.

Why not make it one minute, confirm it works, then change it back to fifteen?

Alexander Rafferty
A: 

You could do something quite hideous like #define GetTickCount() MyReallyEvilReplacement().

DeadMG