Merge branch 'master' into session_refactor

This commit is contained in:
余泓铮
2025-08-15 11:21:52 +08:00
68 changed files with 2027 additions and 1531 deletions

View File

@@ -7,13 +7,14 @@ import (
"fmt"
"path/filepath"
"github.com/rs/zerolog/log"
hrp "github.com/httprunner/httprunner/v5"
"github.com/httprunner/httprunner/v5/code"
"github.com/httprunner/httprunner/v5/internal/builtin"
"github.com/httprunner/httprunner/v5/internal/config"
"github.com/httprunner/httprunner/v5/uixt"
"github.com/httprunner/httprunner/v5/uixt/option"
"github.com/rs/zerolog/log"
)
// GameElement represents a game element detected in the interface
@@ -34,6 +35,15 @@ type Dimensions struct {
type Element struct {
Type string `json:"type"` // Element type/name
Position Position `json:"position"` // Position in grid
BoundBox BoundBox `json:"boundBox"` // Bounding box coordinates
}
// BoundBox represents bounding box coordinates
type BoundBox struct {
X float64 `json:"x"` // X coordinate
Y float64 `json:"y"` // Y coordinate
Width float64 `json:"width"` // Box width
Height float64 `json:"height"` // Box height
}
// Position represents grid position

View File

@@ -1,10 +1,11 @@
//go:build localtest
package llk
import (
"context"
"encoding/json"
"fmt"
"os"
"testing"
"github.com/stretchr/testify/assert"
@@ -97,19 +98,6 @@ func convertToGameElementFromQueryResult(result *ai.QueryResult) (*GameElement,
return &gameElement, nil
}
// hasRequiredEnvVars checks if the required environment variables are set for testing
func hasRequiredEnvVars() bool {
// Check for OpenAI environment variables
if os.Getenv("OPENAI_BASE_URL") != "" && os.Getenv("OPENAI_API_KEY") != "" {
return true
}
// Check for GPT-4O specific environment variables
if os.Getenv("OPENAI_GPT_4O_BASE_URL") != "" && os.Getenv("OPENAI_GPT_4O_API_KEY") != "" {
return true
}
return false
}
// loadTestImage loads the test image from testdata
func loadTestImage(t *testing.T) (string, types.Size) {
screenshot, size, err := builtin.LoadImage("../../../uixt/ai/testdata/llk_1.png")
@@ -129,10 +117,6 @@ func createAIQueryer(t *testing.T) *ai.Querier {
// TestLLKGameBot_AnalyzeGameInterface comprehensive test for game interface analysis
func TestLLKGameBot_AnalyzeGameInterface(t *testing.T) {
if !hasRequiredEnvVars() {
t.Skip("Skipping test: required environment variables not set")
}
t.Run("AnalyzeWithTestImage", func(t *testing.T) {
// Create test bot and load test image
querier := createAIQueryer(t)

View File

@@ -1,3 +1,5 @@
//go:build localtest
package llk
import (
@@ -7,10 +9,11 @@ import (
"os"
"testing"
"github.com/httprunner/httprunner/v5/uixt/ai"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/httprunner/httprunner/v5/uixt/ai"
)
// TestLLKSolver tests the LianLianKan solver functionality