2019-03-27 02:50:09 +00:00
|
|
|
package mousemover
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2019-03-28 19:52:25 +00:00
|
|
|
"time"
|
2019-03-27 02:50:09 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2019-03-28 19:52:25 +00:00
|
|
|
"github.com/stretchr/testify/suite"
|
2019-03-27 02:50:09 +00:00
|
|
|
)
|
|
|
|
|
2019-03-28 19:52:25 +00:00
|
|
|
type TestMover struct {
|
|
|
|
suite.Suite
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSuite(t *testing.T) {
|
|
|
|
suite.Run(t, new(TestMover))
|
|
|
|
}
|
|
|
|
|
|
|
|
//Run once before each test
|
|
|
|
func (suite *TestMover) SetupTest() {
|
|
|
|
instance = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *TestMover) TestSingleton() {
|
|
|
|
t := suite.T()
|
|
|
|
mouseMover1 := GetInstance()
|
|
|
|
mouseMover1.Start()
|
|
|
|
|
|
|
|
time.Sleep(time.Millisecond * 500)
|
|
|
|
|
|
|
|
mouseMover2 := GetInstance()
|
|
|
|
assert.True(t, mouseMover2.isRunning(), "instance should not have started")
|
|
|
|
}
|
|
|
|
func (suite *TestMover) TestAppStartAndStop() {
|
|
|
|
t := suite.T()
|
|
|
|
mouseMover := GetInstance()
|
|
|
|
mouseMover.Start()
|
|
|
|
time.Sleep(time.Millisecond * 500) //wait for app to start
|
|
|
|
assert.True(t, mouseMover.isRunning(), "app should have started")
|
|
|
|
|
|
|
|
mouseMover.Quit()
|
|
|
|
time.Sleep(time.Millisecond * 500) //wait for app to stop
|
|
|
|
assert.False(t, mouseMover.isRunning(), "app should have stopped")
|
|
|
|
}
|