Skip to content

Commit

Permalink
test: 修复API 29以上虚拟机自动化测试
Browse files Browse the repository at this point in the history
1. onActivityPreCreated回调中注册回调,不断启动Activity后无限放大回调数量,OOM。
2. DatabaseList在新版本上内容有增加,改为只匹配部分字符串。
  • Loading branch information
shifujun committed Oct 29, 2021
1 parent 089e026 commit 352561d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

package com.tencent.shadow.test.cases.plugin_main;

import static android.content.Context.MODE_PRIVATE;
import static android.os.Environment.DIRECTORY_MUSIC;
import static android.os.Environment.DIRECTORY_PODCASTS;

import android.content.SharedPreferences;
import android.os.Build;

Expand All @@ -30,10 +34,6 @@
import java.io.FilenameFilter;
import java.util.Arrays;

import static android.content.Context.MODE_PRIVATE;
import static android.os.Environment.DIRECTORY_MUSIC;
import static android.os.Environment.DIRECTORY_PODCASTS;

abstract class SubDirContextThemeWrapperTest extends PluginMainAppTest {

private static final String PREFIX = "ShadowPlugin";
Expand Down Expand Up @@ -324,9 +324,9 @@ public void testGetDatabasePath() {
@Test
public void testDatabaseList() {
String dbName = EXPECT_NAME + "_bar";
matchTextWithViewTag(
matchSubstringWithViewTag(
"TAG_DATABASE_LIST",
"[" + dbName + "]"
dbName
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ public void onActivityPreCreated(@NonNull Activity activity, @Nullable Bundle sa
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
TestActivityLifecycleCallbacks testForRegisterInPreCreatedCallback = new TestActivityLifecycleCallbacks("TestForRegisterInPreCreatedCallback");
TestApplication.getInstance().registerActivityLifecycleCallbacks(
new TestActivityLifecycleCallbacks("TestForRegisterInPreCreatedCallback")
testForRegisterInPreCreatedCallback
);
TestApplication.getInstance().unregisterActivityLifecycleCallbacks(
testForRegisterInPreCreatedCallback
);
}
}
Expand Down

0 comments on commit 352561d

Please sign in to comment.