mirror of
https://github.com/prashantgupta24/automatic-mouse-mover.git
synced 2024-12-22 08:24:11 +00:00
added machine wake test
This commit is contained in:
parent
642e2f3924
commit
90d53f3e4c
@ -57,7 +57,7 @@ func (suite *TestMover) TestSingleton() {
|
|||||||
assert.True(t, mouseMover2.state.isRunning(), "instance should have started")
|
assert.True(t, mouseMover2.state.isRunning(), "instance should have started")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *TestMover) TestSystemSleep() {
|
func (suite *TestMover) TestSystemSleepAndWake() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
mouseMover := GetInstance()
|
mouseMover := GetInstance()
|
||||||
|
|
||||||
@ -69,15 +69,28 @@ func (suite *TestMover) TestSystemSleep() {
|
|||||||
|
|
||||||
//fake a machine-sleep activity
|
//fake a machine-sleep activity
|
||||||
machineSleepActivityMap := make(map[activity.Type][]time.Time)
|
machineSleepActivityMap := make(map[activity.Type][]time.Time)
|
||||||
var timeArray []time.Time
|
var sleepTimeArray []time.Time
|
||||||
timeArray = append(timeArray, time.Now())
|
sleepTimeArray = append(sleepTimeArray, time.Now())
|
||||||
machineSleepActivityMap[activity.MachineSleep] = timeArray
|
machineSleepActivityMap[activity.MachineSleep] = sleepTimeArray
|
||||||
heartbeatCh <- &tracker.Heartbeat{
|
heartbeatCh <- &tracker.Heartbeat{
|
||||||
WasAnyActivity: true,
|
WasAnyActivity: true,
|
||||||
ActivityMap: machineSleepActivityMap,
|
ActivityMap: machineSleepActivityMap,
|
||||||
}
|
}
|
||||||
time.Sleep(time.Millisecond * 500) //wait for it to be registered
|
time.Sleep(time.Millisecond * 500) //wait for it to be registered
|
||||||
assert.True(t, mouseMover.state.isSystemSleeping(), "machine should be sleeping now")
|
assert.True(t, mouseMover.state.isSystemSleeping(), "machine should be sleeping now")
|
||||||
|
|
||||||
|
//fake a machine-wake activity
|
||||||
|
machineWakeActivityMap := make(map[activity.Type][]time.Time)
|
||||||
|
var wakeTimeArray []time.Time
|
||||||
|
wakeTimeArray = append(wakeTimeArray, time.Now())
|
||||||
|
machineWakeActivityMap[activity.MachineWake] = wakeTimeArray
|
||||||
|
heartbeatCh <- &tracker.Heartbeat{
|
||||||
|
WasAnyActivity: true,
|
||||||
|
ActivityMap: machineWakeActivityMap,
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(time.Millisecond * 500) //wait for it to be registered
|
||||||
|
assert.False(t, mouseMover.state.isSystemSleeping(), "machine should be awake now")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *TestMover) TestMouseMoveSuccess() {
|
func (suite *TestMover) TestMouseMoveSuccess() {
|
||||||
|
Loading…
Reference in New Issue
Block a user