Minor changes to unit tests in attempt to fix issues with travis

This commit is contained in:
Kenneth Shaw 2017-06-18 09:32:12 +07:00
parent dba0e6c45a
commit fa3cf26d37
3 changed files with 27 additions and 25 deletions

View File

@ -28,7 +28,7 @@ func TestMouseClickXY(t *testing.T) {
c := testAllocate(t, "input.html") c := testAllocate(t, "input.html")
defer c.Release() defer c.Release()
err = c.Run(defaultContext, Sleep(time.Millisecond*100)) err = c.Run(defaultContext, Sleep(100*time.Millisecond))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -48,7 +48,7 @@ func TestMouseClickXY(t *testing.T) {
t.Fatalf("test %d got error: %v", i, err) t.Fatalf("test %d got error: %v", i, err)
} }
time.Sleep(time.Millisecond * 100) time.Sleep(50 * time.Millisecond)
var xstr, ystr string var xstr, ystr string
err = c.Run(defaultContext, Value("#input1", &xstr, ByID)) err = c.Run(defaultContext, Value("#input1", &xstr, ByID))
@ -113,7 +113,7 @@ func TestMouseClickNode(t *testing.T) {
t.Fatalf("got error: %v", err) t.Fatalf("got error: %v", err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var value string var value string
err = c.Run(defaultContext, Value("#input3", &value, ByID)) err = c.Run(defaultContext, Value("#input3", &value, ByID))
@ -171,7 +171,7 @@ func TestMouseClickOffscreenNode(t *testing.T) {
} }
} }
time.Sleep(time.Millisecond * 100) time.Sleep(100 * time.Millisecond)
var value int var value int
err = c.Run(defaultContext, Evaluate("window.document.test_i", &value)) err = c.Run(defaultContext, Evaluate("window.document.test_i", &value))

View File

@ -82,7 +82,7 @@ func TestNavigationEntries(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
err = c.Run(defaultContext, NavigationEntries(&index, &entries)) err = c.Run(defaultContext, NavigationEntries(&index, &entries))
if err != nil { if err != nil {
@ -116,7 +116,7 @@ func TestNavigateToHistoryEntry(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
err = c.Run(defaultContext, NavigationEntries(&index, &entries)) err = c.Run(defaultContext, NavigationEntries(&index, &entries))
if err != nil { if err != nil {
@ -128,14 +128,14 @@ func TestNavigateToHistoryEntry(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
err = c.Run(defaultContext, NavigateToHistoryEntry(entries[index].ID)) err = c.Run(defaultContext, NavigateToHistoryEntry(entries[index].ID))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var title string var title string
err = c.Run(defaultContext, Title(&title)) err = c.Run(defaultContext, Title(&title))
@ -160,7 +160,7 @@ func TestNavigateBack(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var exptitle string var exptitle string
err = c.Run(defaultContext, Title(&exptitle)) err = c.Run(defaultContext, Title(&exptitle))
@ -173,14 +173,14 @@ func TestNavigateBack(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
err = c.Run(defaultContext, NavigateBack()) err = c.Run(defaultContext, NavigateBack())
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var title string var title string
err = c.Run(defaultContext, Title(&title)) err = c.Run(defaultContext, Title(&title))
@ -205,14 +205,14 @@ func TestNavigateForward(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
err = c.Run(defaultContext, Navigate(testdataDir+"/"+"image.html")) err = c.Run(defaultContext, Navigate(testdataDir+"/"+"image.html"))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var exptitle string var exptitle string
err = c.Run(defaultContext, Title(&exptitle)) err = c.Run(defaultContext, Title(&exptitle))
@ -225,14 +225,14 @@ func TestNavigateForward(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
err = c.Run(defaultContext, NavigateForward()) err = c.Run(defaultContext, NavigateForward())
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var title string var title string
err = c.Run(defaultContext, Title(&title)) err = c.Run(defaultContext, Title(&title))
@ -276,7 +276,7 @@ func TestReload(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var exptitle string var exptitle string
err = c.Run(defaultContext, Title(&exptitle)) err = c.Run(defaultContext, Title(&exptitle))
@ -289,7 +289,7 @@ func TestReload(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var title string var title string
err = c.Run(defaultContext, Title(&title)) err = c.Run(defaultContext, Title(&title))
@ -314,7 +314,7 @@ func TestCaptureScreenshot(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var buf []byte var buf []byte
err = c.Run(defaultContext, CaptureScreenshot(&buf)) err = c.Run(defaultContext, CaptureScreenshot(&buf))
@ -347,7 +347,7 @@ func TestAddOnLoadScript(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
if scriptID == "" { if scriptID == "" {
t.Fatal("got empty script ID") t.Fatal("got empty script ID")
@ -383,7 +383,7 @@ func TestRemoveOnLoadScript(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
} }
func TestLocation(t *testing.T) { func TestLocation(t *testing.T) {
@ -400,7 +400,7 @@ func TestLocation(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var urlstr string var urlstr string
err = c.Run(defaultContext, Location(&urlstr)) err = c.Run(defaultContext, Location(&urlstr))
@ -427,7 +427,7 @@ func TestTitle(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var title string var title string
err = c.Run(defaultContext, Title(&title)) err = c.Run(defaultContext, Title(&title))

View File

@ -642,6 +642,8 @@ func TestDoubleClick(t *testing.T) {
t.Fatalf("got error: %v", err) t.Fatalf("got error: %v", err)
} }
time.Sleep(50 * time.Millisecond)
var value string var value string
err = c.Run(defaultContext, Value("#input1", &value, ByID)) err = c.Run(defaultContext, Value("#input1", &value, ByID))
if err != nil { if err != nil {
@ -782,7 +784,7 @@ func TestComputedStyle(t *testing.T) {
c := testAllocate(t, "js.html") c := testAllocate(t, "js.html")
defer c.Release() defer c.Release()
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var styles []*css.ComputedProperty var styles []*css.ComputedProperty
err := c.Run(defaultContext, ComputedStyle(test.sel, &styles, test.by)) err := c.Run(defaultContext, ComputedStyle(test.sel, &styles, test.by))
@ -803,7 +805,7 @@ func TestComputedStyle(t *testing.T) {
t.Fatalf("got error: %v", err) t.Fatalf("got error: %v", err)
} }
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
err = c.Run(defaultContext, ComputedStyle(test.sel, &styles, test.by)) err = c.Run(defaultContext, ComputedStyle(test.sel, &styles, test.by))
if err != nil { if err != nil {
@ -839,7 +841,7 @@ func TestMatchedStyle(t *testing.T) {
c := testAllocate(t, "js.html") c := testAllocate(t, "js.html")
defer c.Release() defer c.Release()
time.Sleep(time.Millisecond * 50) time.Sleep(50 * time.Millisecond)
var styles *css.GetMatchedStylesForNodeReturns var styles *css.GetMatchedStylesForNodeReturns
err := c.Run(defaultContext, MatchedStyle(test.sel, &styles, test.by)) err := c.Run(defaultContext, MatchedStyle(test.sel, &styles, test.by))