Remove main thread assertion from test

Bug: 30229849
Change-Id: I09d25bebf28f45423320e79d1ba2ad49a327bdb0
diff --git a/v7/recyclerview/tests/src/android/support/v7/widget/BaseRecyclerViewInstrumentationTest.java b/v7/recyclerview/tests/src/android/support/v7/widget/BaseRecyclerViewInstrumentationTest.java
index 5f7f244..7a7a4d4 100644
--- a/v7/recyclerview/tests/src/android/support/v7/widget/BaseRecyclerViewInstrumentationTest.java
+++ b/v7/recyclerview/tests/src/android/support/v7/widget/BaseRecyclerViewInstrumentationTest.java
@@ -1107,11 +1107,21 @@
         return Looper.myLooper() == Looper.getMainLooper();
     }
 
-    public void runTestOnUiThread(Runnable r) throws Throwable {
+    public void runTestOnUiThread(final Runnable r) throws Throwable {
         if (Looper.myLooper() == Looper.getMainLooper()) {
             r.run();
         } else {
-            InstrumentationRegistry.getInstrumentation().runOnMainSync(r);
+            InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        r.run();
+                    } catch (Throwable t) {
+                        postExceptionToInstrumentation(t);
+                    }
+                }
+            });
+            checkForMainThreadException();
         }
     }
 
diff --git a/v7/recyclerview/tests/src/android/support/v7/widget/DefaultItemAnimatorTest.java b/v7/recyclerview/tests/src/android/support/v7/widget/DefaultItemAnimatorTest.java
index 4ace4ca..1ebd17f 100644
--- a/v7/recyclerview/tests/src/android/support/v7/widget/DefaultItemAnimatorTest.java
+++ b/v7/recyclerview/tests/src/android/support/v7/widget/DefaultItemAnimatorTest.java
@@ -440,13 +440,4 @@
     private interface ThrowingRunnable {
         void run() throws Throwable;
     }
-
-    @Override
-    public void runTestOnUiThread(Runnable r) throws Throwable {
-        if (Looper.myLooper() == Looper.getMainLooper()) {
-            r.run();
-        } else {
-            super.runTestOnUiThread(r);
-        }
-    }
 }