Commit 7a93e029 authored by Hazem Ashmawy's avatar Hazem Ashmawy Committed by Commit Bot

[AW] DevUI: add basic espresso tests for CrashesListFragment

Add basic UI espresso tests to make sure the correct UI elements and
info are shown for different crash reports status.

Fixed: 1106312
Test: run_webview_instrumentation_test_apk -f "*android_webview.devui*"
Change-Id: Idf16e513133db7592887f2b881b1ffefe3792b43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2376805
Commit-Queue: Hazem Ashmawy <hazems@chromium.org>
Reviewed-by: default avatarNate Fischer <ntfschr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804515}
parent 9ed0fd18
......@@ -29,8 +29,10 @@ import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.IntDef;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;
import org.chromium.android_webview.common.DeveloperModeUtils;
......@@ -61,11 +63,13 @@ public class CrashesListFragment extends DevUiBaseFragment {
private static final String TAG = "WebViewDevTools";
// Max number of crashes to show in the crashes list.
private static final int MAX_CRASHES_NUMBER = 20;
public static final int MAX_CRASHES_NUMBER = 20;
private CrashListExpandableAdapter mCrashListViewAdapter;
private Context mContext;
private static @Nullable Runnable sCrashInfoLoadedListener;
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
@IntDef({CollectionState.ENABLED_BY_COMMANDLINE, CollectionState.ENABLED_BY_FLAG_UI,
......@@ -390,13 +394,15 @@ public class CrashesListFragment extends DevUiBaseFragment {
protected void onPostExecute(List<CrashInfo> result) {
mCrashInfoList = result;
notifyDataSetChanged();
if (sCrashInfoLoadedListener != null) sCrashInfoLoadedListener.run();
}
};
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
private static String uploadStateString(UploadState uploadState) {
@VisibleForTesting
public static String uploadStateString(UploadState uploadState) {
switch (uploadState) {
case UPLOADED:
return "Uploaded";
......@@ -511,6 +517,15 @@ public class CrashesListFragment extends DevUiBaseFragment {
return dialogBuilder.create();
}
/**
* Notifies the caller when all CrashInfo is reloaded in the ListView.
*/
@MainThread
@VisibleForTesting
public static void setCrashInfoLoadedListenerForTesting(@Nullable Runnable listener) {
sCrashInfoLoadedListener = listener;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.crashes_options_menu, menu);
......
......@@ -318,6 +318,7 @@ instrumentation_test_apk("webview_instrumentation_test_apk") {
"../javatests/src/org/chromium/android_webview/test/common/crash/CrashInfoTest.java",
"../javatests/src/org/chromium/android_webview/test/common/variations/VariationsUtilsTest.java",
"../javatests/src/org/chromium/android_webview/test/devui/AwNonembeddedUmaRecorderTest.java",
"../javatests/src/org/chromium/android_webview/test/devui/CrashesListFragmentTest.java",
"../javatests/src/org/chromium/android_webview/test/devui/DeveloperUiTest.java",
"../javatests/src/org/chromium/android_webview/test/devui/DeveloperUiTestUtils.java",
"../javatests/src/org/chromium/android_webview/test/devui/FlagsFragmentTest.java",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment