mirror of
https://github.com/black-ant/Ant-Browser.git
synced 2026-07-14 18:48:55 +08:00
publish: 1.1.0 snapshot (a358335)
channel: master version: 1.1.0 source-ref: master published-at-utc: 2026-03-29T11:32:04Z
This commit is contained in:
@@ -47,7 +47,60 @@ func TestDescribeChromeProcessStartError(t *testing.T) {
|
||||
|
||||
func TestDescribeBrowserReadyTimeout(t *testing.T) {
|
||||
got := describeBrowserReadyTimeout(9222, 10*time.Second)
|
||||
if !strings.Contains(got, "调试端口 9222 未开启") {
|
||||
if !strings.Contains(got, "调试端口 9222 未就绪") {
|
||||
t.Fatalf("unexpected timeout message: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDescribeBrowserReadyTimeoutWithoutPort(t *testing.T) {
|
||||
got := describeBrowserReadyTimeout(0, 10*time.Second)
|
||||
if !strings.Contains(got, "未获取到调试端口") {
|
||||
t.Fatalf("unexpected timeout message: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDescribeBrowserReadyFailureUsesExitDetail(t *testing.T) {
|
||||
err := &browserStartupExitError{
|
||||
exitErr: fmt.Errorf("exit status 5"),
|
||||
stderrTail: "sandbox initialization failed",
|
||||
}
|
||||
|
||||
got := describeBrowserReadyFailure(`C:\chrome.exe`, 9222, 10*time.Second, err)
|
||||
if !strings.Contains(got, "sandbox initialization failed") {
|
||||
t.Fatalf("expected exit detail in message, got %q", got)
|
||||
}
|
||||
if strings.Contains(got, "调试端口 9222 未就绪") {
|
||||
t.Fatalf("expected exit detail message instead of timeout, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBrowserStartAttemptCountDefault(t *testing.T) {
|
||||
if browserStartAttemptCount() != 5 {
|
||||
t.Fatalf("expected default browser start attempts to be 5, got %d", browserStartAttemptCount())
|
||||
}
|
||||
}
|
||||
|
||||
func TestBrowserDebugPendingMessages(t *testing.T) {
|
||||
warning := browserDebugPendingWarning(15 * time.Second)
|
||||
if !strings.Contains(warning, "15 秒") || !strings.Contains(warning, "继续在后台连接") {
|
||||
t.Fatalf("unexpected pending warning: %q", warning)
|
||||
}
|
||||
|
||||
notice := browserDebugPendingStartNotice(15 * time.Second)
|
||||
if !strings.Contains(notice, "尚未完成接管") || !strings.Contains(notice, "稍后查看实例状态") {
|
||||
t.Fatalf("unexpected pending start notice: %q", notice)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldRetryBrowserReadyFailure(t *testing.T) {
|
||||
if !shouldRetryBrowserReadyFailure(fmt.Errorf("browser debug port 9222 not ready")) {
|
||||
t.Fatal("expected timeout-like ready failure to be retryable")
|
||||
}
|
||||
|
||||
if shouldRetryBrowserReadyFailure(&browserStartupExitError{
|
||||
exitErr: fmt.Errorf("exit status 5"),
|
||||
stderrTail: "missing libEGL.dll",
|
||||
}) {
|
||||
t.Fatal("expected process exit before ready to stop retrying")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user