Sfoglia il codice sorgente

新增字幕校正时间轴测试用例

Signed-off-by: allan716 <[email protected]>
allan716 3 anni fa
parent
commit
78cde34c4f

+ 31 - 28
internal/logic/sub_timeline_fixer/SubTimelineFixerHelperEx_test.go

@@ -1,6 +1,9 @@
 package sub_timeline_fixer
 
 import (
+	"github.com/allanpk716/ChineseSubFinder/internal/pkg/settings"
+	"github.com/allanpk716/ChineseSubFinder/internal/pkg/unit_test_helper"
+	"path/filepath"
 	"testing"
 )
 
@@ -15,32 +18,32 @@ func TestSubTimelineFixerHelperEx_Check(t *testing.T) {
 // TODO 暂不方便在其他环境进行单元测试
 func TestSubTimelineFixerHelperEx_Process(t *testing.T) {
 
-	//rootDir := unit_test_helper.GetTestDataResourceRootPath([]string{"sub_timeline_fixer"}, 4, true)
-	//type args struct {
-	//	videoFileFullPath string
-	//	srcSubFPath       string
-	//}
-	//tests := []struct {
-	//	name    string
-	//	args    args
-	//	wantErr bool
-	//}{
-	//	{
-	//		name: "Foundation (2021) - S01E09", args: args{
-	//			videoFileFullPath: "X:\\连续剧\\Foundation (2021)\\Season 1\\Foundation (2021) - S01E09 - The First Crisis WEBDL-1080p.mkv",
-	//			srcSubFPath:       filepath.Join(rootDir, "series", "Foundation (2021)", "Season 1", "Foundation (2021) - S01E09 - The First Crisis WEBDL-1080p.chinese(简英,zimuku).ass")},
-	//		wantErr: false,
-	//	},
-	//}
-	//
-	//s := NewSubTimelineFixerHelperEx(config.GetConfig().SubTimelineFixerConfig)
-	//s.Check()
-	//for _, tt := range tests {
-	//	t.Run(tt.name, func(t *testing.T) {
-	//
-	//		if err := s.Process(tt.args.videoFileFullPath, tt.args.srcSubFPath); (err != nil) != tt.wantErr {
-	//			t.Errorf("Process() error = %v, wantErr %v", err, tt.wantErr)
-	//		}
-	//	})
-	//}
+	rootDir := unit_test_helper.GetTestDataResourceRootPath([]string{"sub_timeline_fixer"}, 4, true)
+	type args struct {
+		videoFileFullPath string
+		srcSubFPath       string
+	}
+	tests := []struct {
+		name    string
+		args    args
+		wantErr bool
+	}{
+		{
+			name: "Foundation (2021) - S01E09", args: args{
+				videoFileFullPath: "X:\\连续剧\\Foundation (2021)\\Season 1\\Foundation (2021) - S01E09 - The First Crisis WEBDL-1080p.mkv",
+				srcSubFPath:       filepath.Join(rootDir, "series", "Foundation (2021)", "Season 1", "Foundation (2021) - S01E09 - The First Crisis WEBDL-1080p.chinese(简英,zimuku).ass")},
+			wantErr: false,
+		},
+	}
+
+	s := NewSubTimelineFixerHelperEx(*settings.NewTimelineFixerSettings())
+	s.Check()
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+
+			if err := s.Process(tt.args.videoFileFullPath, tt.args.srcSubFPath); (err != nil) != tt.wantErr {
+				t.Errorf("Process() error = %v, wantErr %v", err, tt.wantErr)
+			}
+		})
+	}
 }

+ 10 - 0
internal/pkg/sub_timeline_fixer/pipeline_test.go

@@ -156,6 +156,16 @@ func TestPipeline_FitGSSByAudio(t *testing.T) {
 				srcFixedSubFile: filepath.Join(dirRoot, "Rick and Morty - S05E01", "org-fix.ass")},
 			want: true, want1: -6.1,
 		},
+		// Bulgasal.Immortal.Souls.S01E15
+		{name: "Bulgasal.Immortal.Souls.S01E15",
+			args: args{
+				audioInfo: vad.AudioInfo{
+					FileFullPath: filepath.Join(dirRoot, "Bulgasal.Immortal.Souls.S01E15", "audio.pcm"),
+				},
+				subFilePath:     filepath.Join(dirRoot, "Bulgasal.Immortal.Souls.S01E15", "subs.chinese.srt"),
+				srcFixedSubFile: filepath.Join(dirRoot, "Bulgasal.Immortal.Souls.S01E15", "org-fix.srt")},
+			want: true, want1: 0.01,
+		},
 	}
 
 	for _, tt := range tests {

+ 1 - 1
internal/pkg/sub_timeline_fixer/restore_test.go

@@ -22,7 +22,7 @@ func TestRestore(t *testing.T) {
 	rootDir := unit_test_helper.GetTestDataResourceRootPath([]string{"sub_timeline_fixer"}, 4, true)
 	movieDir := filepath.Join(rootDir, "movies")
 	seriesDir := filepath.Join(rootDir, "series")
-	count, err := Restore(movieDir, seriesDir)
+	count, err := Restore([]string{movieDir}, []string{seriesDir})
 	if err != nil {
 		t.Fatal(err)
 	}