Repository navigation
Expand file tree
/
Copy pathtest.ps1
More file actions
72 lines (69 loc) · 5.51 KB
/
Copy pathtest.ps1
File metadata and controls
72 lines (69 loc) · 5.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# 使用与 build.ps1 相同的 JDK / jadx Gson,测试不连接手机,不触发真实设备操作或认证。
param([switch]$SkipBuild)
$ErrorActionPreference = "Stop"
$projectRoot = $PSScriptRoot
$classesPath = Join-Path $projectRoot 'build\out\classes'
$testPath = Join-Path $projectRoot 'build\out\tests'
$jdkPath = 'D:\Environment\java\bin'
$jadxPath = 'D:\Environment\jadx\lib\jadx-1.5.6-all.jar'
if (-not $SkipBuild) {
$checkedOutput = [IO.Path]::GetFullPath((Join-Path $projectRoot 'build\out'))
if (-not $checkedOutput.StartsWith([IO.Path]::GetFullPath($projectRoot) + [IO.Path]::DirectorySeparatorChar)) {
throw '构建输出目录不在工作区内'
}
& (Join-Path $projectRoot 'build.ps1')
}
if (-not (Test-Path -LiteralPath $classesPath)) { throw '请先运行 build.ps1' }
New-Item -ItemType Directory -Path $testPath -Force | Out-Null
$testClasspath = "$classesPath;$projectRoot\build\out\stubs;$projectRoot\build\libs\android-4.1.1.4.jar;$jadxPath"
$testSources = Get-ChildItem -LiteralPath (Join-Path $projectRoot 'tests') -Filter '*.java' | ForEach-Object FullName
& "$jdkPath\javac.exe" --release 11 -encoding UTF-8 -cp $testClasspath -d $testPath $testSources
if ($LASTEXITCODE -ne 0) { throw '测试编译失败' }
& "$jdkPath\java.exe" -cp "$testPath;$testClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.inject.DeviceActionTest
if ($LASTEXITCODE -ne 0) { throw '设备操作回归测试失败' }
& "$jdkPath\java.exe" -cp "$testPath;$testClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.inject.SmsMessageTest
if ($LASTEXITCODE -ne 0) { throw '短信位置回归测试失败' }
& "$jdkPath\java.exe" -cp "$testPath;$testClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.inject.SmsSentHistoryTest
if ($LASTEXITCODE -ne 0) { throw '短信发送记录回归测试失败' }
& "$jdkPath\java.exe" -cp "$testPath;$testClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.inject.MmsPduTest
if ($LASTEXITCODE -ne 0) { throw '彩信协议回归测试失败' }
& "$jdkPath\java.exe" -cp "$testPath;$testClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.inject.EmailConfigTest
if ($LASTEXITCODE -ne 0) { throw '邮件配置回归测试失败' }
& "$jdkPath\java.exe" -cp "$testPath;$testClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.inject.SmtpClientTest
if ($LASTEXITCODE -ne 0) { throw '邮件协议回归测试失败' }
& "$jdkPath\java.exe" -cp "$testPath;$testClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.inject.UnlockFailureTest
if ($LASTEXITCODE -ne 0) { throw '解锁失败条件回归测试失败' }
& "$jdkPath\java.exe" -cp "$testPath;$testClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.inject.AppUsageConditionTest
if ($LASTEXITCODE -ne 0) { throw '应用使用时长条件回归测试失败' }
# 运行时测试需要可用的 android.util.Log / android.text.TextUtils,用替身覆盖 android.jar 的桩。
$shadowPath = Join-Path $testPath 'shadows'
New-Item -ItemType Directory -Path $shadowPath -Force | Out-Null
$shadowSources = Get-ChildItem -LiteralPath (Join-Path $projectRoot 'tests\shadows') -Recurse -Filter '*.java' | ForEach-Object FullName
& "$jdkPath\javac.exe" --release 11 -encoding UTF-8 -cp $testClasspath -d $shadowPath $shadowSources
if ($LASTEXITCODE -ne 0) { throw '运行时测试替身编译失败' }
& "$jdkPath\java.exe" -cp "$shadowPath;$testPath;$testClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.inject.AppUsageRuntimeTest
if ($LASTEXITCODE -ne 0) { throw '应用使用时长运行时回归测试失败' }
& "$jdkPath\java.exe" -cp "$testPath;$testClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.inject.ActionChainTest
if ($LASTEXITCODE -ne 0) { throw '动作链回归测试失败' }
& "$jdkPath\java.exe" -cp "$testPath;$testClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.inject.ThenExecutionTest
if ($LASTEXITCODE -ne 0) { throw '再执行回归测试失败' }
# UI 树测试使用独立的 Xposed 反射替身,不加入业务测试或 APK 的 classpath。
$uiTestPath = Join-Path $testPath 'ui'
New-Item -ItemType Directory -Path $uiTestPath -Force | Out-Null
$uiClasspath = "$testClasspath;$projectRoot\build\libs\xposed-api-82.jar"
$uiSources = Get-ChildItem -LiteralPath (Join-Path $projectRoot 'tests\ui') -Filter '*.java' | ForEach-Object FullName
& "$jdkPath\javac.exe" --release 11 -encoding UTF-8 -cp $uiClasspath -d $uiTestPath $uiSources
if ($LASTEXITCODE -ne 0) { throw '标题卡片测试编译失败' }
& "$jdkPath\java.exe" -cp "$uiTestPath;$uiClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.TaskSectionCardTest
if ($LASTEXITCODE -ne 0) { throw '标题卡片回归测试失败' }
# 时间条件测试隔离宿主 TaskItem / CustomTimeConditionItem,验证真实策略代码及序列化。
$timeTestPath = Join-Path $testPath 'time'
New-Item -ItemType Directory -Path $timeTestPath -Force | Out-Null
$timeSources = @(Get-ChildItem -LiteralPath (Join-Path $projectRoot 'tests\time') -Filter '*.java' | ForEach-Object FullName)
$timeSources += Join-Path $projectRoot 'tests\ui\XposedHelpers.java'
& "$jdkPath\javac.exe" --release 11 -encoding UTF-8 -cp $uiClasspath -d $timeTestPath $timeSources
if ($LASTEXITCODE -ne 0) { throw '时间退出测试编译失败' }
& "$jdkPath\java.exe" -cp "$timeTestPath;$testClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.inject.TimeExitTest
if ($LASTEXITCODE -ne 0) { throw '时间退出回归测试失败' }
& "$jdkPath\java.exe" -cp "$timeTestPath;$uiClasspath" io.github.codecodegogogo.HyperosAutoTaskPlus.TimeExitEngineTest
if ($LASTEXITCODE -ne 0) { throw '时间退出引擎回归测试失败' }