9c9576b5b9
ci / test (macos-latest) (push) Has been cancelled
ci / test (ubuntu-latest) (push) Has been cancelled
ci / lint (push) Has been cancelled
ci / govulncheck (push) Has been cancelled
ci / tidy (push) Has been cancelled
ci / webview (push) Has been cancelled
ci / windows-gui (push) Has been cancelled
release / check (push) Has been cancelled
release / release (push) Has been cancelled
Docs / build (push) Has been cancelled
Docs / deploy-pages (push) Has been cancelled
Docs / deploy-cloudflare (push) Has been cancelled
38 lines
845 B
Go
38 lines
845 B
Go
//go:build !webview
|
|
|
|
package viewer
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestNativeIsFalseInDefaultBuild(t *testing.T) {
|
|
if Native {
|
|
t.Fatal("Native should be false without the webview build tag")
|
|
}
|
|
}
|
|
|
|
func TestLockMainThreadIsNoop(t *testing.T) {
|
|
// Must not panic; there is no native UI to pin to.
|
|
LockMainThread()
|
|
}
|
|
|
|
func TestShowReturnsWhenContextCancelled(t *testing.T) {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
done := make(chan error, 1)
|
|
// Browser:false so no system browser is launched during the test.
|
|
go func() { done <- Show(ctx, Options{URL: "http://127.0.0.1:0", Browser: false}) }()
|
|
|
|
cancel()
|
|
select {
|
|
case err := <-done:
|
|
if err != nil {
|
|
t.Fatalf("Show returned error: %v", err)
|
|
}
|
|
case <-time.After(2 * time.Second):
|
|
t.Fatal("Show did not return after context cancellation")
|
|
}
|
|
}
|