Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_39073359
jadx
提交
46b5725d
J
jadx
项目概览
qq_39073359
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
46b5725d
编写于
1月 10, 2022
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(test): replace inputs with test profiles
上级
72542fa6
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
78 addition
and
58 deletion
+78
-58
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
+1
-1
jadx-core/src/test/java/jadx/tests/api/extensions/inputs/InputPlugin.java
...st/java/jadx/tests/api/extensions/inputs/InputPlugin.java
+0
-20
jadx-core/src/test/java/jadx/tests/api/extensions/profiles/JadxTestProfilesExtension.java
...ts/api/extensions/profiles/JadxTestProfilesExtension.java
+13
-14
jadx-core/src/test/java/jadx/tests/api/extensions/profiles/TestProfile.java
.../java/jadx/tests/api/extensions/profiles/TestProfile.java
+41
-0
jadx-core/src/test/java/jadx/tests/api/extensions/profiles/TestWithProfiles.java
.../jadx/tests/api/extensions/profiles/TestWithProfiles.java
+5
-5
jadx-core/src/test/java/jadx/tests/integration/debuginfo/TestLineNumbers3.java
...va/jadx/tests/integration/debuginfo/TestLineNumbers3.java
+3
-3
jadx-core/src/test/java/jadx/tests/integration/invoke/TestSuperInvoke2.java
.../java/jadx/tests/integration/invoke/TestSuperInvoke2.java
+3
-3
jadx-core/src/test/java/jadx/tests/integration/others/TestStringConcatJava11.java
...jadx/tests/integration/others/TestStringConcatJava11.java
+3
-3
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatch9.java
...t/java/jadx/tests/integration/trycatch/TestTryCatch9.java
+3
-3
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatchFinally13.java
...adx/tests/integration/trycatch/TestTryCatchFinally13.java
+3
-3
jadx-core/src/test/java/jadx/tests/integration/variables/TestVariablesInInlinedAssign.java
...s/integration/variables/TestVariablesInInlinedAssign.java
+3
-3
未找到文件。
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
浏览文件 @
46b5725d
...
...
@@ -490,7 +490,7 @@ public abstract class IntegrationTest extends TestUtils {
this
.
useEclipseCompiler
=
true
;
}
p
rotected
void
useTargetJavaVersion
(
int
version
)
{
p
ublic
void
useTargetJavaVersion
(
int
version
)
{
Assumptions
.
assumeTrue
(
JavaUtils
.
checkJavaVersion
(
version
),
"skip test for higher java version"
);
this
.
targetJavaVersion
=
version
;
}
...
...
jadx-core/src/test/java/jadx/tests/api/extensions/inputs/InputPlugin.java
已删除
100644 → 0
浏览文件 @
72542fa6
package
jadx.tests.api.extensions.inputs
;
import
java.util.function.Consumer
;
import
jadx.tests.api.IntegrationTest
;
public
enum
InputPlugin
implements
Consumer
<
IntegrationTest
>
{
DEX
{
@Override
public
void
accept
(
IntegrationTest
test
)
{
test
.
useDexInput
();
}
},
JAVA
{
@Override
public
void
accept
(
IntegrationTest
test
)
{
test
.
useJavaInput
();
}
};
}
jadx-core/src/test/java/jadx/tests/api/extensions/
inputs/JadxInputPlugin
sExtension.java
→
jadx-core/src/test/java/jadx/tests/api/extensions/
profiles/JadxTestProfile
sExtension.java
浏览文件 @
46b5725d
package
jadx.tests.api.extensions.
input
s
;
package
jadx.tests.api.extensions.
profile
s
;
import
java.lang.reflect.Method
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.stream.Stream
;
import
org.junit.jupiter.api.Test
;
...
...
@@ -19,38 +18,38 @@ import jadx.tests.api.IntegrationTest;
import
static
org
.
junit
.
platform
.
commons
.
util
.
AnnotationUtils
.
isAnnotated
;
public
class
Jadx
InputPlugin
sExtension
implements
TestTemplateInvocationContextProvider
{
public
class
Jadx
TestProfile
sExtension
implements
TestTemplateInvocationContextProvider
{
@Override
public
boolean
supportsTestTemplate
(
ExtensionContext
context
)
{
return
isAnnotated
(
context
.
getTestMethod
(),
TestWith
InputPlugin
s
.
class
);
return
isAnnotated
(
context
.
getTestMethod
(),
TestWith
Profile
s
.
class
);
}
@Override
public
Stream
<
TestTemplateInvocationContext
>
provideTestTemplateInvocationContexts
(
ExtensionContext
context
)
{
Preconditions
.
condition
(
IntegrationTest
.
class
.
isAssignableFrom
(
context
.
getRequiredTestClass
()),
"@TestWith
InputPlugin
s should be used only in IntegrationTest subclasses"
);
"@TestWith
Profile
s should be used only in IntegrationTest subclasses"
);
Method
testMethod
=
context
.
getRequiredTestMethod
();
boolean
testAnnAdded
=
AnnotationUtils
.
findAnnotation
(
testMethod
,
Test
.
class
).
isPresent
();
Preconditions
.
condition
(!
testAnnAdded
,
"@Test annotation should be removed"
);
TestWith
InputPlugins
inputPluginAnn
=
AnnotationUtils
.
findAnnotation
(
testMethod
,
TestWithInputPlugin
s
.
class
).
get
();
return
Stream
.
of
(
inputPlugin
Ann
.
value
())
TestWith
Profiles
profilesAnn
=
AnnotationUtils
.
findAnnotation
(
testMethod
,
TestWithProfile
s
.
class
).
get
();
return
Stream
.
of
(
profiles
Ann
.
value
())
.
sorted
()
.
map
(
RunWith
InputPlugin
:
:
new
);
.
map
(
RunWith
Profile
:
:
new
);
}
private
static
class
RunWith
InputPlugin
implements
TestTemplateInvocationContext
{
private
final
InputPlugin
plugin
;
private
static
class
RunWith
Profile
implements
TestTemplateInvocationContext
{
private
final
TestProfile
testProfile
;
public
RunWith
InputPlugin
(
InputPlugin
plugin
)
{
this
.
plugin
=
plugin
;
public
RunWith
Profile
(
TestProfile
testProfile
)
{
this
.
testProfile
=
testProfile
;
}
@Override
public
String
getDisplayName
(
int
invocationIndex
)
{
return
plugin
.
name
().
toLowerCase
(
Locale
.
ROOT
)
+
" input"
;
return
testProfile
.
getDescription
()
;
}
@Override
...
...
@@ -59,7 +58,7 @@ public class JadxInputPluginsExtension implements TestTemplateInvocationContextP
}
private
BeforeTestExecutionCallback
beforeTest
()
{
return
execContext
->
plugin
.
accept
((
IntegrationTest
)
execContext
.
getRequiredTestInstance
());
return
execContext
->
testProfile
.
accept
((
IntegrationTest
)
execContext
.
getRequiredTestInstance
());
}
}
}
jadx-core/src/test/java/jadx/tests/api/extensions/profiles/TestProfile.java
0 → 100644
浏览文件 @
46b5725d
package
jadx.tests.api.extensions.profiles
;
import
java.util.function.Consumer
;
import
jadx.tests.api.IntegrationTest
;
public
enum
TestProfile
implements
Consumer
<
IntegrationTest
>
{
DX_J8
(
"dx-java-8"
,
test
->
{
test
.
useTargetJavaVersion
(
8
);
test
.
useDexInput
();
}),
D8_J11
(
"d8-java-11"
,
test
->
{
test
.
useTargetJavaVersion
(
11
);
test
.
useDexInput
();
}),
JAVA8
(
"java-8"
,
test
->
{
test
.
useTargetJavaVersion
(
8
);
test
.
useJavaInput
();
}),
JAVA11
(
"java-11"
,
test
->
{
test
.
useTargetJavaVersion
(
11
);
test
.
useJavaInput
();
});
private
final
String
description
;
private
final
Consumer
<
IntegrationTest
>
setup
;
TestProfile
(
String
description
,
Consumer
<
IntegrationTest
>
setup
)
{
this
.
description
=
description
;
this
.
setup
=
setup
;
}
@Override
public
void
accept
(
IntegrationTest
integrationTest
)
{
this
.
setup
.
accept
(
integrationTest
);
}
public
String
getDescription
()
{
return
description
;
}
}
jadx-core/src/test/java/jadx/tests/api/extensions/
inputs/TestWithInputPlugin
s.java
→
jadx-core/src/test/java/jadx/tests/api/extensions/
profiles/TestWithProfile
s.java
浏览文件 @
46b5725d
package
jadx.tests.api.extensions.
input
s
;
package
jadx.tests.api.extensions.
profile
s
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
...
...
@@ -9,10 +9,10 @@ import org.junit.jupiter.api.TestTemplate;
import
org.junit.jupiter.api.extension.ExtendWith
;
@TestTemplate
@ExtendWith
(
Jadx
InputPlugin
sExtension
.
class
)
@ExtendWith
(
Jadx
TestProfile
sExtension
.
class
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
{
ElementType
.
METHOD
,
ElementType
.
TYPE
}
)
public
@interface
TestWith
InputPlugin
s
{
@Target
(
ElementType
.
METHOD
)
public
@interface
TestWith
Profile
s
{
InputPlugin
[]
value
();
TestProfile
[]
value
();
}
jadx-core/src/test/java/jadx/tests/integration/debuginfo/TestLineNumbers3.java
浏览文件 @
46b5725d
...
...
@@ -2,8 +2,8 @@ package jadx.tests.integration.debuginfo;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
jadx.tests.api.extensions.
inputs.InputPlugin
;
import
jadx.tests.api.extensions.
inputs.TestWithInputPlugin
s
;
import
jadx.tests.api.extensions.
profiles.TestProfile
;
import
jadx.tests.api.extensions.
profiles.TestWithProfile
s
;
import
static
jadx
.
tests
.
api
.
utils
.
assertj
.
JadxAssertions
.
assertThat
;
...
...
@@ -29,7 +29,7 @@ public class TestLineNumbers3 extends IntegrationTest {
}
}
@TestWith
InputPlugins
({
InputPlugin
.
DEX
,
InputPlugin
.
JAVA
})
@TestWith
Profiles
({
TestProfile
.
DX_J8
,
TestProfile
.
JAVA8
})
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
assertThat
(
cls
).
code
().
containsOne
(
"super(message == null ? \"\" : message.toString());"
);
...
...
jadx-core/src/test/java/jadx/tests/integration/invoke/TestSuperInvoke2.java
浏览文件 @
46b5725d
package
jadx.tests.integration.invoke
;
import
jadx.tests.api.IntegrationTest
;
import
jadx.tests.api.extensions.
inputs.InputPlugin
;
import
jadx.tests.api.extensions.
inputs.TestWithInputPlugin
s
;
import
jadx.tests.api.extensions.
profiles.TestProfile
;
import
jadx.tests.api.extensions.
profiles.TestWithProfile
s
;
import
static
jadx
.
tests
.
api
.
utils
.
assertj
.
JadxAssertions
.
assertThat
;
...
...
@@ -19,7 +19,7 @@ public class TestSuperInvoke2 extends IntegrationTest {
}
}
@TestWith
InputPlugins
({
InputPlugin
.
DEX
,
InputPlugin
.
JAVA
})
@TestWith
Profiles
({
TestProfile
.
DX_J8
,
TestProfile
.
JAVA8
})
public
void
test
()
{
noDebugInfo
();
assertThat
(
getClassNode
(
TestCls
.
class
))
...
...
jadx-core/src/test/java/jadx/tests/integration/others/TestStringConcatJava11.java
浏览文件 @
46b5725d
...
...
@@ -3,8 +3,8 @@ package jadx.tests.integration.others;
import
org.junit.jupiter.api.Test
;
import
jadx.tests.api.RaungTest
;
import
jadx.tests.api.extensions.
inputs.InputPlugin
;
import
jadx.tests.api.extensions.
inputs.TestWithInputPlugin
s
;
import
jadx.tests.api.extensions.
profiles.TestProfile
;
import
jadx.tests.api.extensions.
profiles.TestWithProfile
s
;
import
static
jadx
.
tests
.
api
.
utils
.
assertj
.
JadxAssertions
.
assertThat
;
...
...
@@ -52,7 +52,7 @@ public class TestStringConcatJava11 extends RaungTest {
"return str + \"test\" + str + \"7\";"
);
// dynamic concat add const to string recipe
}
@TestWith
InputPlugins
({
InputPlugin
.
DEX
,
InputPlugin
.
JAVA
})
@TestWith
Profiles
({
TestProfile
.
DX_J8
,
TestProfile
.
JAVA8
})
public
void
testJava11
()
{
useTargetJavaVersion
(
11
);
noDebugInfo
();
...
...
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatch9.java
浏览文件 @
46b5725d
package
jadx.tests.integration.trycatch
;
import
jadx.tests.api.IntegrationTest
;
import
jadx.tests.api.extensions.
inputs.InputPlugin
;
import
jadx.tests.api.extensions.
inputs.TestWithInputPlugin
s
;
import
jadx.tests.api.extensions.
profiles.TestProfile
;
import
jadx.tests.api.extensions.
profiles.TestWithProfile
s
;
import
static
jadx
.
tests
.
api
.
utils
.
assertj
.
JadxAssertions
.
assertThat
;
...
...
@@ -34,7 +34,7 @@ public class TestTryCatch9 extends IntegrationTest {
}
}
@TestWith
InputPlugins
({
InputPlugin
.
DEX
,
InputPlugin
.
JAVA
})
@TestWith
Profiles
({
TestProfile
.
DX_J8
,
TestProfile
.
JAVA8
})
public
void
test
()
{
assertThat
(
getClassNode
(
TestCls
.
class
))
.
code
()
...
...
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatchFinally13.java
浏览文件 @
46b5725d
package
jadx.tests.integration.trycatch
;
import
jadx.tests.api.IntegrationTest
;
import
jadx.tests.api.extensions.
inputs.InputPlugin
;
import
jadx.tests.api.extensions.
inputs.TestWithInputPlugin
s
;
import
jadx.tests.api.extensions.
profiles.TestProfile
;
import
jadx.tests.api.extensions.
profiles.TestWithProfile
s
;
import
static
jadx
.
tests
.
api
.
utils
.
assertj
.
JadxAssertions
.
assertThat
;
...
...
@@ -43,7 +43,7 @@ public class TestTryCatchFinally13 extends IntegrationTest {
}
}
@TestWith
InputPlugins
({
InputPlugin
.
DEX
,
InputPlugin
.
JAVA
})
@TestWith
Profiles
({
TestProfile
.
DX_J8
,
TestProfile
.
JAVA8
})
public
void
test
()
{
assertThat
(
getClassNode
(
TestCls
.
class
))
.
code
()
...
...
jadx-core/src/test/java/jadx/tests/integration/variables/TestVariablesInInlinedAssign.java
浏览文件 @
46b5725d
package
jadx.tests.integration.variables
;
import
jadx.tests.api.IntegrationTest
;
import
jadx.tests.api.extensions.
inputs.InputPlugin
;
import
jadx.tests.api.extensions.
inputs.TestWithInputPlugin
s
;
import
jadx.tests.api.extensions.
profiles.TestProfile
;
import
jadx.tests.api.extensions.
profiles.TestWithProfile
s
;
import
static
jadx
.
tests
.
api
.
utils
.
assertj
.
JadxAssertions
.
assertThat
;
...
...
@@ -21,7 +21,7 @@ public class TestVariablesInInlinedAssign extends IntegrationTest {
}
}
@TestWith
InputPlugins
({
InputPlugin
.
DEX
,
InputPlugin
.
JAVA
})
@TestWith
Profiles
({
TestProfile
.
DX_J8
,
TestProfile
.
JAVA8
})
public
void
test
()
{
assertThat
(
getClassNode
(
TestCls
.
class
))
.
code
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录