Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core.runtime): getDatabasePath支持传绝对路径 #1311

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ Shadow的`coding`和`core.gradle-plugin`、`core.manifest-parser`、`core.transf
`-wipe-data -no-snapstorage`使得虚拟机完全恢复到新建状态。
`-no-boot-anim`稍微加快点启动。

## 启动指定自动化测试用例

随着Android Studio更新,在#1263 解决之前,只能通过命令行执行自动化测试。
如下命令,传入类名#方法可以指定单个方法。只传入类名可以测试整个类。
如果测试方法是抽象类中的,需要传入一个具体的实现类。

```shell
./gradlew :test-dynamic-host:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.tencent.shadow.test.cases.plugin_main.ApplicationContextSubDirTest#testGetDatabasePath
```

## 清理工作区

由于复合构建的存在,Gradle clean任务不能总是很好的完成清理工作区的目的。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ public boolean deleteDatabase(String name) {

@Override
public File getDatabasePath(String name) {
if (getSubDirName() == null) {
if (getSubDirName() == null
|| name.charAt(0) == File.separatorChar) {
return super.getDatabasePath(name);
} else {
return super.getDatabasePath(makeSubName(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ public void testGetDatabasePath() {
"TAG_GET_DATABASE_PATH_BAR",
hostDatabasePath + "/" + EXPECT_NAME + "_bar"
);
matchTextWithViewTag(
"TAG_GET_DATABASE_ABSOLUTE_PATH_FOO_BAR",
"/foo/bar"
);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ protected void fillTestValues(Context testContext) {
testContext.getDatabasePath("bar").getAbsolutePath()
);

// 传绝对路径给getDatabasePath应该返回路径不变的文件
makeItem("getDatabasePath(\"/foo/bar\")", "TAG_GET_DATABASE_ABSOLUTE_PATH_FOO_BAR",
testContext.getDatabasePath("/foo/bar").getAbsolutePath()
);


Context hostContext = getApplication().getBaseContext();
hostContext.openOrCreateDatabase("foo", MODE_PRIVATE, null);
Expand Down
Loading