Skip to content

Commit

Permalink
[WebView] Cleanup: Nonembedded/embedded crash BUILD-dependencies
Browse files Browse the repository at this point in the history
- Separate common_crash BUILD targets into BUILD targets for nonembedded code and embedded code.
- Convert CrashInfoTest from instrumentation to junit test as it does not need to run on a device.

Test: android_webview_junit_tests and webview_instrumentation_test_apk
Change-Id: Ia1eac73d9c9354c6f051b13a9168c736f183bb8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4548241
Commit-Queue: Susanne Westphal <swestphal@chromium.org>
Reviewed-by: Nate Fischer <ntfschr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1148104}
  • Loading branch information
s-westphal authored and Chromium LUCI CQ committed May 23, 2023
1 parent 063619f commit 7498ab2
Show file tree
Hide file tree
Showing 29 changed files with 306 additions and 281 deletions.
14 changes: 3 additions & 11 deletions android_webview/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,10 @@ android_library("browser_java") {
]
deps = [
":common_aidl_java",
":common_crash_java",
":common_java",
":common_platform_services_java",
":common_variations_java",
":crash_client_java",
":resources",
"//android_webview/proto:metrics_bridge_records_proto_java",
"//base:base_java",
Expand Down Expand Up @@ -723,20 +723,12 @@ android_library("platform_service_bridge_upstream_implementation_java") {
deps = [ ":common_platform_services_java" ]
}

android_library("common_crash_java") {
sources = [
"java/src/org/chromium/android_webview/common/crash/AwCrashReporterClient.java",
"java/src/org/chromium/android_webview/common/crash/CrashInfo.java",
"java/src/org/chromium/android_webview/common/crash/CrashUploadUtil.java",
"java/src/org/chromium/android_webview/common/crash/SystemWideCrashDirectories.java",
]
android_library("crash_client_java") {
sources = [ "java/src/org/chromium/android_webview/common/crash/AwCrashReporterClient.java" ]

deps = [
":common_java",
"//base:base_java",
"//base:jni_java",
"//components/background_task_scheduler:background_task_scheduler_task_ids_java",
"//components/minidump_uploader:minidump_uploader_java",
"//third_party/androidx:androidx_annotation_annotation_java",
]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;

import static org.chromium.android_webview.test.common.crash.CrashInfoTest.createCrashInfo;
import static org.chromium.android_webview.nonembedded.crash.CrashInfo.createCrashInfoForTesting;
import static org.chromium.android_webview.test.devui.DeveloperUiTestUtils.getClipBoardTextOnUiThread;
import static org.chromium.android_webview.test.devui.DeveloperUiTestUtils.setClipBoardTextOnUiThread;
import static org.chromium.android_webview.test.devui.DeveloperUiTestUtils.withCount;
Expand Down Expand Up @@ -63,16 +63,16 @@
import org.junit.runner.RunWith;

import org.chromium.android_webview.common.PlatformServiceBridge;
import org.chromium.android_webview.common.crash.CrashInfo;
import org.chromium.android_webview.common.crash.CrashInfo.UploadState;
import org.chromium.android_webview.common.crash.CrashUploadUtil;
import org.chromium.android_webview.common.crash.CrashUploadUtil.CrashUploadDelegate;
import org.chromium.android_webview.common.crash.SystemWideCrashDirectories;
import org.chromium.android_webview.devui.CrashesListFragment;
import org.chromium.android_webview.devui.MainActivity;
import org.chromium.android_webview.devui.R;
import org.chromium.android_webview.devui.WebViewPackageError;
import org.chromium.android_webview.devui.util.CrashBugUrlFactory;
import org.chromium.android_webview.nonembedded.crash.CrashInfo;
import org.chromium.android_webview.nonembedded.crash.CrashInfo.UploadState;
import org.chromium.android_webview.nonembedded.crash.CrashUploadUtil;
import org.chromium.android_webview.nonembedded.crash.CrashUploadUtil.CrashUploadDelegate;
import org.chromium.android_webview.nonembedded.crash.SystemWideCrashDirectories;
import org.chromium.android_webview.nonembedded_util.WebViewPackageHelper;
import org.chromium.android_webview.test.AwJUnit4ClassRunner;
import org.chromium.base.Callback;
Expand Down Expand Up @@ -386,7 +386,7 @@ public void queryMetricsSetting(Callback<Boolean> callback) {
@Feature({"AndroidWebView"})
public void testShowingSingleCrashReport_uploaded() throws Throwable {
final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo("123456", systemTime, "0abcde123456",
CrashInfo crashInfo = createCrashInfoForTesting("123456", systemTime, "0abcde123456",
systemTime + 1000, FAKE_APP_PACKAGE_NAME, UploadState.UPLOADED);

assertThat("temp json log file should exist", writeJsonLogFile(crashInfo).exists());
Expand Down Expand Up @@ -423,7 +423,7 @@ public void testShowingSingleCrashReport_uploaded() throws Throwable {
@Feature({"AndroidWebView"})
public void testOpenBugReportCrash() throws Throwable {
final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo("123456", systemTime, "0abcde123456",
CrashInfo crashInfo = createCrashInfoForTesting("123456", systemTime, "0abcde123456",
systemTime + 1000, FAKE_APP_PACKAGE_NAME, UploadState.UPLOADED);

assertThat("temp json log file should exist", writeJsonLogFile(crashInfo).exists());
Expand Down Expand Up @@ -472,7 +472,7 @@ public void testOpenBugReportCrash() throws Throwable {
@Feature({"AndroidWebView"})
public void testShowingSingleCrashReport_pending() throws Throwable {
final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo(
CrashInfo crashInfo = createCrashInfoForTesting(
"123456", systemTime, null, -1, FAKE_APP_PACKAGE_NAME, UploadState.PENDING);

assertThat("temp minidump file should exist", createMinidumpFile(crashInfo).exists());
Expand Down Expand Up @@ -511,8 +511,8 @@ public void testShowingSingleCrashReport_pending() throws Throwable {
@Feature({"AndroidWebView"})
public void testShowingSingleCrashReport_pendingUserRequest() throws Throwable {
final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo("123456", systemTime, null, -1, FAKE_APP_PACKAGE_NAME,
UploadState.PENDING_USER_REQUESTED);
CrashInfo crashInfo = createCrashInfoForTesting("123456", systemTime, null, -1,
FAKE_APP_PACKAGE_NAME, UploadState.PENDING_USER_REQUESTED);

assertThat("temp minidump file should exist", createMinidumpFile(crashInfo).exists());
assertThat("temp json log file should exist", writeJsonLogFile(crashInfo).exists());
Expand Down Expand Up @@ -549,7 +549,7 @@ public void testShowingSingleCrashReport_pendingUserRequest() throws Throwable {
@Feature({"AndroidWebView"})
public void testShowingSingleCrashReport_skipped() throws Throwable {
final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo(
CrashInfo crashInfo = createCrashInfoForTesting(
"123456", systemTime, null, -1, FAKE_APP_PACKAGE_NAME, UploadState.SKIPPED);

assertThat("temp minidump file should exist", createMinidumpFile(crashInfo).exists());
Expand Down Expand Up @@ -588,7 +588,7 @@ public void testShowingSingleCrashReport_skipped() throws Throwable {
@Feature({"AndroidWebView"})
public void testForceUploadSkippedCrashReport_noWifi() throws Throwable {
final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo(
CrashInfo crashInfo = createCrashInfoForTesting(
"123456", systemTime, null, -1, FAKE_APP_PACKAGE_NAME, UploadState.SKIPPED);

File minidumpFile = createMinidumpFile(crashInfo);
Expand Down Expand Up @@ -654,7 +654,7 @@ public boolean isNetworkUnmetered(Context context) {
@Feature({"AndroidWebView"})
public void testForceUploadSkippedCrashReport_withWifi() throws Throwable {
final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo(
CrashInfo crashInfo = createCrashInfoForTesting(
"123456", systemTime, null, -1, FAKE_APP_PACKAGE_NAME, UploadState.SKIPPED);

File minidumpFile = createMinidumpFile(crashInfo);
Expand Down Expand Up @@ -721,7 +721,7 @@ public void testInstalledPackageInfo() throws Throwable {
"This test assumes \"com.android.settings\" package is available", appInfo);

final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo(
CrashInfo crashInfo = createCrashInfoForTesting(
"123456", systemTime, null, -1, appPackageName, UploadState.PENDING);

assertThat("temp minidump file should exist", createMinidumpFile(crashInfo).exists());
Expand All @@ -746,8 +746,8 @@ public void testInstalledPackageInfo() throws Throwable {
// Test when app package name field is missing in the crash info.
public void testMissingPackageInfo() throws Throwable {
final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo =
createCrashInfo("123456", systemTime, null, -1, null, UploadState.PENDING);
CrashInfo crashInfo = createCrashInfoForTesting(
"123456", systemTime, null, -1, null, UploadState.PENDING);

assertThat("temp minidump file should exist", createMinidumpFile(crashInfo).exists());
assertThat("temp json log file should exist", writeJsonLogFile(crashInfo).exists());
Expand All @@ -766,7 +766,8 @@ public void testMissingPackageInfo() throws Throwable {
@Feature({"AndroidWebView"})
// Test when crash is missing json, but has upload log file and minidump.
public void testShowingSingleCrashReport_uploaded_missingJson() throws Throwable {
CrashInfo crashInfo = createCrashInfo("123456", -1, null, 1000, null, UploadState.UPLOADED);
CrashInfo crashInfo =
createCrashInfoForTesting("123456", -1, null, 1000, null, UploadState.UPLOADED);

assertThat("temp minidump file should exist", createMinidumpFile(crashInfo).exists());
assertThat("upload log file should exist", appendUploadedEntryToLog(crashInfo).exists());
Expand All @@ -785,7 +786,8 @@ public void testShowingSingleCrashReport_uploaded_missingJson() throws Throwable
@Feature({"AndroidWebView"})
// Test when crash is missing json, but has upload log file and minidump.
public void testShowingSingleCrashReport_pending_missingJson() throws Throwable {
CrashInfo crashInfo = createCrashInfo("123456", -1, null, 1000, null, UploadState.PENDING);
CrashInfo crashInfo =
createCrashInfoForTesting("123456", -1, null, 1000, null, UploadState.PENDING);

assertThat("temp minidump file should exist", createMinidumpFile(crashInfo).exists());

Expand All @@ -808,8 +810,8 @@ public void testMaxNumberOfCrashes() throws Throwable {
for (int i = 0; i < crashReportsNum; ++i) {
// Set capture time with an arbitrary chosen 2 second difference to make sure crashes
// are shown in descending order with most recent crash first.
crashInfo[i] = createCrashInfo("abcd" + Integer.toString(i), systemTime + i * 2000,
null, -1, FAKE_APP_PACKAGE_NAME, UploadState.PENDING);
crashInfo[i] = createCrashInfoForTesting("abcd" + Integer.toString(i),
systemTime + i * 2000, null, -1, FAKE_APP_PACKAGE_NAME, UploadState.PENDING);

assertThat(
"temp minidump file should exist", createMinidumpFile(crashInfo[i]).exists());
Expand All @@ -836,7 +838,7 @@ public void testMaxNumberOfCrashes() throws Throwable {
@Feature({"AndroidWebView"})
public void testHideCrashButton_uploaded() throws Throwable {
final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo("123456", systemTime, "0abcde123456",
CrashInfo crashInfo = createCrashInfoForTesting("123456", systemTime, "0abcde123456",
systemTime + 1000, FAKE_APP_PACKAGE_NAME, UploadState.UPLOADED);

assertThat("temp json log file should exist", writeJsonLogFile(crashInfo).exists());
Expand Down Expand Up @@ -867,7 +869,7 @@ public void testHideCrashButton_uploaded() throws Throwable {
@Feature({"AndroidWebView"})
public void testHideCrashButton_pending() throws Throwable {
final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo(
CrashInfo crashInfo = createCrashInfoForTesting(
"123456", systemTime, null, -1, FAKE_APP_PACKAGE_NAME, UploadState.PENDING);

assertThat("temp minidump file should exist", createMinidumpFile(crashInfo).exists());
Expand Down Expand Up @@ -897,7 +899,8 @@ public void testHideCrashButton_pending() throws Throwable {
@Test
@Feature({"AndroidWebView"})
public void testHideCrashButton_uploaded_missingJson() throws Throwable {
CrashInfo crashInfo = createCrashInfo("123456", -1, null, 1000, null, UploadState.UPLOADED);
CrashInfo crashInfo =
createCrashInfoForTesting("123456", -1, null, 1000, null, UploadState.UPLOADED);

assertThat("temp minidump file should exist", createMinidumpFile(crashInfo).exists());
assertThat("upload log file should exist", appendUploadedEntryToLog(crashInfo).exists());
Expand Down Expand Up @@ -926,7 +929,8 @@ public void testHideCrashButton_uploaded_missingJson() throws Throwable {
@Test
@Feature({"AndroidWebView"})
public void testHideCrashButton_pending_missingJson() throws Throwable {
CrashInfo crashInfo = createCrashInfo("123456", -1, null, -1, null, UploadState.PENDING);
CrashInfo crashInfo =
createCrashInfoForTesting("123456", -1, null, -1, null, UploadState.PENDING);

assertThat("temp minidump file should exist", createMinidumpFile(crashInfo).exists());

Expand Down Expand Up @@ -963,7 +967,7 @@ public void testRefreshMenuOption() throws Throwable {
onView(withId(R.id.crashes_list)).check(matches(withCount(0)));

final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo(
CrashInfo crashInfo = createCrashInfoForTesting(
"123456", systemTime, null, -1, FAKE_APP_PACKAGE_NAME, UploadState.PENDING);

assertThat("temp minidump file should exist", createMinidumpFile(crashInfo).exists());
Expand All @@ -988,9 +992,9 @@ public void testRefreshMenuOption() throws Throwable {
public void testLongPressCopy() throws Throwable {
Context context = InstrumentationRegistry.getTargetContext();
final long systemTime = System.currentTimeMillis();
CrashInfo uploadedCrashInfo = createCrashInfo("123456", systemTime - 1000, "0abcde123456",
systemTime, FAKE_APP_PACKAGE_NAME, UploadState.UPLOADED);
CrashInfo pendingCrashInfo = createCrashInfo(
CrashInfo uploadedCrashInfo = createCrashInfoForTesting("123456", systemTime - 1000,
"0abcde123456", systemTime, FAKE_APP_PACKAGE_NAME, UploadState.UPLOADED);
CrashInfo pendingCrashInfo = createCrashInfoForTesting(
"78910", systemTime - 2000, null, -1, FAKE_APP_PACKAGE_NAME, UploadState.PENDING);

assertThat("temp json log file for uploaded crash should exist",
Expand Down
Loading

0 comments on commit 7498ab2

Please sign in to comment.