diff options
author | Alexander Dorokhine <adorokhine@google.com> | 2020-10-03 00:53:42 -0700 |
---|---|---|
committer | Alexander Dorokhine <adorokhine@google.com> | 2020-10-06 00:14:31 -0700 |
commit | 831cd8798e70588a4c686f1747d039c1a5f1c2b6 (patch) | |
tree | d25438efb254f84899b2dee1f5f70143426ede9d /robolectric | |
parent | 77e1d0b29c0fd220da10bd59d0389976878f9040 (diff) | |
download | robolectric-shadows-831cd8798e70588a4c686f1747d039c1a5f1c2b6.tar.gz |
Migrate away from deprecated Truth APIs.
This is a transitional step towards truth 1.0.1, where these APIs have
been completely removed.
Bug: 168765701
Test: m checkbuild
Merged-In: Ib80387329d988fd0c99b261e9aa454e697515fb6
Change-Id: Ib80387329d988fd0c99b261e9aa454e697515fb6
(cherry picked from commit 971e1154c1cc9439be3e1ec269f0abc178c7db3a)
Diffstat (limited to 'robolectric')
92 files changed, 490 insertions, 489 deletions
diff --git a/robolectric/src/test/java/org/robolectric/ConfigMergerTest.java b/robolectric/src/test/java/org/robolectric/ConfigMergerTest.java index 731dfd7a0..d4474f3da 100644 --- a/robolectric/src/test/java/org/robolectric/ConfigMergerTest.java +++ b/robolectric/src/test/java/org/robolectric/ConfigMergerTest.java @@ -434,9 +434,9 @@ public class ConfigMergerTest { assertThat(config.qualifiers()).isEqualTo(qualifiers); assertThat(config.resourceDir()).isEqualTo(resourceDir); assertThat(config.assetDir()).isEqualTo(assetsDir); - assertThat(config.shadows()).asList().containsAllIn(shadows).inOrder(); - assertThat(config.instrumentedPackages()).asList().containsAllIn(instrumentedPackages); - assertThat(config.libraries()).asList().containsAllIn(libraries); + assertThat(config.shadows()).asList().containsAtLeastElementsIn(shadows).inOrder(); + assertThat(config.instrumentedPackages()).asList().containsAtLeastElementsIn(instrumentedPackages); + assertThat(config.libraries()).asList().containsAtLeastElementsIn(libraries); } @Ignore diff --git a/robolectric/src/test/java/org/robolectric/ConfigTest.java b/robolectric/src/test/java/org/robolectric/ConfigTest.java index 4e04d354e..0c6ee6ccd 100644 --- a/robolectric/src/test/java/org/robolectric/ConfigTest.java +++ b/robolectric/src/test/java/org/robolectric/ConfigTest.java @@ -112,7 +112,7 @@ public class ConfigTest { Config withMore = overlay(withString, new Builder().setShadows(new Class[]{Map.class, String.class}).build()); - assertThat(withMore.shadows()).asList().containsAllOf(String.class, Map.class, String.class); + assertThat(withMore.shadows()).asList().containsAtLeast(String.class, Map.class, String.class); } @Test diff --git a/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerSelfTest.java b/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerSelfTest.java index 8c04b213a..f2adc1e77 100644 --- a/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerSelfTest.java +++ b/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerSelfTest.java @@ -1,6 +1,7 @@ package org.robolectric; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static org.junit.Assert.fail; import android.app.Application; @@ -21,15 +22,14 @@ public class RobolectricTestRunnerSelfTest { @Test public void shouldInitializeAndBindApplicationButNotCallOnCreate() { - assertThat((Application) ApplicationProvider.getApplicationContext()) - .named("application") + assertWithMessage("application").that((Application) ApplicationProvider.getApplicationContext()) .isInstanceOf(MyTestApplication.class); - assertThat(((MyTestApplication) ApplicationProvider.getApplicationContext()).onCreateWasCalled) - .named("onCreate called") + assertWithMessage("onCreate called") + .that(((MyTestApplication) ApplicationProvider.getApplicationContext()).onCreateWasCalled) .isTrue(); if (RuntimeEnvironment.useLegacyResources()) { - assertThat(RuntimeEnvironment.getAppResourceTable()) - .named("Application resource loader") + assertWithMessage("Application resource loader") + .that(RuntimeEnvironment.getAppResourceTable()) .isNotNull(); } } @@ -39,12 +39,12 @@ public class RobolectricTestRunnerSelfTest { Resources systemResources = Resources.getSystem(); Resources appResources = ApplicationProvider.getApplicationContext().getResources(); - assertThat(systemResources).named("system resources").isNotNull(); + assertWithMessage("system resources").that(systemResources).isNotNull(); - assertThat(systemResources.getString(android.R.string.copy)).named("system resource") + assertWithMessage("system resource").that(systemResources.getString(android.R.string.copy)) .isEqualTo(appResources.getString(android.R.string.copy)); - assertThat(appResources.getString(R.string.howdy)).named("app resource") + assertWithMessage("app resource").that(appResources.getString(R.string.howdy)) .isNotNull(); try { systemResources.getString(R.string.howdy); diff --git a/robolectric/src/test/java/org/robolectric/RuntimeEnvironmentTest.java b/robolectric/src/test/java/org/robolectric/RuntimeEnvironmentTest.java index 1fb8a9484..ff42114b0 100644 --- a/robolectric/src/test/java/org/robolectric/RuntimeEnvironmentTest.java +++ b/robolectric/src/test/java/org/robolectric/RuntimeEnvironmentTest.java @@ -1,6 +1,7 @@ package org.robolectric; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static java.util.concurrent.TimeUnit.MILLISECONDS; import java.util.concurrent.CountDownLatch; @@ -16,14 +17,14 @@ public class RuntimeEnvironmentTest { @Test public void setMainThread_forCurrentThread() { RuntimeEnvironment.setMainThread(Thread.currentThread()); - assertThat(RuntimeEnvironment.getMainThread()).isSameAs(Thread.currentThread()); + assertThat(RuntimeEnvironment.getMainThread()).isSameInstanceAs(Thread.currentThread()); } @Test public void setMainThread_forNewThread() { Thread t = new Thread(); RuntimeEnvironment.setMainThread(t); - assertThat(RuntimeEnvironment.getMainThread()).isSameAs(t); + assertThat(RuntimeEnvironment.getMainThread()).isSameInstanceAs(t); } @Test @@ -42,8 +43,8 @@ public class RuntimeEnvironmentTest { if (!finished.await(1000, MILLISECONDS)) { throw new InterruptedException("Thread " + t + " didn't finish timely"); } - assertThat(RuntimeEnvironment.isMainThread()).named("testThread").isTrue(); - assertThat(res.get()).named("thread t").isFalse(); + assertWithMessage("testThread").that(RuntimeEnvironment.isMainThread()).isTrue(); + assertWithMessage("thread t").that(res.get()).isFalse(); } @Test @@ -62,8 +63,8 @@ public class RuntimeEnvironmentTest { if (!finished.await(1000, MILLISECONDS)) { throw new InterruptedException("Thread " + t + " didn't finish timely"); } - assertThat(RuntimeEnvironment.isMainThread()).named("testThread").isFalse(); - assertThat(res.get()).named("thread t").isTrue(); + assertWithMessage("testThread").that(RuntimeEnvironment.isMainThread()).isFalse(); + assertWithMessage("thread t").that(res.get()).isTrue(); } @Test @@ -77,6 +78,6 @@ public class RuntimeEnvironmentTest { public void getSetMasterScheduler() { Scheduler s = new Scheduler(); RuntimeEnvironment.setMasterScheduler(s); - assertThat(RuntimeEnvironment.getMasterScheduler()).isSameAs(s); + assertThat(RuntimeEnvironment.getMasterScheduler()).isSameInstanceAs(s); } -}
\ No newline at end of file +} diff --git a/robolectric/src/test/java/org/robolectric/android/AndroidInterceptorsTest.java b/robolectric/src/test/java/org/robolectric/android/AndroidInterceptorsTest.java index 53be889c3..6241907e8 100644 --- a/robolectric/src/test/java/org/robolectric/android/AndroidInterceptorsTest.java +++ b/robolectric/src/test/java/org/robolectric/android/AndroidInterceptorsTest.java @@ -12,7 +12,7 @@ import org.robolectric.internal.bytecode.MethodRef; public class AndroidInterceptorsTest { @Test public void allMethodRefs() throws Exception { - assertThat(new Interceptors(AndroidInterceptors.all()).getAllMethodRefs()).containsAllOf( + assertThat(new Interceptors(AndroidInterceptors.all()).getAllMethodRefs()).containsAtLeast( new MethodRef("java.util.LinkedHashMap", "eldest"), new MethodRef("java.lang.System", "loadLibrary"), new MethodRef("android.os.StrictMode", "trackActivity"), diff --git a/robolectric/src/test/java/org/robolectric/android/XmlResourceParserImplTest.java b/robolectric/src/test/java/org/robolectric/android/XmlResourceParserImplTest.java index 3fcbcbed5..0247a1237 100644 --- a/robolectric/src/test/java/org/robolectric/android/XmlResourceParserImplTest.java +++ b/robolectric/src/test/java/org/robolectric/android/XmlResourceParserImplTest.java @@ -1,6 +1,7 @@ package org.robolectric.android; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Arrays.asList; import static org.junit.Assert.assertTrue; @@ -357,20 +358,20 @@ public class XmlResourceParserImplTest { @Test public void testIsEmptyElementTag() throws Exception { - assertThat(parser.isEmptyElementTag()).named("Before START_DOCUMENT should return false.").isEqualTo(false); + assertWithMessage("Before START_DOCUMENT should return false.").that(parser.isEmptyElementTag()).isEqualTo(false); forgeAndOpenDocument("<foo><bar/></foo>"); - assertThat(parser.isEmptyElementTag()).named("Not empty tag should return false.").isEqualTo(false); + assertWithMessage("Not empty tag should return false.").that(parser.isEmptyElementTag()).isEqualTo(false); forgeAndOpenDocument("<foo/>"); - assertThat(parser.isEmptyElementTag()).named( - "In the Android implementation this method always return false.").isEqualTo(false); + assertWithMessage("In the Android implementation this method always return false.") + .that(parser.isEmptyElementTag()).isEqualTo(false); } @Test public void testGetAttributeCount() throws Exception { - assertThat(parser.getAttributeCount()) - .named("When no node is being explored the number of attributes should be -1.").isEqualTo(-1); + assertWithMessage("When no node is being explored the number of attributes should be -1.") + .that(parser.getAttributeCount()).isEqualTo(-1); forgeAndOpenDocument("<foo bar=\"bar\"/>"); assertThat(parser.getAttributeCount()).isEqualTo(1); @@ -629,8 +630,8 @@ public class XmlResourceParserImplTest { // Negative unsigned int must be forgeAndOpenDocument("<foo xmlns:app=\"http://schemas.android.com/apk/res-auto\" app:bar=\"-12\"/>"); - assertThat(parser.getAttributeUnsignedIntValue(RES_AUTO_NS, "bar", 0)) - .named("Getting a negative number as unsigned should return the default value.").isEqualTo(0); + assertWithMessage("Getting a negative number as unsigned should return the default value.") + .that(parser.getAttributeUnsignedIntValue(RES_AUTO_NS, "bar", 0)).isEqualTo(0); } @Test @@ -644,8 +645,8 @@ public class XmlResourceParserImplTest { // Negative unsigned int must be forgeAndOpenDocument("<foo bar=\"-12\"/>"); - assertThat(parser.getAttributeUnsignedIntValue(0, 0)) - .named("Getting a negative number as unsigned should return the default value.").isEqualTo(0); + assertWithMessage("Getting a negative number as unsigned should return the default value.") + .that(parser.getAttributeUnsignedIntValue(0, 0)).isEqualTo(0); } @Test diff --git a/robolectric/src/test/java/org/robolectric/android/controller/ActivityControllerTest.java b/robolectric/src/test/java/org/robolectric/android/controller/ActivityControllerTest.java index ea4375763..e12527e91 100644 --- a/robolectric/src/test/java/org/robolectric/android/controller/ActivityControllerTest.java +++ b/robolectric/src/test/java/org/robolectric/android/controller/ActivityControllerTest.java @@ -1,6 +1,7 @@ package org.robolectric.android.controller; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static org.robolectric.Shadows.shadowOf; import android.app.Activity; @@ -66,8 +67,8 @@ public class ActivityControllerTest { final Scheduler s = Robolectric.getForegroundThreadScheduler(); final long startTime = s.getCurrentTime(); TestDelayedPostActivity activity = Robolectric.setupActivity(TestDelayedPostActivity.class); - assertThat(activity.r1.wasRun).named("immediate task").isTrue(); - assertThat(s.getCurrentTime()).named("currentTime").isEqualTo(startTime); + assertWithMessage("immediate task").that(activity.r1.wasRun).isTrue(); + assertWithMessage("currentTime").that(s.getCurrentTime()).isEqualTo(startTime); } @Test @@ -76,11 +77,11 @@ public class ActivityControllerTest { final Scheduler s = Robolectric.getForegroundThreadScheduler(); final long startTime = s.getCurrentTime(); TestDelayedPostActivity activity = Robolectric.setupActivity(TestDelayedPostActivity.class); - assertThat(activity.r2.wasRun).named("before flush").isFalse(); - assertThat(s.getCurrentTime()).named("currentTime before flush").isEqualTo(startTime); + assertWithMessage("before flush").that(activity.r2.wasRun).isFalse(); + assertWithMessage("currentTime before flush").that(s.getCurrentTime()).isEqualTo(startTime); s.advanceToLastPostedRunnable(); - assertThat(activity.r2.wasRun).named("after flush").isTrue(); - assertThat(s.getCurrentTime()).named("currentTime after flush").isEqualTo(startTime + 60000); + assertWithMessage("after flush").that(activity.r2.wasRun).isTrue(); + assertWithMessage("currentTime after flush").that(s.getCurrentTime()).isEqualTo(startTime + 60000); } @Test @@ -108,7 +109,7 @@ public class ActivityControllerTest { ShadowLooper.unPauseMainLooper(); controller.create(); assertThat(shadowOf(Looper.getMainLooper()).isPaused()).isFalse(); - assertThat(transcript).containsAllOf("finishedOnCreate", "onCreate"); + assertThat(transcript).containsAtLeast("finishedOnCreate", "onCreate"); } @Test @@ -133,73 +134,73 @@ public class ActivityControllerTest { @Test public void start_callsPerformStartWhilePaused() { controller.create().start(); - assertThat(transcript).containsAllOf("finishedOnStart", "onStart"); + assertThat(transcript).containsAtLeast("finishedOnStart", "onStart"); } @Test public void stop_callsPerformStopWhilePaused() { controller.create().start().stop(); - assertThat(transcript).containsAllOf("finishedOnStop", "onStop"); + assertThat(transcript).containsAtLeast("finishedOnStop", "onStop"); } @Test public void restart_callsPerformRestartWhilePaused() { controller.create().start().stop().restart(); - assertThat(transcript).containsAllOf("finishedOnRestart", "onRestart"); + assertThat(transcript).containsAtLeast("finishedOnRestart", "onRestart"); } @Test public void pause_callsPerformPauseWhilePaused() { controller.create().pause(); - assertThat(transcript).containsAllOf("finishedOnPause", "onPause"); + assertThat(transcript).containsAtLeast("finishedOnPause", "onPause"); } @Test public void resume_callsPerformResumeWhilePaused() { controller.create().start().resume(); - assertThat(transcript).containsAllOf("finishedOnResume", "onResume"); + assertThat(transcript).containsAtLeast("finishedOnResume", "onResume"); } @Test public void destroy_callsPerformDestroyWhilePaused() { controller.create().destroy(); - assertThat(transcript).containsAllOf("finishedOnDestroy", "onDestroy"); + assertThat(transcript).containsAtLeast("finishedOnDestroy", "onDestroy"); } @Test public void postCreate_callsOnPostCreateWhilePaused() { controller.create().postCreate(new Bundle()); - assertThat(transcript).containsAllOf("finishedOnPostCreate", "onPostCreate"); + assertThat(transcript).containsAtLeast("finishedOnPostCreate", "onPostCreate"); } @Test public void postResume_callsOnPostResumeWhilePaused() { controller.create().postResume(); - assertThat(transcript).containsAllOf("finishedOnPostResume", "onPostResume"); + assertThat(transcript).containsAtLeast("finishedOnPostResume", "onPostResume"); } @Test public void restoreInstanceState_callsPerformRestoreInstanceStateWhilePaused() { controller.create().restoreInstanceState(new Bundle()); - assertThat(transcript).containsAllOf("finishedOnRestoreInstanceState", "onRestoreInstanceState"); + assertThat(transcript).containsAtLeast("finishedOnRestoreInstanceState", "onRestoreInstanceState"); } @Test public void newIntent_callsOnNewIntentWhilePaused() { controller.create().newIntent(new Intent(Intent.ACTION_VIEW)); - assertThat(transcript).containsAllOf("finishedOnNewIntent", "onNewIntent"); + assertThat(transcript).containsAtLeast("finishedOnNewIntent", "onNewIntent"); } @Test public void userLeaving_callsPerformUserLeavingWhilePaused() { controller.create().userLeaving(); - assertThat(transcript).containsAllOf("finishedOnUserLeaveHint", "onUserLeaveHint"); + assertThat(transcript).containsAtLeast("finishedOnUserLeaveHint", "onUserLeaveHint"); } @Test public void setup_callsLifecycleMethodsAndMakesVisible() { controller.setup(); - assertThat(transcript).containsAllOf("onCreate", "onStart", "onPostCreate", "onResume", "onPostResume"); + assertThat(transcript).containsAtLeast("onCreate", "onStart", "onPostCreate", "onResume", "onPostResume"); assertThat(controller.get().getWindow().getDecorView().getParent().getClass()).isEqualTo( ViewRootImpl.class); } @@ -207,7 +208,7 @@ public class ActivityControllerTest { @Test public void setupWithBundle_callsLifecycleMethodsAndMakesVisible() { controller.setup(new Bundle()); - assertThat(transcript).containsAllOf("onCreate", "onStart", "onRestoreInstanceState", "onPostCreate", "onResume", "onPostResume"); + assertThat(transcript).containsAtLeast("onCreate", "onStart", "onRestoreInstanceState", "onPostCreate", "onResume", "onPostResume"); assertThat(controller.get().getWindow().getDecorView().getParent().getClass()).isEqualTo( ViewRootImpl.class); } @@ -229,7 +230,7 @@ public class ActivityControllerTest { controller.setup(); transcript.clear(); controller.configurationChange(config); - assertThat(transcript).containsAllOf("onPause", "onStop", "onDestroy", "onCreate", "onStart", "onRestoreInstanceState", "onPostCreate", "onResume", "onPostResume"); + assertThat(transcript).containsAtLeast("onPause", "onStop", "onDestroy", "onCreate", "onStart", "onRestoreInstanceState", "onPostCreate", "onResume", "onPostResume"); assertThat(controller.get().getResources().getConfiguration().fontScale).isEqualTo(newFontScale); } @@ -260,7 +261,7 @@ public class ActivityControllerTest { Robolectric.buildActivity(ConfigAwareActivity.class).setup(); transcript.clear(); configController.configurationChange(config); - assertThat(transcript).containsAllOf("onPause", "onStop", "onDestroy", "onCreate", "onStart", "onResume"); + assertThat(transcript).containsAtLeast("onPause", "onStop", "onDestroy", "onCreate", "onStart", "onResume"); assertThat(configController.get().getResources().getConfiguration().fontScale).isEqualTo(newFontScale); assertThat(configController.get().getResources().getConfiguration().orientation).isEqualTo(newOrientation); } @@ -309,9 +310,9 @@ public class ActivityControllerTest { activity = configController.get(); assertThat(activity.retainedFragment).isNotNull(); - assertThat(activity.retainedFragment).isSameAs(retainedFragment); + assertThat(activity.retainedFragment).isSameInstanceAs(retainedFragment); assertThat(activity.nonRetainedFragment).isNotNull(); - assertThat(activity.nonRetainedFragment).isNotSameAs(otherFragment); + assertThat(activity.nonRetainedFragment).isNotSameInstanceAs(otherFragment); } @Test diff --git a/robolectric/src/test/java/org/robolectric/android/controller/ContentProviderControllerTest.java b/robolectric/src/test/java/org/robolectric/android/controller/ContentProviderControllerTest.java index 190e8878a..2ed48b1d6 100644 --- a/robolectric/src/test/java/org/robolectric/android/controller/ContentProviderControllerTest.java +++ b/robolectric/src/test/java/org/robolectric/android/controller/ContentProviderControllerTest.java @@ -94,7 +94,7 @@ public class ContentProviderControllerTest { XContentProvider xContentProvider = Robolectric.setupContentProvider(XContentProvider.class, "x-authority"); assertThat(xContentProvider.transcript).containsExactly("x-authority not registered yet"); ContentProviderClient contentProviderClient = contentResolver.acquireContentProviderClient("x-authority"); - assertThat(contentProviderClient.getLocalContentProvider()).isSameAs(xContentProvider); + assertThat(contentProviderClient.getLocalContentProvider()).isSameInstanceAs(xContentProvider); } //////////////////// diff --git a/robolectric/src/test/java/org/robolectric/android/controller/IntentServiceControllerTest.java b/robolectric/src/test/java/org/robolectric/android/controller/IntentServiceControllerTest.java index 67115f8ba..e3c7be486 100644 --- a/robolectric/src/test/java/org/robolectric/android/controller/IntentServiceControllerTest.java +++ b/robolectric/src/test/java/org/robolectric/android/controller/IntentServiceControllerTest.java @@ -79,31 +79,31 @@ public class IntentServiceControllerTest { @Test public void unbind_callsUnbindWhilePaused() { controller.create().bind().unbind(); - assertThat(transcript).containsAllOf("finishedOnUnbind", "onUnbind"); + assertThat(transcript).containsAtLeast("finishedOnUnbind", "onUnbind"); } @Test public void rebind_callsRebindWhilePaused() { controller.create().bind().unbind().bind().rebind(); - assertThat(transcript).containsAllOf("finishedOnRebind", "onRebind"); + assertThat(transcript).containsAtLeast("finishedOnRebind", "onRebind"); } @Test public void destroy_callsOnDestroyWhilePaused() { controller.create().destroy(); - assertThat(transcript).containsAllOf("finishedOnDestroy", "onDestroy"); + assertThat(transcript).containsAtLeast("finishedOnDestroy", "onDestroy"); } @Test public void bind_callsOnBindWhilePaused() { controller.create().bind(); - assertThat(transcript).containsAllOf("finishedOnBind", "onBind"); + assertThat(transcript).containsAtLeast("finishedOnBind", "onBind"); } @Test public void startCommand_callsOnHandleIntentWhilePaused() { controller.create().startCommand(1, 2); - assertThat(transcript).containsAllOf("finishedOnHandleIntent", "onHandleIntent"); + assertThat(transcript).containsAtLeast("finishedOnHandleIntent", "onHandleIntent"); } public static class MyService extends IntentService { diff --git a/robolectric/src/test/java/org/robolectric/android/controller/ServiceControllerTest.java b/robolectric/src/test/java/org/robolectric/android/controller/ServiceControllerTest.java index 47eba920f..e01f0d745 100644 --- a/robolectric/src/test/java/org/robolectric/android/controller/ServiceControllerTest.java +++ b/robolectric/src/test/java/org/robolectric/android/controller/ServiceControllerTest.java @@ -80,31 +80,31 @@ public class ServiceControllerTest { @Test public void unbind_callsUnbindWhilePaused() { controller.create().bind().unbind(); - assertThat(transcript).containsAllOf("finishedOnUnbind", "onUnbind"); + assertThat(transcript).containsAtLeast("finishedOnUnbind", "onUnbind"); } @Test public void rebind_callsRebindWhilePaused() { controller.create().bind().unbind().bind().rebind(); - assertThat(transcript).containsAllOf("finishedOnRebind", "onRebind"); + assertThat(transcript).containsAtLeast("finishedOnRebind", "onRebind"); } @Test public void destroy_callsOnDestroyWhilePaused() { controller.create().destroy(); - assertThat(transcript).containsAllOf("finishedOnDestroy", "onDestroy"); + assertThat(transcript).containsAtLeast("finishedOnDestroy", "onDestroy"); } @Test public void bind_callsOnBindWhilePaused() { controller.create().bind(); - assertThat(transcript).containsAllOf("finishedOnBind", "onBind"); + assertThat(transcript).containsAtLeast("finishedOnBind", "onBind"); } @Test public void startCommand_callsOnStartCommandWhilePaused() { controller.create().startCommand(1, 2); - assertThat(transcript).containsAllOf("finishedOnStartCommand", "onStartCommand"); + assertThat(transcript).containsAtLeast("finishedOnStartCommand", "onStartCommand"); } public static class MyService extends Service { diff --git a/robolectric/src/test/java/org/robolectric/android/internal/ParallelUniverseTest.java b/robolectric/src/test/java/org/robolectric/android/internal/ParallelUniverseTest.java index fc9e4d33a..f129e7212 100644 --- a/robolectric/src/test/java/org/robolectric/android/internal/ParallelUniverseTest.java +++ b/robolectric/src/test/java/org/robolectric/android/internal/ParallelUniverseTest.java @@ -54,9 +54,9 @@ public class ParallelUniverseTest { bootstrapWrapper.callSetUpApplicationState(); assertThat(RuntimeEnvironment.getMasterScheduler()) - .isSameAs(ShadowLooper.getShadowMainLooper().getScheduler()); + .isSameInstanceAs(ShadowLooper.getShadowMainLooper().getScheduler()); assertThat(RuntimeEnvironment.getMasterScheduler()) - .isSameAs(ShadowApplication.getInstance().getForegroundThreadScheduler()); + .isSameInstanceAs(ShadowApplication.getInstance().getForegroundThreadScheduler()); } @Test @@ -67,9 +67,9 @@ public class ParallelUniverseTest { final ShadowApplication shadowApplication = Shadow.extract(ApplicationProvider.getApplicationContext()); assertThat(shadowApplication.getBackgroundThreadScheduler()) - .isSameAs(shadowApplication.getForegroundThreadScheduler()); + .isSameInstanceAs(shadowApplication.getForegroundThreadScheduler()); assertThat(RuntimeEnvironment.getMasterScheduler()) - .isSameAs(RuntimeEnvironment.getMasterScheduler()); + .isSameInstanceAs(RuntimeEnvironment.getMasterScheduler()); } finally { RoboSettings.setUseGlobalScheduler(false); } @@ -81,7 +81,7 @@ public class ParallelUniverseTest { final ShadowApplication shadowApplication = Shadow.extract(ApplicationProvider.getApplicationContext()); assertThat(shadowApplication.getBackgroundThreadScheduler()) - .isNotSameAs(shadowApplication.getForegroundThreadScheduler()); + .isNotSameInstanceAs(shadowApplication.getForegroundThreadScheduler()); } @Test diff --git a/robolectric/src/test/java/org/robolectric/fakes/RoboMenuItemTest.java b/robolectric/src/test/java/org/robolectric/fakes/RoboMenuItemTest.java index b9ae3117a..1f733e5f2 100644 --- a/robolectric/src/test/java/org/robolectric/fakes/RoboMenuItemTest.java +++ b/robolectric/src/test/java/org/robolectric/fakes/RoboMenuItemTest.java @@ -146,7 +146,7 @@ public class RoboMenuItemTest { assertThat(testDrawable).isNotNull(); assertThat(item.getIcon()).isNull(); item.setIcon(testDrawable); - assertThat(item.getIcon()).isSameAs(testDrawable); + assertThat(item.getIcon()).isSameInstanceAs(testDrawable); } @Test @@ -158,7 +158,7 @@ public class RoboMenuItemTest { @Test public void setOnActionExpandListener_shouldReturnMenuItem() throws Exception { - assertThat(item.setOnActionExpandListener(listener)).isSameAs(item); + assertThat(item.setOnActionExpandListener(listener)).isSameInstanceAs(item); } static class TestOnActionExpandListener implements MenuItem.OnActionExpandListener { diff --git a/robolectric/src/test/java/org/robolectric/internal/bytecode/AndroidSandboxClassLoaderTest.java b/robolectric/src/test/java/org/robolectric/internal/bytecode/AndroidSandboxClassLoaderTest.java index d15b3d08f..cc3121be4 100644 --- a/robolectric/src/test/java/org/robolectric/internal/bytecode/AndroidSandboxClassLoaderTest.java +++ b/robolectric/src/test/java/org/robolectric/internal/bytecode/AndroidSandboxClassLoaderTest.java @@ -1,6 +1,7 @@ package org.robolectric.internal.bytecode; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import android.os.Build; import java.lang.reflect.Modifier; @@ -27,7 +28,7 @@ public class AndroidSandboxClassLoaderTest { public void shouldMakeBuildVersionIntsNonFinal() throws Exception { Class<?> versionClass = loadClass(Build.VERSION.class); int modifiers = versionClass.getDeclaredField("SDK_INT").getModifiers(); - assertThat(Modifier.isFinal(modifiers)).named("SDK_INT should be non-final").isFalse(); + assertWithMessage("SDK_INT should be non-final").that(Modifier.isFinal(modifiers)).isFalse(); } //////////////////////// diff --git a/robolectric/src/test/java/org/robolectric/internal/bytecode/ShadowWranglerUnitTest.java b/robolectric/src/test/java/org/robolectric/internal/bytecode/ShadowWranglerUnitTest.java index a083e48bd..ea0adf3d1 100644 --- a/robolectric/src/test/java/org/robolectric/internal/bytecode/ShadowWranglerUnitTest.java +++ b/robolectric/src/test/java/org/robolectric/internal/bytecode/ShadowWranglerUnitTest.java @@ -38,7 +38,7 @@ public class ShadowWranglerUnitTest { MethodSignature methodSignature = MethodSignature.parse("java/util/LinkedHashMap/eldest()Ljava/lang/Object;"); Function<Object,Object> handler = interceptors.getInterceptionHandler(methodSignature); - assertThat(handler).isNotSameAs(ShadowWrangler.DO_NOTHING_HANDLER); + assertThat(handler).isNotSameInstanceAs(ShadowWrangler.DO_NOTHING_HANDLER); } @Test @@ -122,7 +122,7 @@ public class ShadowWranglerUnitTest { public void whenChildShadowHasNarrowerSdk_createShadowFor_shouldReturnSuperShadowSometimes() throws Exception { ShadowMap shadowMap = new ShadowMap.Builder().addShadowClasses(ShadowDummyClass.class, ShadowChildOfDummyClass.class).build(); assertThat(new ShadowWrangler(shadowMap, 18, interceptors).createShadowFor(new ChildOfDummyClass())) - .isSameAs(ShadowWrangler.NO_SHADOW); + .isSameInstanceAs(ShadowWrangler.NO_SHADOW); assertThat(new ShadowWrangler(shadowMap, 19, interceptors).createShadowFor(new ChildOfDummyClass())) .isInstanceOf(ShadowDummyClass.class); assertThat(new ShadowWrangler(shadowMap, 20, interceptors).createShadowFor(new ChildOfDummyClass())) @@ -130,7 +130,7 @@ public class ShadowWranglerUnitTest { assertThat(new ShadowWrangler(shadowMap, 21, interceptors).createShadowFor(new ChildOfDummyClass())) .isInstanceOf(ShadowChildOfDummyClass.class); assertThat(new ShadowWrangler(shadowMap, 22, interceptors).createShadowFor(new ChildOfDummyClass())) - .isSameAs(ShadowWrangler.NO_SHADOW); + .isSameInstanceAs(ShadowWrangler.NO_SHADOW); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/SQLiteDatabaseTest.java b/robolectric/src/test/java/org/robolectric/shadows/SQLiteDatabaseTest.java index d8d64499c..5026fdbd8 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/SQLiteDatabaseTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/SQLiteDatabaseTest.java @@ -618,7 +618,7 @@ public class SQLiteDatabaseTest { assertThat(db.isOpen()).isFalse(); SQLiteDatabase reopened = SQLiteDatabase.openDatabase(databasePath.getAbsolutePath(), null, OPEN_READWRITE); - assertThat(reopened).isNotSameAs(db); + assertThat(reopened).isNotSameInstanceAs(db); assertThat(reopened.isOpen()).isTrue(); } diff --git a/robolectric/src/test/java/org/robolectric/shadows/SQLiteOpenHelperTest.java b/robolectric/src/test/java/org/robolectric/shadows/SQLiteOpenHelperTest.java index ad4488b63..0153979cc 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/SQLiteOpenHelperTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/SQLiteOpenHelperTest.java @@ -57,7 +57,7 @@ public class SQLiteOpenHelperTest { SQLiteDatabase db1 = helper.getReadableDatabase(); SQLiteDatabase db2 = helper.getReadableDatabase(); - assertThat(db1).isSameAs(db2); + assertThat(db1).isSameInstanceAs(db2); } @Test @@ -79,7 +79,7 @@ public class SQLiteOpenHelperTest { SQLiteDatabase db1 = helper.getWritableDatabase(); SQLiteDatabase db2 = helper.getWritableDatabase(); - assertThat(db1).isSameAs(db2); + assertThat(db1).isSameInstanceAs(db2); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java index 4ad950d5a..1be47623d 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java @@ -46,11 +46,11 @@ public class ShadowAccountManagerTest { @Test public void testGet() { assertThat(am).isNotNull(); - assertThat(am).isSameAs(AccountManager.get(ApplicationProvider.getApplicationContext())); + assertThat(am).isSameInstanceAs(AccountManager.get(ApplicationProvider.getApplicationContext())); AccountManager activityAM = AccountManager.get(ApplicationProvider.getApplicationContext()); assertThat(activityAM).isNotNull(); - assertThat(activityAM).isSameAs(am); + assertThat(activityAM).isSameInstanceAs(am); } @Test @@ -62,13 +62,13 @@ public class ShadowAccountManagerTest { shadowOf(am).addAccount(a1); assertThat(am.getAccounts()).isNotNull(); assertThat(am.getAccounts().length).isEqualTo(1); - assertThat(am.getAccounts()[0]).isSameAs(a1); + assertThat(am.getAccounts()[0]).isSameInstanceAs(a1); Account a2 = new Account("name_b", "type_b"); shadowOf(am).addAccount(a2); assertThat(am.getAccounts()).isNotNull(); assertThat(am.getAccounts().length).isEqualTo(2); - assertThat(am.getAccounts()[1]).isSameAs(a2); + assertThat(am.getAccounts()[1]).isSameInstanceAs(a2); } @Test @@ -77,7 +77,7 @@ public class ShadowAccountManagerTest { shadowOf(am).addAccount(new Account("name_2", "type_2")); shadowOf(am).addAccount(new Account("name_3", "type_3")); - assertThat(am.getAccountsByType(null)).asList().containsAllIn(am.getAccounts()); + assertThat(am.getAccountsByType(null)).asList().containsAtLeastElementsIn(am.getAccounts()); } @Test @@ -90,22 +90,22 @@ public class ShadowAccountManagerTest { Account[] accounts = am.getAccountsByType("type_a"); assertThat(accounts).isNotNull(); assertThat(accounts.length).isEqualTo(1); - assertThat(accounts[0]).isSameAs(a1); + assertThat(accounts[0]).isSameInstanceAs(a1); Account a2 = new Account("name_b", "type_b"); shadowOf(am).addAccount(a2); accounts = am.getAccountsByType("type_a"); assertThat(accounts).isNotNull(); assertThat(accounts.length).isEqualTo(1); - assertThat(accounts[0]).isSameAs(a1); + assertThat(accounts[0]).isSameInstanceAs(a1); Account a3 = new Account("name_c", "type_a"); shadowOf(am).addAccount(a3); accounts = am.getAccountsByType("type_a"); assertThat(accounts).isNotNull(); assertThat(accounts.length).isEqualTo(2); - assertThat(accounts[0]).isSameAs(a1); - assertThat(accounts[1]).isSameAs(a3); + assertThat(accounts[0]).isSameInstanceAs(a1); + assertThat(accounts[1]).isSameInstanceAs(a3); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityGroupTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityGroupTest.java index 5a649e928..d1757df3b 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityGroupTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityGroupTest.java @@ -18,6 +18,6 @@ public class ShadowActivityGroupTest { Activity activity = new Activity(); shadowOf(activityGroup).setCurrentActivity(activity); - assertThat(activityGroup.getCurrentActivity()).isSameAs(activity); + assertThat(activityGroup.getCurrentActivity()).isSameInstanceAs(activity); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityTest.java index 0ce9c3082..00726adf5 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityTest.java @@ -5,6 +5,7 @@ import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -250,7 +251,7 @@ public class ShadowActivityTest { Intent startedIntent = shadowActivity.getNextStartedActivity(); assertThat(startedIntent).isNotNull(); - assertThat(startedIntent).isSameAs(intent); + assertThat(startedIntent).isSameInstanceAs(intent); } @Test @@ -265,7 +266,7 @@ public class ShadowActivityTest { assertThat(intentForResult).isNotNull(); assertThat(shadowActivity.getNextStartedActivityForResult()).isNull(); assertThat(intentForResult.intent).isNotNull(); - assertThat(intentForResult.intent).isSameAs(intent); + assertThat(intentForResult.intent).isSameInstanceAs(intent); assertThat(intentForResult.requestCode).isEqualTo(142); } @@ -279,9 +280,9 @@ public class ShadowActivityTest { ShadowActivity.IntentForResult intentForResult = shadowActivity.peekNextStartedActivityForResult(); assertThat(intentForResult).isNotNull(); - assertThat(shadowActivity.peekNextStartedActivityForResult()).isSameAs(intentForResult); + assertThat(shadowActivity.peekNextStartedActivityForResult()).isSameInstanceAs(intentForResult); assertThat(intentForResult.intent).isNotNull(); - assertThat(intentForResult.intent).isSameAs(intent); + assertThat(intentForResult.intent).isSameInstanceAs(intent); assertThat(intentForResult.requestCode).isEqualTo(142); } @@ -500,7 +501,7 @@ public class ShadowActivityTest { for (int mode : modes) { activity.setDefaultKeyMode(mode); - assertThat(shadow.getDefaultKeymode()).named("Unexpected key mode").isEqualTo(mode); + assertWithMessage("Unexpected key mode").that(shadow.getDefaultKeymode()).isEqualTo(mode); } } @@ -558,7 +559,7 @@ public class ShadowActivityTest { activity.setContentView(contentView); FrameLayout contentViewContainer = (FrameLayout) activity.findViewById(android.R.id.content); - assertThat(contentViewContainer.getChildAt(0)).isSameAs(contentView); + assertThat(contentViewContainer.getChildAt(0)).isSameInstanceAs(contentView); } @Test @@ -604,7 +605,7 @@ public class ShadowActivityTest { assertThat(shadow.getManagedCursors()).isNotNull(); assertThat(shadow.getManagedCursors().size()).isEqualTo(1); - assertThat(shadow.getManagedCursors().get(0)).isSameAs(c); + assertThat(shadow.getManagedCursors().get(0)).isSameInstanceAs(c); activity.stopManagingCursor(c); @@ -813,7 +814,7 @@ public class ShadowActivityTest { activity.startActivityFromFragment(new Fragment(), intent, 4); ShadowActivity.IntentForResult intentForResult = shadowOf(activity).getNextStartedActivityForResult(); - assertThat(intentForResult.intent).isSameAs(intent); + assertThat(intentForResult.intent).isSameInstanceAs(intent); assertThat(intentForResult.requestCode).isEqualTo(4); } @@ -826,8 +827,8 @@ public class ShadowActivityTest { activity.startActivityFromFragment(new Fragment(), intent, 5, options); ShadowActivity.IntentForResult intentForResult = shadowOf(activity).getNextStartedActivityForResult(); - assertThat(intentForResult.intent).isSameAs(intent); - assertThat(intentForResult.options).isSameAs(options); + assertThat(intentForResult.intent).isSameInstanceAs(intent); + assertThat(intentForResult.options).isSameInstanceAs(options); assertThat(intentForResult.requestCode).isEqualTo(5); } @@ -838,7 +839,7 @@ public class ShadowActivityTest { Bundle animationBundle = ActivityOptions.makeCustomAnimation(activity, R.anim.test_anim_1, R.anim.test_anim_1).toBundle(); activity.startActivity(intent, animationBundle); - assertThat(shadowOf(activity).getNextStartedActivityForResult().options).isSameAs(animationBundle); + assertThat(shadowOf(activity).getNextStartedActivityForResult().options).isSameInstanceAs(animationBundle); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAlarmManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAlarmManagerTest.java index 9bd8eae34..0d4b40207 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAlarmManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAlarmManagerTest.java @@ -346,8 +346,8 @@ public class ShadowAlarmManagerTest { AlarmClockInfo next = alarmManager.getNextAlarmClock(); assertThat(next).isNotNull(); assertThat(next.getTriggerTime()).isEqualTo(1000); - assertThat(next.getShowIntent()).isSameAs(show); - assertThat(shadowAlarmManager.peekNextScheduledAlarm().operation).isSameAs(operation); + assertThat(next.getShowIntent()).isSameInstanceAs(show); + assertThat(shadowAlarmManager.peekNextScheduledAlarm().operation).isSameInstanceAs(operation); // Schedule another alarm sooner. PendingIntent show2 = PendingIntent.getBroadcast(context, 0, new Intent("showAction2"), 0); @@ -358,8 +358,8 @@ public class ShadowAlarmManagerTest { next = alarmManager.getNextAlarmClock(); assertThat(next).isNotNull(); assertThat(next.getTriggerTime()).isEqualTo(500); - assertThat(next.getShowIntent()).isSameAs(show2); - assertThat(shadowAlarmManager.peekNextScheduledAlarm().operation).isSameAs(operation2); + assertThat(next.getShowIntent()).isSameInstanceAs(show2); + assertThat(shadowAlarmManager.peekNextScheduledAlarm().operation).isSameInstanceAs(operation2); // Remove the soonest alarm. alarmManager.cancel(operation2); @@ -367,8 +367,8 @@ public class ShadowAlarmManagerTest { next = alarmManager.getNextAlarmClock(); assertThat(next).isNotNull(); assertThat(next.getTriggerTime()).isEqualTo(1000); - assertThat(next.getShowIntent()).isSameAs(show); - assertThat(shadowAlarmManager.peekNextScheduledAlarm().operation).isSameAs(operation); + assertThat(next.getShowIntent()).isSameInstanceAs(show); + assertThat(shadowAlarmManager.peekNextScheduledAlarm().operation).isSameInstanceAs(operation); // Remove the sole alarm. alarmManager.cancel(operation); @@ -386,7 +386,7 @@ public class ShadowAlarmManagerTest { ShadowAlarmManager.ScheduledAlarm scheduledAlarm) { assertThat(scheduledAlarm).isNotNull(); assertThat(scheduledAlarm.operation).isNotNull(); - assertThat(scheduledAlarm.operation).isSameAs(pendingIntent); + assertThat(scheduledAlarm.operation).isSameInstanceAs(pendingIntent); assertThat(scheduledAlarm.type).isEqualTo(AlarmManager.ELAPSED_REALTIME); assertThat(scheduledAlarm.triggerAtTime).isEqualTo(now); assertThat(scheduledAlarm.interval).isEqualTo(interval); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAlertDialogTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAlertDialogTest.java index 854e856b1..e15ecbaf1 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAlertDialogTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAlertDialogTest.java @@ -55,8 +55,8 @@ public class ShadowAlertDialogTest { assertEquals("title", shadowAlertDialog.getTitle()); assertThat(shadowAlertDialog.getMessage()).isEqualTo("message"); assertThat(shadowAlertDialog.isCancelable()).isTrue(); - assertThat(shadowOf(ShadowAlertDialog.getLatestAlertDialog())).isSameAs(shadowAlertDialog); - assertThat(ShadowAlertDialog.getLatestAlertDialog()).isSameAs(alert); + assertThat(shadowOf(ShadowAlertDialog.getLatestAlertDialog())).isSameInstanceAs(shadowAlertDialog); + assertThat(ShadowAlertDialog.getLatestAlertDialog()).isSameInstanceAs(alert); } @Test @@ -74,7 +74,7 @@ public class ShadowAlertDialogTest { assertThat(ShadowAlertDialog.getLatestAlertDialog()).isNull(); AlertDialog dialog = new AlertDialog.Builder(application).show(); - assertThat(ShadowAlertDialog.getLatestAlertDialog()).isSameAs(dialog); + assertThat(ShadowAlertDialog.getLatestAlertDialog()).isSameInstanceAs(dialog); } @Test @@ -148,7 +148,7 @@ public class ShadowAlertDialogTest { public void shouldSetCustomTitleView() throws Exception { AlertDialog.Builder builder = new AlertDialog.Builder(application); View view = new View(application); - assertThat(builder.setCustomTitle(view)).isSameAs(builder); + assertThat(builder.setCustomTitle(view)).isSameInstanceAs(builder); AlertDialog alert = builder.create(); assertThat(shadowOf(alert).getCustomTitleView()).isEqualTo(view); @@ -210,8 +210,8 @@ public class ShadowAlertDialogTest { assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo("title"); assertThat(shadowAlertDialog.getItems().length).isEqualTo(2); assertThat(shadowAlertDialog.getItems()[0]).isEqualTo("Aloha"); - assertThat(shadowOf(ShadowAlertDialog.getLatestAlertDialog())).isSameAs(shadowAlertDialog); - assertThat(ShadowAlertDialog.getLatestAlertDialog()).isSameAs(alert); + assertThat(shadowOf(ShadowAlertDialog.getLatestAlertDialog())).isSameInstanceAs(shadowAlertDialog); + assertThat(ShadowAlertDialog.getLatestAlertDialog()).isSameInstanceAs(alert); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAppOpsManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAppOpsManagerTest.java index 81a25062b..0d1f4f65c 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAppOpsManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAppOpsManagerTest.java @@ -284,6 +284,6 @@ public class ShadowAppOpsManagerTest { } } - assertThat(actualOps).containsAllIn(expectedOps); + assertThat(actualOps).containsAtLeastElementsIn(expectedOps); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAppTaskTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAppTaskTest.java index e8fcd4e2f..db17e6e82 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAppTaskTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAppTaskTest.java @@ -45,7 +45,7 @@ public class ShadowAppTaskTest { shadowOf(appTask).setTaskInfo(recentTaskInfo); - assertThat(appTask.getTaskInfo()).isSameAs(recentTaskInfo); + assertThat(appTask.getTaskInfo()).isSameInstanceAs(recentTaskInfo); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAppWidgetHostTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAppWidgetHostTest.java index d7bca7e5f..0bf5355c7 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAppWidgetHostTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAppWidgetHostTest.java @@ -29,7 +29,7 @@ public class ShadowAppWidgetHostTest { @Test public void shouldKnowItsContext() throws Exception { - assertThat(shadowAppWidgetHost.getContext()).isSameAs(context); + assertThat(shadowAppWidgetHost.getContext()).isSameInstanceAs(context); } @Test @@ -46,7 +46,7 @@ public class ShadowAppWidgetHostTest { @Test public void createView_shouldSetViewsContext() throws Exception { AppWidgetHostView hostView = appWidgetHost.createView(context, 0, null); - assertThat(hostView.getContext()).isSameAs(context); + assertThat(hostView.getContext()).isSameInstanceAs(context); } @Test @@ -59,12 +59,12 @@ public class ShadowAppWidgetHostTest { public void createView_shouldSetViewsAppWidgetInfo() throws Exception { AppWidgetProviderInfo info = new AppWidgetProviderInfo(); AppWidgetHostView hostView = appWidgetHost.createView(context, 0, info); - assertThat(hostView.getAppWidgetInfo()).isSameAs(info); + assertThat(hostView.getAppWidgetInfo()).isSameInstanceAs(info); } @Test public void createView_shouldSetHostViewsHost() throws Exception { AppWidgetHostView hostView = appWidgetHost.createView(context, 0, null); - assertThat(shadowOf(hostView).getHost()).isSameAs(appWidgetHost); + assertThat(shadowOf(hostView).getHost()).isSameInstanceAs(appWidgetHost); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAppWidgetHostViewTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAppWidgetHostViewTest.java index 834ae37b0..cf17b4580 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAppWidgetHostViewTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAppWidgetHostViewTest.java @@ -33,7 +33,7 @@ public class ShadowAppWidgetHostViewTest { public void shouldKnowItsAppWidgetProviderInfo() throws Exception { AppWidgetProviderInfo providerInfo = new AppWidgetProviderInfo(); appWidgetHostView.setAppWidget(0, providerInfo); - assertThat(appWidgetHostView.getAppWidgetInfo()).isSameAs(providerInfo); + assertThat(appWidgetHostView.getAppWidgetInfo()).isSameInstanceAs(providerInfo); } @Test @@ -45,6 +45,6 @@ public class ShadowAppWidgetHostViewTest { public void shouldBeAbleToHaveHostSet() throws Exception { AppWidgetHost host = new AppWidgetHost(ApplicationProvider.getApplicationContext(), 0); shadowAppWidgetHostView.setHost(host); - assertThat(shadowAppWidgetHostView.getHost()).isSameAs(host); + assertThat(shadowAppWidgetHostView.getHost()).isSameInstanceAs(host); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowApplicationTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowApplicationTest.java index e7ddc3ba1..65c752609 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowApplicationTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowApplicationTest.java @@ -68,9 +68,9 @@ public class ShadowApplicationTest { @Test public void shouldBeAContext() throws Exception { assertThat(Robolectric.setupActivity(Activity.class).getApplication()) - .isSameAs(ApplicationProvider.getApplicationContext()); + .isSameInstanceAs(ApplicationProvider.getApplicationContext()); assertThat(Robolectric.setupActivity(Activity.class).getApplication().getApplicationContext()) - .isSameAs(ApplicationProvider.getApplicationContext()); + .isSameInstanceAs(ApplicationProvider.getApplicationContext()); } @Test @@ -266,7 +266,7 @@ public class ShadowApplicationTest { context.bindService(expectedIntent, service, Context.BIND_AUTO_CREATE); context.unbindService(service); assertThat(shadowApplication.getUnboundServiceConnections()).hasSize(1); - assertThat(shadowApplication.getUnboundServiceConnections().get(0)).isSameAs(service); + assertThat(shadowApplication.getUnboundServiceConnections().get(0)).isSameInstanceAs(service); } @Test @@ -526,7 +526,7 @@ public class ShadowApplicationTest { assertThat(context.bindService(new Intent("connect"), expectedServiceConnection, 0)).isTrue(); assertThat(shadowApplication.getBoundServiceConnections()).hasSize(1); assertThat(shadowApplication.getBoundServiceConnections().get(0)) - .isSameAs(expectedServiceConnection); + .isSameInstanceAs(expectedServiceConnection); } @Test @@ -539,7 +539,7 @@ public class ShadowApplicationTest { assertThat(shadowApplication.getBoundServiceConnections()).hasSize(0); assertThat(context.bindService(serviceIntent, expectedServiceConnection, 0)).isFalse(); assertThat(shadowApplication.getBoundServiceConnections()).hasSize(1); - assertThat(shadowApplication.getBoundServiceConnections().get(0)).isSameAs(expectedServiceConnection); + assertThat(shadowApplication.getBoundServiceConnections().get(0)).isSameInstanceAs(expectedServiceConnection); } @Test @@ -554,14 +554,14 @@ public class ShadowApplicationTest { assertThat(shadowApplication.getBoundServiceConnections()).hasSize(0); assertThat(shadowApplication.getUnboundServiceConnections()).hasSize(1); assertThat(shadowApplication.getUnboundServiceConnections().get(0)) - .isSameAs(expectedServiceConnection); + .isSameInstanceAs(expectedServiceConnection); } @Test public void getThreadScheduler_shouldMatchRobolectricValue() { final ShadowApplication shadowApplication = Shadows.shadowOf(context); - assertThat(shadowApplication.getForegroundThreadScheduler()).isSameAs(Robolectric.getForegroundThreadScheduler()); - assertThat(shadowApplication.getBackgroundThreadScheduler()).isSameAs(Robolectric.getBackgroundThreadScheduler()); + assertThat(shadowApplication.getForegroundThreadScheduler()).isSameInstanceAs(Robolectric.getForegroundThreadScheduler()); + assertThat(shadowApplication.getBackgroundThreadScheduler()).isSameInstanceAs(Robolectric.getBackgroundThreadScheduler()); } @Test @@ -569,7 +569,7 @@ public class ShadowApplicationTest { Scheduler s = new Scheduler(); RuntimeEnvironment.setMasterScheduler(s); final ShadowApplication shadowApplication = Shadows.shadowOf(context); - assertThat(shadowApplication.getForegroundThreadScheduler()).isSameAs(s); + assertThat(shadowApplication.getForegroundThreadScheduler()).isSameInstanceAs(s); } @Test @@ -577,7 +577,7 @@ public class ShadowApplicationTest { Scheduler s = new Scheduler(); RuntimeEnvironment.setMasterScheduler(s); final ShadowApplication shadowApplication = Shadows.shadowOf(context); - assertThat(shadowApplication.getBackgroundThreadScheduler()).isNotSameAs(RuntimeEnvironment.getMasterScheduler()); + assertThat(shadowApplication.getBackgroundThreadScheduler()).isNotSameInstanceAs(RuntimeEnvironment.getMasterScheduler()); } @Test @@ -585,7 +585,7 @@ public class ShadowApplicationTest { Scheduler s = new Scheduler(); RuntimeEnvironment.setMasterScheduler(s); final ShadowApplication shadowApplication = Shadows.shadowOf(context); - assertThat(shadowApplication.getBackgroundThreadScheduler()).isNotSameAs(s); + assertThat(shadowApplication.getBackgroundThreadScheduler()).isNotSameInstanceAs(s); } @Test @@ -595,7 +595,7 @@ public class ShadowApplicationTest { pw.showAtLocation(new LinearLayout(context), Gravity.CENTER, 0, 0); PopupWindow latestPopupWindow = ShadowApplication.getInstance().getLatestPopupWindow(); - assertThat(latestPopupWindow).isSameAs(pw); + assertThat(latestPopupWindow).isSameInstanceAs(pw); } ///////////////////////////// diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowArrayAdapterTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowArrayAdapterTest.java index b50fbacb1..b90bc0419 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowArrayAdapterTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowArrayAdapterTest.java @@ -36,7 +36,7 @@ public class ShadowArrayAdapterTest { @Test public void verifyContext() { - assertThat(arrayAdapter.getContext()).isSameAs(context); + assertThat(arrayAdapter.getContext()).isSameInstanceAs(context); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioManagerTest.java index a36942453..aa7086d76 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioManagerTest.java @@ -30,7 +30,7 @@ public class ShadowAudioManagerTest { public void requestAudioFocus_shouldRecordArgumentsOfMostRecentCall() { assertThat(shadowOf(audioManager).getLastAudioFocusRequest()).isNull(); audioManager.requestAudioFocus(listener, 999, 888); - assertThat(shadowOf(audioManager).getLastAudioFocusRequest().listener).isSameAs(listener); + assertThat(shadowOf(audioManager).getLastAudioFocusRequest().listener).isSameInstanceAs(listener); assertThat(shadowOf(audioManager).getLastAudioFocusRequest().streamType).isEqualTo(999); assertThat(shadowOf(audioManager).getLastAudioFocusRequest().durationHint).isEqualTo(888); assertThat(shadowOf(audioManager).getLastAudioFocusRequest().audioFocusRequest).isNull(); @@ -88,7 +88,7 @@ public class ShadowAudioManagerTest { assertThat(shadowOf(audioManager).getLastAbandonedAudioFocusListener()).isNull(); audioManager.abandonAudioFocus(listener); - assertThat(shadowOf(audioManager).getLastAbandonedAudioFocusListener()).isSameAs(listener); + assertThat(shadowOf(audioManager).getLastAbandonedAudioFocusListener()).isSameInstanceAs(listener); } @Test @@ -97,7 +97,7 @@ public class ShadowAudioManagerTest { android.media.AudioFocusRequest request = new android.media.AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN).build(); audioManager.abandonAudioFocusRequest(request); - assertThat(shadowOf(audioManager).getLastAbandonedAudioFocusRequest()).isSameAs(request); + assertThat(shadowOf(audioManager).getLastAbandonedAudioFocusRequest()).isSameInstanceAs(request); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupManagerTest.java index ec3f289dd..9057c421d 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupManagerTest.java @@ -163,17 +163,9 @@ public class ShadowBackupManagerTest { } private static <T, F> Correspondence<T, F> fieldCorrespondence(String fieldName) { - return new Correspondence<T, F>() { - @Override - public boolean compare(T actual, F expected) { - return Objects.equals(ReflectionHelpers.getField(actual, fieldName), expected); - } - - @Override - public String toString() { - return "field \"" + fieldName + "\" matches"; - } - }; + return Correspondence.from((T actual, F expected) -> { + return Objects.equals(ReflectionHelpers.getField(actual, fieldName), expected); + }, "field \"" + fieldName + "\" matches"); } private static class TestRestoreObserver extends RestoreObserver {} diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowBinderTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBinderTest.java index 009a495b2..e1ae40606 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBinderTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBinderTest.java @@ -21,8 +21,8 @@ public class ShadowBinderTest { data.writeString("Hello Robolectric"); assertTrue(testBinder.transact(2, data, reply, 3)); assertThat(testBinder.code).isEqualTo(2); - assertThat(testBinder.data).isSameAs(data); - assertThat(testBinder.reply).isSameAs(reply); + assertThat(testBinder.data).isSameInstanceAs(data); + assertThat(testBinder.reply).isSameInstanceAs(reply); assertThat(testBinder.flags).isEqualTo(3); reply.readException(); assertThat(reply.readString()).isEqualTo("Hello Robolectric"); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowBitmapDrawableTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBitmapDrawableTest.java index 35aeb17f3..61cfd6ccc 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBitmapDrawableTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBitmapDrawableTest.java @@ -48,7 +48,7 @@ public class ShadowBitmapDrawableTest { public void mutate_createsDeepCopy() throws Exception { BitmapDrawable original = (BitmapDrawable) resources.getDrawable(R.drawable.an_image); Drawable mutated = original.mutate(); - assertThat(original).isNotSameAs(mutated); + assertThat(original).isNotSameInstanceAs(mutated); assertThat(mutated instanceof BitmapDrawable).isTrue(); assertThat(mutated.getIntrinsicHeight()).isEqualTo(original.getIntrinsicHeight()); assertThat(mutated.getIntrinsicWidth()).isEqualTo(original.getIntrinsicWidth()); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowBitmapTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBitmapTest.java index eb23b462a..00175d9b6 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBitmapTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBitmapTest.java @@ -284,20 +284,20 @@ public class ShadowBitmapTest { public void bitmapsAreReused() { Bitmap b = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888); Bitmap b1 = Bitmap.createBitmap(b, 0, 0, 10, 10); - assertThat(b1).isSameAs(b); + assertThat(b1).isSameInstanceAs(b); Bitmap b2 = Bitmap.createBitmap(b, 0, 0, 10, 10, null, false); - assertThat(b2).isSameAs(b); + assertThat(b2).isSameInstanceAs(b); Bitmap b3 = Bitmap.createScaledBitmap(b, 10, 10, false); - assertThat(b3).isSameAs(b); + assertThat(b3).isSameInstanceAs(b); } @Test public void equalsSizeTransformReturnsOriginal() { Bitmap b1 = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888); Bitmap b2 = Bitmap.createBitmap(b1, 0, 0, 10, 10, null, false); - assertThat(b1).isSameAs(b2); + assertThat(b1).isSameInstanceAs(b2); Bitmap b3 = Bitmap.createBitmap(b1, 0, 0, 10, 10, null, true); - assertThat(b1).isSameAs(b3); + assertThat(b1).isSameInstanceAs(b3); } @Test(expected = IllegalArgumentException.class) diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothManagerTest.java index ec4d368f1..33164f129 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothManagerTest.java @@ -21,6 +21,6 @@ public class ShadowBluetoothManagerTest { @Test public void getAdapter_shouldReturnBluetoothAdapter() { - assertThat(manager.getAdapter()).isSameAs(BluetoothAdapter.getDefaultAdapter()); + assertThat(manager.getAdapter()).isSameInstanceAs(BluetoothAdapter.getDefaultAdapter()); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowCameraManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowCameraManagerTest.java index d5213da2f..4c800d436 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowCameraManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowCameraManagerTest.java @@ -107,6 +107,6 @@ public class ShadowCameraManagerTest { public void testGetCameraCharacteristicsRecognizedCameraId() throws CameraAccessException { shadowOf(cameraManager).addCamera(CAMERA_ID_0, characteristics); - assertThat(cameraManager.getCameraCharacteristics(CAMERA_ID_0)).isSameAs(characteristics); + assertThat(cameraManager.getCameraCharacteristics(CAMERA_ID_0)).isSameInstanceAs(characteristics); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowCameraTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowCameraTest.java index a7687e4da..e919399dd 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowCameraTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowCameraTest.java @@ -83,7 +83,7 @@ public class ShadowCameraTest { public void testSetPreviewDisplay() throws Exception { SurfaceHolder previewSurfaceHolder = new TestSurfaceHolder(); camera.setPreviewDisplay(previewSurfaceHolder); - assertThat(shadowCamera.getPreviewDisplay()).isSameAs(previewSurfaceHolder); + assertThat(shadowCamera.getPreviewDisplay()).isSameInstanceAs(previewSurfaceHolder); } @Test @@ -117,7 +117,7 @@ public class ShadowCameraTest { camera.setPreviewCallback(callback); shadowCamera.invokePreviewCallback("foobar".getBytes(UTF_8)); - assertThat(callback.camera).isSameAs(camera); + assertThat(callback.camera).isSameInstanceAs(camera); assertThat(callback.data).isEqualTo("foobar".getBytes(UTF_8)); } @@ -130,7 +130,7 @@ public class ShadowCameraTest { camera.setOneShotPreviewCallback(callback); shadowCamera.invokePreviewCallback("foobar".getBytes(UTF_8)); - assertThat(callback.camera).isSameAs(camera); + assertThat(callback.camera).isSameInstanceAs(camera); assertThat(callback.data).isEqualTo("foobar".getBytes(UTF_8)); } @@ -143,7 +143,7 @@ public class ShadowCameraTest { camera.setPreviewCallbackWithBuffer(callback); shadowCamera.invokePreviewCallback("foobar".getBytes(UTF_8)); - assertThat(callback.camera).isSameAs(camera); + assertThat(callback.camera).isSameInstanceAs(camera); assertThat(callback.data).isEqualTo("foobar".getBytes(UTF_8)); } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowCanvasTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowCanvasTest.java index 6aae0dd30..c6ee36836 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowCanvasTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowCanvasTest.java @@ -274,12 +274,12 @@ public class ShadowCanvasTest { assertThat(shadowCanvas.getDrawnCircle(0).centerX).isEqualTo(1.0f); assertThat(shadowCanvas.getDrawnCircle(0).centerY).isEqualTo(2.0f); assertThat(shadowCanvas.getDrawnCircle(0).radius).isEqualTo(3.0f); - assertThat(shadowCanvas.getDrawnCircle(0).paint).isSameAs(paint0); + assertThat(shadowCanvas.getDrawnCircle(0).paint).isSameInstanceAs(paint0); assertThat(shadowCanvas.getDrawnCircle(1).centerX).isEqualTo(4.0f); assertThat(shadowCanvas.getDrawnCircle(1).centerY).isEqualTo(5.0f); assertThat(shadowCanvas.getDrawnCircle(1).radius).isEqualTo(6.0f); - assertThat(shadowCanvas.getDrawnCircle(1).paint).isSameAs(paint1); + assertThat(shadowCanvas.getDrawnCircle(1).paint).isSameInstanceAs(paint1); } @Test @@ -297,13 +297,13 @@ public class ShadowCanvasTest { assertThat(shadowCanvas.getDrawnArc(0).startAngle).isEqualTo(1f); assertThat(shadowCanvas.getDrawnArc(0).sweepAngle).isEqualTo(2f); assertThat(shadowCanvas.getDrawnArc(0).useCenter).isTrue(); - assertThat(shadowCanvas.getDrawnArc(0).paint).isSameAs(paint0); + assertThat(shadowCanvas.getDrawnArc(0).paint).isSameInstanceAs(paint0); assertThat(shadowCanvas.getDrawnArc(1).oval).isEqualTo(oval1); assertThat(shadowCanvas.getDrawnArc(1).startAngle).isEqualTo(3f); assertThat(shadowCanvas.getDrawnArc(1).sweepAngle).isEqualTo(4f); assertThat(shadowCanvas.getDrawnArc(1).useCenter).isFalse(); - assertThat(shadowCanvas.getDrawnArc(1).paint).isSameAs(paint1); + assertThat(shadowCanvas.getDrawnArc(1).paint).isSameInstanceAs(paint1); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowConnectivityManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowConnectivityManagerTest.java index 40d3af28e..7192b3c71 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowConnectivityManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowConnectivityManagerTest.java @@ -93,7 +93,7 @@ public class ShadowConnectivityManagerTest { shadowOf(connectivityManager).addNetwork(vpnNetwork, vpnNetworkInfo); NetworkInfo returnedNetworkInfo = connectivityManager.getNetworkInfo(vpnNetwork); - assertThat(returnedNetworkInfo).isSameAs(vpnNetworkInfo); + assertThat(returnedNetworkInfo).isSameInstanceAs(vpnNetworkInfo); } @Test @Config(minSdk = LOLLIPOP) @@ -251,10 +251,10 @@ public class ShadowConnectivityManagerTest { assertThat(networks).asList().hasSize(1); Network returnedNetwork = networks[0]; - assertThat(returnedNetwork).isSameAs(vpnNetwork); + assertThat(returnedNetwork).isSameInstanceAs(vpnNetwork); NetworkInfo returnedNetworkInfo = connectivityManager.getNetworkInfo(returnedNetwork); - assertThat(returnedNetworkInfo).isSameAs(vpnNetworkInfo); + assertThat(returnedNetworkInfo).isSameInstanceAs(vpnNetworkInfo); } @Test @Config(minSdk = LOLLIPOP) @@ -390,7 +390,7 @@ public class ShadowConnectivityManagerTest { public void bindProcessToNetwork_shouldGetBoundNetworkForProcess() { Network network = ShadowNetwork.newInstance(789); connectivityManager.bindProcessToNetwork(network); - assertThat(connectivityManager.getBoundNetworkForProcess()).isSameAs(network); + assertThat(connectivityManager.getBoundNetworkForProcess()).isSameInstanceAs(network); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowContentObserverTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowContentObserverTest.java index f51c7c827..8eaa292ef 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowContentObserverTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowContentObserverTest.java @@ -31,7 +31,7 @@ public class ShadowContentObserverTest { assertThat(observer.changed).isTrue(); assertThat(observer.selfChange).isTrue(); - assertThat(observer.uri).isSameAs(uri); + assertThat(observer.uri).isSameInstanceAs(uri); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowContentResolverTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowContentResolverTest.java index 1cb403c71..9b693ac1c 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowContentResolverTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowContentResolverTest.java @@ -202,7 +202,7 @@ public class ShadowContentResolverTest { assertThat(shadowContentResolver.query(null, null, null, null, null)).isNull(); BaseCursor cursor = new BaseCursor(); shadowContentResolver.setCursor(cursor); - assertThat((BaseCursor) shadowContentResolver.query(null, null, null, null, null)).isSameAs(cursor); + assertThat((BaseCursor) shadowContentResolver.query(null, null, null, null, null)).isSameInstanceAs(cursor); } @Test @@ -210,7 +210,7 @@ public class ShadowContentResolverTest { assertThat(shadowContentResolver.query(null, null, null, null, null, new CancellationSignal())).isNull(); BaseCursor cursor = new BaseCursor(); shadowContentResolver.setCursor(cursor); - assertThat((BaseCursor) shadowContentResolver.query(null, null, null, null, null, new CancellationSignal())).isSameAs(cursor); + assertThat((BaseCursor) shadowContentResolver.query(null, null, null, null, null, new CancellationSignal())).isSameInstanceAs(cursor); } @Test @@ -223,8 +223,8 @@ public class ShadowContentResolverTest { shadowContentResolver.setCursor(uri21, cursor21); shadowContentResolver.setCursor(uri22, cursor22); - assertThat((BaseCursor) shadowContentResolver.query(uri21, null, null, null, null)).isSameAs(cursor21); - assertThat((BaseCursor) shadowContentResolver.query(uri22, null, null, null, null)).isSameAs(cursor22); + assertThat((BaseCursor) shadowContentResolver.query(uri21, null, null, null, null)).isSameInstanceAs(cursor21); + assertThat((BaseCursor) shadowContentResolver.query(uri22, null, null, null, null)).isSameInstanceAs(cursor22); } @Test @@ -256,14 +256,14 @@ public class ShadowContentResolverTest { ContentProvider cp = mock(ContentProvider.class); ShadowContentResolver.registerProviderInternal(AUTHORITY, cp); final Uri uri = Uri.parse("content://" + AUTHORITY); - assertThat(contentResolver.acquireUnstableProvider(uri)).isSameAs(cp.getIContentProvider()); + assertThat(contentResolver.acquireUnstableProvider(uri)).isSameInstanceAs(cp.getIContentProvider()); } @Test public void acquireUnstableProvider_shouldReturnWithString() { ContentProvider cp = mock(ContentProvider.class); ShadowContentResolver.registerProviderInternal(AUTHORITY, cp); - assertThat(contentResolver.acquireUnstableProvider(AUTHORITY)).isSameAs(cp.getIContentProvider()); + assertThat(contentResolver.acquireUnstableProvider(AUTHORITY)).isSameInstanceAs(cp.getIContentProvider()); } @Test @@ -767,21 +767,21 @@ public class ShadowContentResolverTest { Uri uri = Uri.parse("content://" + AUTHORITY + "/whatever"); contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); assertThat(permissions).hasSize(1); - assertThat(permissions.get(0).getUri()).isSameAs(uri); + assertThat(permissions.get(0).getUri()).isSameInstanceAs(uri); assertThat(permissions.get(0).isReadPermission()).isTrue(); assertThat(permissions.get(0).isWritePermission()).isFalse(); // Take the write permission for the uri. contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION); assertThat(permissions).hasSize(1); - assertThat(permissions.get(0).getUri()).isSameAs(uri); + assertThat(permissions.get(0).getUri()).isSameInstanceAs(uri); assertThat(permissions.get(0).isReadPermission()).isTrue(); assertThat(permissions.get(0).isWritePermission()).isTrue(); // Release the read permission for the uri. contentResolver.releasePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); assertThat(permissions).hasSize(1); - assertThat(permissions.get(0).getUri()).isSameAs(uri); + assertThat(permissions.get(0).getUri()).isSameInstanceAs(uri); assertThat(permissions.get(0).isReadPermission()).isFalse(); assertThat(permissions.get(0).isWritePermission()).isTrue(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowContextWrapperTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowContextWrapperTest.java index 3ccd80cb8..26c6cf586 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowContextWrapperTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowContextWrapperTest.java @@ -423,17 +423,17 @@ public class ShadowContextWrapperTest { @Test public void shouldReturnSameApplicationEveryTime() throws Exception { Activity activity = new Activity(); - assertThat(activity.getApplication()).isSameAs(activity.getApplication()); + assertThat(activity.getApplication()).isSameInstanceAs(activity.getApplication()); - assertThat(activity.getApplication()).isSameAs(new Activity().getApplication()); + assertThat(activity.getApplication()).isSameInstanceAs(new Activity().getApplication()); } @Test public void shouldReturnSameApplicationContextEveryTime() throws Exception { Activity activity = Robolectric.setupActivity(Activity.class); - assertThat(activity.getApplicationContext()).isSameAs(activity.getApplicationContext()); + assertThat(activity.getApplicationContext()).isSameInstanceAs(activity.getApplicationContext()); - assertThat(activity.getApplicationContext()).isSameAs(Robolectric.setupActivity(Activity.class).getApplicationContext()); + assertThat(activity.getApplicationContext()).isSameInstanceAs(Robolectric.setupActivity(Activity.class).getApplicationContext()); } @Test @@ -449,9 +449,9 @@ public class ShadowContextWrapperTest { @Test public void shouldReturnSameContentResolverEveryTime() throws Exception { Activity activity = Robolectric.setupActivity(Activity.class); - assertThat(activity.getContentResolver()).isSameAs(activity.getContentResolver()); + assertThat(activity.getContentResolver()).isSameInstanceAs(activity.getContentResolver()); - assertThat(activity.getContentResolver()).isSameAs(Robolectric.setupActivity(Activity.class).getContentResolver()); + assertThat(activity.getContentResolver()).isSameInstanceAs(Robolectric.setupActivity(Activity.class).getContentResolver()); } @Test @@ -539,8 +539,8 @@ public class ShadowContextWrapperTest { private void assertSameInstanceEveryTime(String serviceName) { Activity activity1 = buildActivity(Activity.class).create().get(); Activity activity2 = buildActivity(Activity.class).create().get(); - assertThat(activity1.getSystemService(serviceName)).isSameAs(activity1.getSystemService(serviceName)); - assertThat(activity1.getSystemService(serviceName)).isSameAs(activity2.getSystemService(serviceName)); + assertThat(activity1.getSystemService(serviceName)).isSameInstanceAs(activity1.getSystemService(serviceName)); + assertThat(activity1.getSystemService(serviceName)).isSameInstanceAs(activity2.getSystemService(serviceName)); } @Test @@ -635,7 +635,7 @@ public class ShadowContextWrapperTest { final SharedPreferences pref1 = contextWrapper.getSharedPreferences("pref", Context.MODE_PRIVATE); final SharedPreferences pref2 = contextWrapper.getSharedPreferences("pref", Context.MODE_PRIVATE); - assertThat(pref1).isSameAs(pref2); + assertThat(pref1).isSameInstanceAs(pref2); } @Test @@ -643,7 +643,7 @@ public class ShadowContextWrapperTest { final SharedPreferences pref1 = contextWrapper.getSharedPreferences("pref1", Context.MODE_PRIVATE); final SharedPreferences pref2 = contextWrapper.getSharedPreferences("pref2", Context.MODE_PRIVATE); - assertThat(pref1).isNotSameAs(pref2); + assertThat(pref1).isNotSameInstanceAs(pref2); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowCookieManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowCookieManagerTest.java index 79fb9b480..f1363b99f 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowCookieManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowCookieManagerTest.java @@ -17,7 +17,7 @@ public class ShadowCookieManagerTest { @Test public void shouldGetASingletonInstance() { assertThat(CookieManager.getInstance()).isNotNull(); - assertThat(CookieManager.getInstance()).isSameAs(CookieManager.getInstance()); + assertThat(CookieManager.getInstance()).isSameInstanceAs(CookieManager.getInstance()); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowCrossProfileAppsTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowCrossProfileAppsTest.java index cae91513a..cd83bd15f 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowCrossProfileAppsTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowCrossProfileAppsTest.java @@ -296,7 +296,7 @@ public class ShadowCrossProfileAppsTest { StartedActivity startedActivity = shadowOf(crossProfileApps).peekNextStartedActivity(); assertThat(startedActivity).isEqualTo(new StartedActivity(component, userHandle1)); - assertThat(shadowOf(crossProfileApps).peekNextStartedActivity()).isSameAs(startedActivity); + assertThat(shadowOf(crossProfileApps).peekNextStartedActivity()).isSameInstanceAs(startedActivity); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowCursorAdapterTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowCursorAdapterTest.java index 2f3f4f825..d31912f26 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowCursorAdapterTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowCursorAdapterTest.java @@ -46,7 +46,7 @@ public class ShadowCursorAdapterTest { @Test public void testChangeCursor() { assertThat(adapter.getCursor()).isNotNull(); - assertThat(adapter.getCursor()).isSameAs(curs); + assertThat(adapter.getCursor()).isSameInstanceAs(curs); adapter.changeCursor(null); @@ -57,11 +57,11 @@ public class ShadowCursorAdapterTest { @Test public void testSwapCursor() { assertThat(adapter.getCursor()).isNotNull(); - assertThat(adapter.getCursor()).isSameAs(curs); + assertThat(adapter.getCursor()).isSameInstanceAs(curs); Cursor oldCursor = adapter.swapCursor(null); - assertThat(oldCursor).isSameAs(curs); + assertThat(oldCursor).isSameInstanceAs(curs); assertThat(curs.isClosed()).isFalse(); assertThat(adapter.getCursor()).isNull(); } @@ -83,7 +83,7 @@ public class ShadowCursorAdapterTest { @Test public void shouldNotErrorOnCursorChangeWhenNoFlagsAreSet() throws Exception { adapter = new TestAdapterWithFlags(curs, 0); adapter.changeCursor(database.rawQuery("SELECT * FROM table_name;", null)); - assertThat(adapter.getCursor()).isNotSameAs(curs); + assertThat(adapter.getCursor()).isNotSameInstanceAs(curs); } private static class TestAdapter extends CursorAdapter { diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowCursorWrapperTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowCursorWrapperTest.java index 786b35dd0..78bbe8f5a 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowCursorWrapperTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowCursorWrapperTest.java @@ -104,7 +104,7 @@ public class ShadowCursorWrapperTest { CursorWrapper cursorWrapper = new CursorWrapper(mockCursor); ShadowCursorWrapper shadow = Shadows.shadowOf(cursorWrapper); - assertThat(shadow.getWrappedCursor()).isSameAs(mockCursor); + assertThat(shadow.getWrappedCursor()).isSameInstanceAs(mockCursor); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowDialogTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowDialogTest.java index 9c8805c46..0c68e19d1 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowDialogTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowDialogTest.java @@ -44,7 +44,7 @@ public class ShadowDialogTest { dialog.show(); dialog.setOnDismissListener( dialogInListener -> { - assertThat(dialogInListener).isSameAs(dialog); + assertThat(dialogInListener).isSameInstanceAs(dialog); transcript.add("onDismiss called!"); }); @@ -141,7 +141,7 @@ public class ShadowDialogTest { Dialog dialog = new Dialog(context); dialog.show(); - assertThat(ShadowDialog.getLatestDialog()).isSameAs(dialog); + assertThat(ShadowDialog.getLatestDialog()).isSameInstanceAs(dialog); } @Test @@ -195,7 +195,7 @@ public class ShadowDialogTest { Dialog dialog = new Dialog(context); DialogInterface.OnCancelListener onCancelListener = dialog1 -> {}; dialog.setOnCancelListener(onCancelListener); - assertThat(onCancelListener).isSameAs(shadowOf(dialog).getOnCancelListener()); + assertThat(onCancelListener).isSameInstanceAs(shadowOf(dialog).getOnCancelListener()); } private static class TestDialog extends Dialog { diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowHandlerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowHandlerTest.java index ac8d3a2fd..c8f6f05cc 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowHandlerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowHandlerTest.java @@ -1,6 +1,7 @@ package org.robolectric.shadows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.robolectric.Shadows.shadowOf; @@ -376,12 +377,12 @@ public class ShadowHandlerTest { handler.sendMessageDelayed(msg, 200); handler.removeMessages(123); Message newMsg = handler.obtainMessage(123); - assertThat(newMsg).named("new message").isSameAs(msg); + assertWithMessage("new message").that(newMsg).isSameInstanceAs(msg); handler.sendMessageDelayed(newMsg, 400); ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); // Original implementation had a bug which caused reused messages to still // be invoked at their original post time. - assertThat(runAt).named("handledAt").containsExactly(startTime + 400L); + assertWithMessage("handledAt").that(runAt).containsExactly(startTime + 400L); } @Test @@ -400,8 +401,8 @@ public class ShadowHandlerTest { handler.removeCallbacksAndMessages(null); ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); - assertThat(wasRun[0]).named("Message").isFalse(); - assertThat(scratchRunnable.wasRun).named("Callback").isFalse(); + assertWithMessage("Message").that(wasRun[0]).isFalse(); + assertWithMessage("Callback").that(scratchRunnable.wasRun).isFalse(); } @Test @@ -449,10 +450,10 @@ public class ShadowHandlerTest { handler.removeCallbacks(r, tag2); ShadowLooper.unPauseMainLooper(); - assertThat(count[0]).named("run count").isEqualTo(1); + assertWithMessage("run count").that(count[0]).isEqualTo(1); // This assertion proves that it was the first runnable that ran, // which proves that the correctly tagged runnable was removed. - assertThat(shadowOf(handler.getLooper()).getScheduler().getCurrentTime()).named("currentTime").isEqualTo(100); + assertWithMessage("currentTime").that(shadowOf(handler.getLooper()).getScheduler().getCurrentTime()).isEqualTo(100); } @Test @@ -500,7 +501,7 @@ public class ShadowHandlerTest { h.sendEmptyMessageDelayed(0, 12000L); Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable(); - assertThat(whens).named("whens").containsExactly(startTime, startTime + 4000, startTime + 16000); + assertWithMessage("whens").that(whens).containsExactly(startTime, startTime + 4000, startTime + 16000); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowHttpResponseCacheTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowHttpResponseCacheTest.java index 48ee23120..26e88fba6 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowHttpResponseCacheTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowHttpResponseCacheTest.java @@ -29,7 +29,7 @@ public class ShadowHttpResponseCacheTest { assertThat(HttpResponseCache.getInstalled()).isNull(); HttpResponseCache cache = HttpResponseCache.install(File.createTempFile("foo", "bar"), 42); HttpResponseCache installed = HttpResponseCache.getInstalled(); - assertThat(installed).isSameAs(cache); + assertThat(installed).isSameInstanceAs(cache); assertThat(installed.maxSize()).isEqualTo(42); } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowIntentTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowIntentTest.java index d54b48ba0..6fd6db6e9 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowIntentTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowIntentTest.java @@ -348,7 +348,7 @@ public class ShadowIntentTest { assertThat(chooserIntent.getAction()).isEqualTo(Intent.ACTION_CHOOSER); assertThat(chooserIntent.getStringExtra(Intent.EXTRA_TITLE)).isEqualTo("The title"); assertThat((Intent) chooserIntent.getParcelableExtra(Intent.EXTRA_INTENT)) - .isSameAs(originalIntent); + .isSameInstanceAs(originalIntent); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowLayoutInflaterTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowLayoutInflaterTest.java index b132e436b..33b973502 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowLayoutInflaterTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowLayoutInflaterTest.java @@ -1,6 +1,7 @@ package org.robolectric.shadows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -406,9 +407,8 @@ public class ShadowLayoutInflaterTest { exception = e; } assertNotNull(exception); - assertThat(exception.getMessage()) - .named("The error message should contain the id name of the faulty button") - .contains("invalid_onclick_button"); + assertWithMessage("The error message should contain the id name of the faulty button") + .that(exception.getMessage()).contains("invalid_onclick_button"); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowListPopupWindowTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowListPopupWindowTest.java index 55362f289..5f1a68b64 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowListPopupWindowTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowListPopupWindowTest.java @@ -19,6 +19,6 @@ public class ShadowListPopupWindowTest { assertThat(ShadowListPopupWindow.getLatestListPopupWindow()).isNull(); popupWindow.setAnchorView(new View(context)); popupWindow.show(); - assertThat(ShadowListPopupWindow.getLatestListPopupWindow()).isSameAs(popupWindow); + assertThat(ShadowListPopupWindow.getLatestListPopupWindow()).isSameInstanceAs(popupWindow); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowListPreferenceTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowListPreferenceTest.java index 36a6f2f3b..93e6b4529 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowListPreferenceTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowListPreferenceTest.java @@ -27,7 +27,7 @@ public class ShadowListPreferenceTest { assertThat(listPreference.getEntries()).isNull(); listPreference.setEntries(entries); - assertThat(listPreference.getEntries()).isSameAs(entries); + assertThat(listPreference.getEntries()).isSameInstanceAs(entries); } @Test @@ -43,7 +43,7 @@ public class ShadowListPreferenceTest { assertThat(listPreference.getEntryValues()).isNull(); listPreference.setEntryValues(entryValues); - assertThat(listPreference.getEntryValues()).isSameAs(entryValues); + assertThat(listPreference.getEntryValues()).isSameInstanceAs(entryValues); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowListViewTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowListViewTest.java index e1745db6c..d3ac3833e 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowListViewTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowListViewTest.java @@ -60,10 +60,10 @@ public class ShadowListViewTest { listView.addHeaderView(view3, null, false); listView.setAdapter(new ShadowCountingAdapter(2)); assertThat(listView.getHeaderViewsCount()).isEqualTo(4); - assertThat(shadowOf(listView).getHeaderViews().get(0)).isSameAs(view0); - assertThat(shadowOf(listView).getHeaderViews().get(1)).isSameAs(view1); - assertThat(shadowOf(listView).getHeaderViews().get(2)).isSameAs(view2); - assertThat(shadowOf(listView).getHeaderViews().get(3)).isSameAs(view3); + assertThat(shadowOf(listView).getHeaderViews().get(0)).isSameInstanceAs(view0); + assertThat(shadowOf(listView).getHeaderViews().get(1)).isSameInstanceAs(view1); + assertThat(shadowOf(listView).getHeaderViews().get(2)).isSameInstanceAs(view2); + assertThat(shadowOf(listView).getHeaderViews().get(3)).isSameInstanceAs(view3); assertThat((View) listView.findViewById(0)).isNotNull(); assertThat((View) listView.findViewById(1)).isNotNull(); @@ -78,7 +78,7 @@ public class ShadowListViewTest { listView.addHeaderView(view); - assertThat((View) listView.findViewById(42)).isSameAs(view); + assertThat((View) listView.findViewById(42)).isSameInstanceAs(view); } @Test @@ -88,8 +88,8 @@ public class ShadowListViewTest { listView.addFooterView(view0); listView.addFooterView(view1); listView.setAdapter(new ShadowCountingAdapter(3)); - assertThat(shadowOf(listView).getFooterViews().get(0)).isSameAs(view0); - assertThat(shadowOf(listView).getFooterViews().get(1)).isSameAs(view1); + assertThat(shadowOf(listView).getFooterViews().get(0)).isSameInstanceAs(view0); + assertThat(shadowOf(listView).getFooterViews().get(1)).isSameInstanceAs(view1); } @Test @@ -99,7 +99,7 @@ public class ShadowListViewTest { listView.addFooterView(view); - assertThat((View) listView.findViewById(42)).isSameAs(view); + assertThat((View) listView.findViewById(42)).isSameInstanceAs(view); } @Test @@ -112,8 +112,8 @@ public class ShadowListViewTest { prepareListWithThreeItems(); assertThat(listView.getChildCount()).isEqualTo(5); - assertThat(listView.getChildAt(0)).isSameAs(header); - assertThat(listView.getChildAt(4)).isSameAs(footer); + assertThat(listView.getChildAt(0)).isSameInstanceAs(header); + assertThat(listView.getChildAt(4)).isSameInstanceAs(footer); } @Test @@ -156,7 +156,7 @@ public class ShadowListViewTest { public void findItemContainingText_shouldFindChildByString() throws Exception { ShadowListView shadowListView = prepareListWithThreeItems(); View item1 = shadowListView.findItemContainingText("Item 1"); - assertThat(item1).isSameAs(listView.getChildAt(1)); + assertThat(item1).isSameInstanceAs(listView.getChildAt(1)); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowLogTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowLogTest.java index ace202301..be87d0c92 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowLogTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowLogTest.java @@ -276,7 +276,7 @@ public class ShadowLogTest { @Test public void getLogs_shouldReturnCopy() { - assertThat(ShadowLog.getLogs()).isNotSameAs(ShadowLog.getLogs()); + assertThat(ShadowLog.getLogs()).isNotSameInstanceAs(ShadowLog.getLogs()); assertThat(ShadowLog.getLogs()).isEqualTo(ShadowLog.getLogs()); } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowLooperTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowLooperTest.java index 17dbe9f54..1302072e0 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowLooperTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowLooperTest.java @@ -1,6 +1,7 @@ package org.robolectric.shadows; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static org.robolectric.Shadows.shadowOf; import android.app.Application; @@ -70,34 +71,34 @@ public class ShadowLooperTest { @Test public void mainLooper_andMyLooper_shouldBeSame_onMainThread() { - assertThat(Looper.myLooper()).isSameAs(Looper.getMainLooper()); + assertThat(Looper.myLooper()).isSameInstanceAs(Looper.getMainLooper()); } @Test public void differentThreads_getDifferentLoopers() { HandlerThread ht = getHandlerThread(); - assertThat(ht.getLooper()).isNotSameAs(Looper.getMainLooper()); + assertThat(ht.getLooper()).isNotSameInstanceAs(Looper.getMainLooper()); } @Test public void mainLooperThread_shouldBeTestThread() { - assertThat(Looper.getMainLooper().getThread()).isSameAs(Thread.currentThread()); + assertThat(Looper.getMainLooper().getThread()).isSameInstanceAs(Thread.currentThread()); } @Test public void shadowMainLooper_shouldBeShadowOfMainLooper() { - assertThat(ShadowLooper.getShadowMainLooper()).isSameAs(shadowOf(Looper.getMainLooper())); + assertThat(ShadowLooper.getShadowMainLooper()).isSameInstanceAs(shadowOf(Looper.getMainLooper())); } @Test public void getLooperForThread_returnsLooperForAThreadThatHasOne() throws InterruptedException { QuitThread qt = getQuitThread(); - assertThat(ShadowLooper.getLooperForThread(qt)).isSameAs(qt.looper); + assertThat(ShadowLooper.getLooperForThread(qt)).isSameInstanceAs(qt.looper); } @Test public void getLooperForThread_returnsLooperForMainThread() { - assertThat(ShadowLooper.getLooperForThread(Thread.currentThread())).isSameAs(Looper.getMainLooper()); + assertThat(ShadowLooper.getLooperForThread(Thread.currentThread())).isSameInstanceAs(Looper.getMainLooper()); } @Test @@ -110,11 +111,11 @@ public class ShadowLooperTest { } }, 2000); - assertThat(wasRun[0]).named("first").isFalse(); + assertWithMessage("first").that(wasRun[0]).isFalse(); ShadowLooper.idleMainLooper(1999); - assertThat(wasRun[0]).named("second").isFalse(); + assertWithMessage("second").that(wasRun[0]).isFalse(); ShadowLooper.idleMainLooper(1); - assertThat(wasRun[0]).named("last").isTrue(); + assertWithMessage("last").that(wasRun[0]).isTrue(); } @Test @@ -141,19 +142,19 @@ public class ShadowLooperTest { HandlerThread ht = getHandlerThread(); Looper looper = ht.getLooper(); looper.quit(); - assertThat(shadowOf(looper).hasQuit()).named("hasQuit").isTrue(); - assertThat(shadowOf(looper).post(new Runnable() { + assertWithMessage("hasQuit").that(shadowOf(looper).hasQuit()).isTrue(); + assertWithMessage("postAtFrontOfQueue").that(shadowOf(looper).post(new Runnable() { @Override public void run() { } - }, 0)).named("post").isFalse(); + }, 0)).isFalse(); assertThat(shadowOf(looper).postAtFrontOfQueue(new Runnable() { @Override public void run() { } - })).named("postAtFrontOfQueue").isFalse(); - assertThat(shadowOf(looper).getScheduler().areAnyRunnable()).named("areAnyRunnable").isFalse(); + })).isFalse(); + assertWithMessage("areAnyRunnable").that(shadowOf(looper).getScheduler().areAnyRunnable()).isFalse(); } @Test @@ -167,18 +168,18 @@ public class ShadowLooperTest { } }, 0); looper.quit(); - assertThat(shadowOf(looper).hasQuit()).named("hasQuit").isTrue(); - assertThat(shadowOf(looper).getScheduler().areAnyRunnable()).named("areAnyRunnable").isFalse(); - assertThat(shadowOf(looper.getQueue()).getHead()).named("queue").isNull(); + assertWithMessage("hasQuit").that(shadowOf(looper).hasQuit()).isTrue(); + assertWithMessage("areAnyRunnable").that(shadowOf(looper).getScheduler().areAnyRunnable()).isFalse(); + assertWithMessage("queue").that(shadowOf(looper.getQueue()).getHead()).isNull(); } @Test public void threadShouldContinue_whenLooperQuits() throws InterruptedException { QuitThread test = getQuitThread(); - assertThat(test.hasContinued).named("beforeJoin").isFalse(); + assertWithMessage("beforeJoin").that(test.hasContinued).isFalse(); test.looper.quit(); test.join(5000); - assertThat(test.hasContinued).named("afterJoin").isTrue(); + assertWithMessage("afterJoin").that(test.hasContinued).isTrue(); } @Test @@ -193,10 +194,10 @@ public class ShadowLooperTest { public void run() { } }); - assertThat(shadowOf(looper.getQueue()).getHead()).named("queue").isNotNull(); + assertWithMessage("queue").that(shadowOf(looper.getQueue()).getHead()).isNotNull(); sLooper.reset(); - assertThat(sLooper.getScheduler().areAnyRunnable()).named("areAnyRunnable").isFalse(); - assertThat(shadowOf(looper.getQueue()).getHead()).named("queue").isNull(); + assertWithMessage("areAnyRunnable").that(sLooper.getScheduler().areAnyRunnable()).isFalse(); + assertWithMessage("queue").that(shadowOf(looper.getQueue()).getHead()).isNull(); } @Test @@ -206,21 +207,21 @@ public class ShadowLooperTest { ShadowLooper sLooper = shadowOf(looper); Scheduler old = sLooper.getScheduler(); sLooper.reset(); - assertThat(old).isNotSameAs(sLooper.getScheduler()); + assertThat(old).isNotSameInstanceAs(sLooper.getScheduler()); } @Test public void resetThreadLoopers_shouldQuitAllNonMainLoopers() throws InterruptedException { QuitThread test = getQuitThread(); - assertThat(test.hasContinued).named("hasContinued:before").isFalse(); + assertWithMessage("hasContinued:before").that(test.hasContinued).isFalse(); ShadowLooper.resetThreadLoopers(); test.join(5000); - assertThat(test.hasContinued).named("hasContinued:after").isTrue(); + assertWithMessage("hasContinued:after").that(test.hasContinued).isTrue(); } @Test(timeout = 1000) public void whenTestHarnessUsesDifferentThread_shouldStillHaveMainLooper() { - assertThat(Looper.myLooper()).isSameAs(Looper.getMainLooper()); + assertThat(Looper.myLooper()).isSameInstanceAs(Looper.getMainLooper()); } @Test @@ -246,7 +247,7 @@ public class ShadowLooperTest { Looper mainLooper = Looper.getMainLooper(); Scheduler scheduler = shadowOf(mainLooper).getScheduler(); shadowOf(mainLooper).quit = true; - assertThat(ApplicationProvider.getApplicationContext().getMainLooper()).isSameAs(mainLooper); + assertThat(ApplicationProvider.getApplicationContext().getMainLooper()).isSameInstanceAs(mainLooper); Scheduler s = new Scheduler(); RuntimeEnvironment.setMasterScheduler(s); ShadowLooper.resetThreadLoopers(); @@ -258,11 +259,11 @@ public class ShadowLooperTest { Context.class, ((Application) ApplicationProvider.getApplicationContext()).getBaseContext())); - assertThat(Looper.getMainLooper()).named("Looper.getMainLooper()").isSameAs(mainLooper); - assertThat(application.getMainLooper()).named("app.getMainLooper()").isSameAs(mainLooper); - assertThat(shadowOf(mainLooper).getScheduler()).named("scheduler").isNotSameAs(scheduler); - assertThat(shadowOf(mainLooper).getScheduler()).named("scheduler").isSameAs(s); - assertThat(shadowOf(mainLooper).hasQuit()).named("quit").isFalse(); + assertWithMessage("Looper.getMainLooper()").that(Looper.getMainLooper()).isSameInstanceAs(mainLooper); + assertWithMessage("app.getMainLooper()").that(application.getMainLooper()).isSameInstanceAs(mainLooper); + assertWithMessage("scheduler").that(shadowOf(mainLooper).getScheduler()).isNotSameInstanceAs(scheduler); + assertWithMessage("scheduler").that(shadowOf(mainLooper).getScheduler()).isSameInstanceAs(s); + assertWithMessage("quit").that(shadowOf(mainLooper).hasQuit()).isFalse(); } @Test @@ -281,7 +282,7 @@ public class ShadowLooperTest { Scheduler s = new Scheduler(); RuntimeEnvironment.setMasterScheduler(s); sMainLooper.reset(); - assertThat(sMainLooper.getScheduler()).isSameAs(s); + assertThat(sMainLooper.getScheduler()).isSameInstanceAs(s); } @Test @@ -291,7 +292,7 @@ public class ShadowLooperTest { Scheduler s = new Scheduler(); RuntimeEnvironment.setMasterScheduler(s); sMainLooper.reset(); - assertThat(sMainLooper.getScheduler()).isSameAs(s); + assertThat(sMainLooper.getScheduler()).isSameInstanceAs(s); } @Test @@ -300,8 +301,8 @@ public class ShadowLooperTest { ShadowLooper sLooper = shadowOf(ht.getLooper()); Scheduler old = sLooper.getScheduler(); sLooper.reset(); - assertThat(sLooper.getScheduler()).isNotSameAs(old); - assertThat(sLooper.getScheduler()).isNotSameAs(RuntimeEnvironment.getMasterScheduler()); + assertThat(sLooper.getScheduler()).isNotSameInstanceAs(old); + assertThat(sLooper.getScheduler()).isNotSameInstanceAs(RuntimeEnvironment.getMasterScheduler()); } @Test @@ -312,7 +313,7 @@ public class ShadowLooperTest { RuntimeEnvironment.setMasterScheduler(s); setAdvancedScheduling(); sLooper.reset(); - assertThat(sLooper.getScheduler()).isSameAs(s); + assertThat(sLooper.getScheduler()).isSameInstanceAs(s); } @Test @@ -352,7 +353,7 @@ public class ShadowLooperTest { t.start(); try { t.join(1000); - assertThat(myLooper.get()).isSameAs(Looper.getMainLooper()); + assertThat(myLooper.get()).isSameInstanceAs(Looper.getMainLooper()); } finally { RuntimeEnvironment.setMainThread(Thread.currentThread()); } @@ -373,20 +374,20 @@ public class ShadowLooperTest { backgroundThread.start(); backgroundThread.join(); - assertThat(mainLooperAtomicReference.get()).named("mainLooper").isSameAs(Looper.getMainLooper()); + assertWithMessage("mainLooper").that(mainLooperAtomicReference.get()).isSameInstanceAs(Looper.getMainLooper()); } @Test public void schedulerOnAnotherLooper_shouldNotBeMaster_byDefault() { HandlerThread ht = getHandlerThread(); - assertThat(shadowOf(ht.getLooper()).getScheduler()).isNotSameAs(RuntimeEnvironment.getMasterScheduler()); + assertThat(shadowOf(ht.getLooper()).getScheduler()).isNotSameInstanceAs(RuntimeEnvironment.getMasterScheduler()); } @Test public void schedulerOnAnotherLooper_shouldBeMaster_ifAdvancedSchedulingEnabled() { setAdvancedScheduling(); HandlerThread ht = getHandlerThread(); - assertThat(shadowOf(ht.getLooper()).getScheduler()).isSameAs(RuntimeEnvironment.getMasterScheduler()); + assertThat(shadowOf(ht.getLooper()).getScheduler()).isSameInstanceAs(RuntimeEnvironment.getMasterScheduler()); } @Test @@ -409,17 +410,17 @@ public class ShadowLooperTest { events.add("handler2"); } }, 200); - assertThat(events).named("start").isEmpty(); + assertWithMessage("start").that(events).isEmpty(); Scheduler s = ShadowLooper.getShadowMainLooper().getScheduler(); - assertThat(s).isSameAs(RuntimeEnvironment.getMasterScheduler()); - assertThat(s).isSameAs(shadowOf(ht.getLooper()).getScheduler()); + assertThat(s).isSameInstanceAs(RuntimeEnvironment.getMasterScheduler()); + assertThat(s).isSameInstanceAs(shadowOf(ht.getLooper()).getScheduler()); final long startTime = s.getCurrentTime(); s.runOneTask(); - assertThat(events).named("firstEvent").containsExactly("handler1"); - assertThat(s.getCurrentTime()).named("firstEvent:time").isEqualTo(100 + startTime); + assertWithMessage("firstEvent").that(events).containsExactly("handler1"); + assertWithMessage("firstEvent:time").that(s.getCurrentTime()).isEqualTo(100 + startTime); s.runOneTask(); - assertThat(events).named("secondEvent").containsExactly("handler1", "handler2"); - assertThat(s.getCurrentTime()).named("secondEvent:time").isEqualTo(200 + startTime); + assertWithMessage("secondEvent").that(events).containsExactly("handler1", "handler2"); + assertWithMessage("secondEvent:time").that(s.getCurrentTime()).isEqualTo(200 + startTime); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaMetadataRetrieverTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaMetadataRetrieverTest.java index 40d771f05..ce6227e1c 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaMetadataRetrieverTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaMetadataRetrieverTest.java @@ -4,6 +4,7 @@ import static android.media.MediaMetadataRetriever.METADATA_KEY_ALBUM; import static android.media.MediaMetadataRetriever.METADATA_KEY_ARTIST; import static android.media.MediaMetadataRetriever.METADATA_KEY_TITLE; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static org.junit.Assert.fail; import static org.robolectric.shadows.ShadowMediaMetadataRetriever.addException; import static org.robolectric.shadows.ShadowMediaMetadataRetriever.addFrame; @@ -112,7 +113,7 @@ public class ShadowMediaMetadataRetrieverTest { addException(toDataSource(path2), new IllegalArgumentException()); retriever.setDataSource(path); assertThat(retriever.extractMetadata(METADATA_KEY_ARTIST)).isEqualTo("The Rolling Stones"); - assertThat(retriever.getFrameAtTime(1)).isSameAs(bitmap); + assertThat(retriever.getFrameAtTime(1)).isSameInstanceAs(bitmap); try { retriever2.setDataSource(path2); fail("Expected exception"); @@ -135,9 +136,9 @@ public class ShadowMediaMetadataRetrieverTest { retriever.setDataSource(path); fail("Expected exception"); } catch (Exception caught) { - assertThat(caught).isSameAs(e); - assertThat(e.getStackTrace()[0].getClassName()) - .named("Stack trace should originate in Shadow") + assertThat(caught).isSameInstanceAs(e); + assertWithMessage("Stack trace should originate in Shadow") + .that(e.getStackTrace()[0].getClassName()) .isEqualTo(ShadowMediaMetadataRetriever.class.getName()); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaPlayerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaPlayerTest.java index 0ea781136..f9a5674b4 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaPlayerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaPlayerTest.java @@ -2,6 +2,7 @@ package org.robolectric.shadows; import static android.os.Build.VERSION_CODES.O; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static org.junit.Assert.fail; import static org.robolectric.Shadows.shadowOf; import static org.robolectric.shadows.ShadowMediaPlayer.State.END; @@ -157,7 +158,7 @@ public class ShadowMediaPlayerTest { DataSource ds = toDataSource("dummy"); ShadowMediaPlayer.addMediaInfo(ds, info); mediaPlayer.setDataSource("dummy"); - assertThat(shadowMediaPlayer.getDataSource()).named("dataSource").isEqualTo(ds); + assertWithMessage("dataSource").that(shadowMediaPlayer.getDataSource()).isEqualTo(ds); } @Test @@ -169,8 +170,8 @@ public class ShadowMediaPlayerTest { mediaPlayer.setDataSource(ApplicationProvider.getApplicationContext(), uri, headers); - assertThat(shadowMediaPlayer.getSourceUri()).named("sourceUri").isSameAs(uri); - assertThat(shadowMediaPlayer.getDataSource()).named("dataSource").isEqualTo(ds); + assertWithMessage("sourceUri").that(shadowMediaPlayer.getSourceUri()).isSameInstanceAs(uri); + assertWithMessage("dataSource").that(shadowMediaPlayer.getDataSource()).isEqualTo(ds); } @Test @@ -184,8 +185,8 @@ public class ShadowMediaPlayerTest { DataSource ds = toDataSource(fd, 23, 524); ShadowMediaPlayer.addMediaInfo(ds, info); mediaPlayer.setDataSource(fd, 23, 524); - assertThat(shadowMediaPlayer.getSourceUri()).named("sourceUri").isNull(); - assertThat(shadowMediaPlayer.getDataSource()).named("dataSource") + assertWithMessage("sourceUri").that(shadowMediaPlayer.getSourceUri()).isNull(); + assertWithMessage("dataSource").that(shadowMediaPlayer.getDataSource()) .isEqualTo(ds); } finally { is.close(); @@ -209,7 +210,7 @@ public class ShadowMediaPlayerTest { assertThat(shadowMediaPlayer.getState()).isEqualTo(PREPARING); Mockito.verifyZeroInteractions(preparedListener); scheduler.advanceToLastPostedRunnable(); - assertThat(scheduler.getCurrentTime()).named("currentTime").isEqualTo( + assertWithMessage("currentTime").that(scheduler.getCurrentTime()).isEqualTo( startTime + delay); assertThat(shadowMediaPlayer.getState()).isEqualTo(PREPARED); Mockito.verify(preparedListener).onPrepared(mediaPlayer); @@ -227,20 +228,20 @@ public class ShadowMediaPlayerTest { final long startTime = scheduler.getCurrentTime(); mediaPlayer.prepareAsync(); - assertThat(scheduler.getCurrentTime()).named("currentTime").isEqualTo( + assertWithMessage("currentTime").that(scheduler.getCurrentTime()).isEqualTo( startTime); - assertThat(shadowMediaPlayer.getState()).isSameAs(PREPARING); + assertThat(shadowMediaPlayer.getState()).isSameInstanceAs(PREPARING); Mockito.verifyZeroInteractions(preparedListener); shadowMediaPlayer.invokePreparedListener(); - assertThat(shadowMediaPlayer.getState()).isSameAs(PREPARED); + assertThat(shadowMediaPlayer.getState()).isSameInstanceAs(PREPARED); Mockito.verify(preparedListener).onPrepared(mediaPlayer); Mockito.verifyNoMoreInteractions(preparedListener); } @Test public void testDefaultPreparationDelay() { - assertThat(info.getPreparationDelay()) - .named("preparationDelay").isEqualTo(0); + assertWithMessage("preparationDelay").that(info.getPreparationDelay()) + .isEqualTo(0); } @Test @@ -587,7 +588,7 @@ public class ShadowMediaPlayerTest { @Test public void testInitialAudioSessionIdIsNotZero() { - assertThat(mediaPlayer.getAudioSessionId()).named("initial audioSessionId") + assertWithMessage("initial audioSessionId").that(mediaPlayer.getAudioSessionId()) .isNotEqualTo(0); } @@ -750,7 +751,7 @@ public class ShadowMediaPlayerTest { } Mockito.verifyZeroInteractions(errorListener); final State finalState = shadowMediaPlayer.getState(); - assertThat(finalState).isSameAs(ERROR); + assertThat(finalState).isSameInstanceAs(ERROR); scheduler.unPause(); Mockito.verify(errorListener).onError(mediaPlayer, what, extra); Mockito.reset(errorListener); @@ -779,7 +780,7 @@ public class ShadowMediaPlayerTest { Throwable cause = e.getTargetException(); assertThat(cause).isInstanceOf(eClass); final State finalState = shadowMediaPlayer.getState(); - assertThat(finalState).isSameAs(state); + assertThat(finalState).isSameInstanceAs(state); } assertThat(success).isFalse(); } @@ -834,9 +835,9 @@ public class ShadowMediaPlayerTest { mediaPlayer.seekTo(-1); shadowMediaPlayer.invokeSeekCompleteListener(); - assertThat(mediaPlayer.getCurrentPosition()).named( - "Current postion while " + state).isEqualTo(0); - assertThat(shadowMediaPlayer.getState()).named("Final state " + state) + assertWithMessage("Current postion while " + state).that(mediaPlayer.getCurrentPosition()) + .isEqualTo(0); + assertWithMessage("Final state " + state).that(shadowMediaPlayer.getState()) .isEqualTo(state); } } @@ -852,9 +853,9 @@ public class ShadowMediaPlayerTest { mediaPlayer.seekTo(1001); shadowMediaPlayer.invokeSeekCompleteListener(); - assertThat(mediaPlayer.getCurrentPosition()).named( - "Current postion while " + state).isEqualTo(1000); - assertThat(shadowMediaPlayer.getState()).named("Final state " + state) + assertWithMessage("Current postion while " + state).that(mediaPlayer.getCurrentPosition()) + .isEqualTo(1000); + assertWithMessage("Final state " + state).that(shadowMediaPlayer.getState()) .isEqualTo(state); } } @@ -1054,16 +1055,16 @@ public class ShadowMediaPlayerTest { // invoked automatically by the shadow player itself. shadowMediaPlayer.setSeekDelay(-1); - assertThat(shadowMediaPlayer.getPendingSeek()).named("pendingSeek before") + assertWithMessage("pendingSeek before").that(shadowMediaPlayer.getPendingSeek()) .isEqualTo(-1); int[] positions = { 0, 5, 2, 999 }; int prevPos = 0; for (int position : positions) { mediaPlayer.seekTo(position); - assertThat(shadowMediaPlayer.getPendingSeek()).named("pendingSeek") + assertWithMessage("pendingSeek").that(shadowMediaPlayer.getPendingSeek()) .isEqualTo(position); - assertThat(mediaPlayer.getCurrentPosition()).named("pendingSeekCurrentPos") + assertWithMessage("pendingSeekCurrentPos").that(mediaPlayer.getCurrentPosition()) .isEqualTo(prevPos); shadowMediaPlayer.invokeSeekCompleteListener(); @@ -1156,7 +1157,7 @@ public class ShadowMediaPlayerTest { shadowMediaPlayer.doStart(); assertThat(shadowMediaPlayer.isReallyPlaying()).isTrue(); assertThat(shadowMediaPlayer.getCurrentPositionRaw()).isEqualTo(0); - assertThat(shadowMediaPlayer.getState()).isSameAs(IDLE); + assertThat(shadowMediaPlayer.getState()).isSameInstanceAs(IDLE); scheduler.advanceBy(100); assertThat(shadowMediaPlayer.getCurrentPositionRaw()).isEqualTo(100); @@ -1164,7 +1165,7 @@ public class ShadowMediaPlayerTest { shadowMediaPlayer.doStop(); assertThat(shadowMediaPlayer.isReallyPlaying()).isFalse(); assertThat(shadowMediaPlayer.getCurrentPositionRaw()).isEqualTo(100); - assertThat(shadowMediaPlayer.getState()).isSameAs(IDLE); + assertThat(shadowMediaPlayer.getState()).isSameInstanceAs(IDLE); scheduler.advanceBy(50); assertThat(shadowMediaPlayer.getCurrentPositionRaw()).isEqualTo(100); @@ -1182,7 +1183,7 @@ public class ShadowMediaPlayerTest { scheduler.advanceBy(1); Mockito.verify(errorListener).onError(mediaPlayer, 1, 3); - assertThat(shadowMediaPlayer.getState()).isSameAs(ERROR); + assertThat(shadowMediaPlayer.getState()).isSameInstanceAs(ERROR); assertThat(scheduler.advanceToLastPostedRunnable()).isFalse(); assertThat(shadowMediaPlayer.getCurrentPositionRaw()).isEqualTo(500); } @@ -1304,7 +1305,7 @@ public class ShadowMediaPlayerTest { Mockito.verify(errorListener).onError(mediaPlayer, 32, 22); assertThat(scheduler.size()).isEqualTo(0); assertThat(shadowMediaPlayer.getCurrentPositionRaw()).isEqualTo(675); - assertThat(shadowMediaPlayer.getState()).isSameAs(ERROR); + assertThat(shadowMediaPlayer.getState()).isSameInstanceAs(ERROR); Mockito.verifyZeroInteractions(e2); } @@ -1387,8 +1388,7 @@ public class ShadowMediaPlayerTest { scheduler.advanceBy(700); Mockito.verifyZeroInteractions(completionListener); - assertThat(mediaPlayer.getCurrentPosition()).named(state.toString()) - .isEqualTo(200); + assertWithMessage(state.toString()).that(mediaPlayer.getCurrentPosition()).isEqualTo(200); } } @@ -1410,9 +1410,8 @@ public class ShadowMediaPlayerTest { ShadowMediaPlayer.CreateListener createListener = Mockito .mock(ShadowMediaPlayer.CreateListener.class); ShadowMediaPlayer.setCreateListener(createListener); - assertThat(ShadowMediaPlayer.createListener) - .named("createListener") - .isSameAs(createListener); + assertWithMessage("createListener").that(ShadowMediaPlayer.createListener) + .isSameInstanceAs(createListener); DataSource dummy = toDataSource("stuff"); IOException e = new IOException(); addException(dummy, e); @@ -1422,18 +1421,16 @@ public class ShadowMediaPlayerTest { shadowMediaPlayer.setDataSource(dummy); fail("Expected exception thrown"); } catch (IOException e2) { - assertThat(e2).named("thrown exception").isSameAs(e); + assertWithMessage("thrown exception").that(e2).isSameInstanceAs(e); } // Check that the mediaInfo was cleared shadowMediaPlayer.doSetDataSource(defaultSource); - assertThat(shadowMediaPlayer.getMediaInfo()).named("mediaInfo:before").isNotNull(); + assertWithMessage("mediaInfo:before").that(shadowMediaPlayer.getMediaInfo()).isNotNull(); ShadowMediaPlayer.resetStaticState(); // Check that the listener was cleared. - assertThat(ShadowMediaPlayer.createListener) - .named("createListener") - .isNull(); + assertWithMessage("createListener").that(ShadowMediaPlayer.createListener).isNull(); // Check that the mediaInfo was cleared. try { @@ -1461,9 +1458,9 @@ public class ShadowMediaPlayerTest { mediaPlayer.setDataSource("dummy"); fail("Expected exception thrown"); } catch (Exception caught) { - assertThat(caught).isSameAs(e); - assertThat(e.getStackTrace()[0].getClassName()) - .named("Stack trace should originate in Shadow") + assertThat(caught).isSameInstanceAs(e); + assertWithMessage("Stack trace should originate in Shadow") + .that(e.getStackTrace()[0].getClassName()) .isEqualTo(ShadowMediaPlayer.class.getName()); } } @@ -1477,12 +1474,12 @@ public class ShadowMediaPlayerTest { mediaPlayer.setDataSource("dummy"); fail("Expected exception thrown"); } catch (Exception caught) { - assertThat(caught).isSameAs(e); - assertThat(e.getStackTrace()[0].getClassName()) - .named("Stack trace should originate in Shadow") + assertThat(caught).isSameInstanceAs(e); + assertWithMessage("Stack trace should originate in Shadow") + .that(e.getStackTrace()[0].getClassName()) .isEqualTo(ShadowMediaPlayer.class.getName()); - assertThat(shadowMediaPlayer.getState()).named( - "State after " + e + " thrown should be unchanged").isSameAs(IDLE); + assertWithMessage("State after " + e + " thrown should be unchanged") + .that(shadowMediaPlayer.getState()).isSameInstanceAs(IDLE); } } @@ -1492,9 +1489,9 @@ public class ShadowMediaPlayerTest { mediaPlayer.setDataSource("some unspecified data source"); fail("Expected exception thrown"); } catch (IllegalArgumentException a) { - assertThat(a.getMessage()).named("assertionMessage") + assertWithMessage("assertionMessage").that(a.getMessage()) .contains("addException"); - assertThat(a.getMessage()).named("assertionMessage") + assertWithMessage("assertionMessage").that(a.getMessage()) .contains("addMediaInfo"); } catch (Exception e) { throw new RuntimeException("Unexpected exception", e); @@ -1517,7 +1514,7 @@ public class ShadowMediaPlayerTest { new MediaEvent() { @Override public void run(MediaPlayer mp, ShadowMediaPlayer smp) { - assertThat(Looper.myLooper()).isSameAs(Looper.getMainLooper()); + assertThat(Looper.myLooper()).isSameInstanceAs(Looper.getMainLooper()); ran.set(true); } }); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaRecorderTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaRecorderTest.java index 85b02fa61..c11fff4bf 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaRecorderTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaRecorderTest.java @@ -69,7 +69,7 @@ public class ShadowMediaRecorderTest { Camera c = Shadow.newInstanceOf(Camera.class); mediaRecorder.setCamera(c); assertThat(shadowMediaRecorder.getCamera()).isNotNull(); - assertThat(shadowMediaRecorder.getCamera()).isSameAs(c); + assertThat(shadowMediaRecorder.getCamera()).isSameInstanceAs(c); } @Test @@ -92,7 +92,7 @@ public class ShadowMediaRecorderTest { TestErrorListener listener = new TestErrorListener(); mediaRecorder.setOnErrorListener(listener); assertThat(shadowMediaRecorder.getErrorListener()).isNotNull(); - assertThat(shadowMediaRecorder.getErrorListener()).isSameAs((MediaRecorder.OnErrorListener) listener); + assertThat(shadowMediaRecorder.getErrorListener()).isSameInstanceAs((MediaRecorder.OnErrorListener) listener); } @Test @@ -101,7 +101,7 @@ public class ShadowMediaRecorderTest { TestInfoListener listener = new TestInfoListener(); mediaRecorder.setOnInfoListener(listener); assertThat(shadowMediaRecorder.getInfoListener()).isNotNull(); - assertThat(shadowMediaRecorder.getInfoListener()).isSameAs((MediaRecorder.OnInfoListener) listener); + assertThat(shadowMediaRecorder.getInfoListener()).isSameInstanceAs((MediaRecorder.OnInfoListener) listener); } @Test @@ -129,7 +129,7 @@ public class ShadowMediaRecorderTest { Surface surface = Shadow.newInstanceOf(Surface.class); mediaRecorder.setPreviewDisplay(surface); assertThat(shadowMediaRecorder.getPreviewDisplay()).isNotNull(); - assertThat(shadowMediaRecorder.getPreviewDisplay()).isSameAs(surface); + assertThat(shadowMediaRecorder.getPreviewDisplay()).isSameInstanceAs(surface); assertThat(shadowMediaRecorder.getState()).isEqualTo(ShadowMediaRecorder.STATE_DATA_SOURCE_CONFIGURED); } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowMessageQueueTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowMessageQueueTest.java index 9fa24e898..66794c41f 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowMessageQueueTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowMessageQueueTest.java @@ -2,6 +2,7 @@ package org.robolectric.shadows; import static android.os.Build.VERSION_CODES.M; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static org.junit.Assert.fail; import static org.robolectric.Shadows.shadowOf; import static org.robolectric.util.ReflectionHelpers.ClassParameter.from; @@ -74,7 +75,7 @@ public class ShadowMessageQueueTest { @Test public void test_setGetHead() { shadowQueue.setHead(testMessage); - assertThat(shadowQueue.getHead()).named("getHead()").isSameAs(testMessage); + assertWithMessage("getHead()").that(shadowQueue.getHead()).isSameInstanceAs(testMessage); } private boolean enqueueMessage(Message msg, long when) { @@ -95,50 +96,50 @@ public class ShadowMessageQueueTest { @Test public void enqueueMessage_setsHead() { enqueueMessage(testMessage, 100); - assertThat(shadowQueue.getHead()).named("head").isSameAs(testMessage); + assertWithMessage("head").that(shadowQueue.getHead()).isSameInstanceAs(testMessage); } @Test public void enqueueMessage_returnsTrue() { - assertThat(enqueueMessage(testMessage, 100)).named("retval").isTrue(); + assertWithMessage("retval").that(enqueueMessage(testMessage, 100)).isTrue(); } @Test public void enqueueMessage_setsWhen() { enqueueMessage(testMessage, 123); - assertThat(testMessage.getWhen()).named("when").isEqualTo(123); + assertWithMessage("when").that(testMessage.getWhen()).isEqualTo(123); } @Test public void enqueueMessage_returnsFalse_whenQuitting() { setField(queue, quitField, true); - assertThat(enqueueMessage(testMessage, 1)).named("enqueueMessage()").isFalse(); + assertWithMessage("enqueueMessage()").that(enqueueMessage(testMessage, 1)).isFalse(); } @Test public void enqueueMessage_doesntSchedule_whenQuitting() { setField(queue, quitField, true); enqueueMessage(testMessage, 1); - assertThat(scheduler.size()).named("scheduler_size").isEqualTo(0); + assertWithMessage("scheduler_size").that(scheduler.size()).isEqualTo(0); } @Test public void enqueuedMessage_isSentToHandler() { enqueueMessage(testMessage, 200); scheduler.advanceTo(199); - assertThat(handler.handled).named("handled:before").isEmpty(); + assertWithMessage("handled:before").that(handler.handled).isEmpty(); scheduler.advanceTo(200); - assertThat(handler.handled).named("handled:after").containsExactly(testMessage); + assertWithMessage("handled:after").that(handler.handled).containsExactly(testMessage); } @Test public void removedMessage_isNotSentToHandler() { enqueueMessage(testMessage, 200); - assertThat(scheduler.size()).named("scheduler size:before").isEqualTo(1); + assertWithMessage("scheduler size:before").that(scheduler.size()).isEqualTo(1); removeMessages(handler, testMessage.what, null); scheduler.advanceToLastPostedRunnable(); - assertThat(scheduler.size()).named("scheduler size:after").isEqualTo(0); - assertThat(handler.handled).named("handled").isEmpty(); + assertWithMessage("scheduler size:after").that(scheduler.size()).isEqualTo(0); + assertWithMessage("handled").that(handler.handled).isEmpty(); } @Test @@ -147,7 +148,7 @@ public class ShadowMessageQueueTest { Message m2 = handler.obtainMessage(2); enqueueMessage(m2, 0); scheduler.advanceToLastPostedRunnable(); - assertThat(handler.handled).named("handled").containsExactly(m2, testMessage); + assertWithMessage("handled").that(handler.handled).containsExactly(m2, testMessage); } @Test @@ -156,9 +157,9 @@ public class ShadowMessageQueueTest { @Override public void handleMessage(Message msg) { boolean inUse = callInstanceMethod(msg, "isInUse"); - assertThat(inUse).named(msg.what + ":inUse").isTrue(); + assertWithMessage(msg.what + ":inUse").that(inUse).isTrue(); Message next = getField(msg, "next"); - assertThat(next).named(msg.what + ":next").isNull(); + assertWithMessage(msg.what + ":next").that(next).isNull(); } }; Message msg = handler.obtainMessage(1); @@ -168,11 +169,11 @@ public class ShadowMessageQueueTest { scheduler.advanceToNextPostedRunnable(); // Check that it's been properly recycled. - assertThat(msg.what).named("msg.what").isEqualTo(0); + assertWithMessage("msg.what").that(msg.what).isEqualTo(0); scheduler.advanceToNextPostedRunnable(); - assertThat(msg2.what).named("msg2.what").isEqualTo(0); + assertWithMessage("msg2.what").that(msg2.what).isEqualTo(0); } @Test @@ -181,11 +182,11 @@ public class ShadowMessageQueueTest { Message msg2 = handler.obtainMessage(5678); handler.sendMessage(msg); handler.sendMessage(msg2); - assertThat(handler.hasMessages(1234)).named("before-1234").isTrue(); - assertThat(handler.hasMessages(5678)).named("before-5678").isTrue(); + assertWithMessage("before-1234").that(handler.hasMessages(1234)).isTrue(); + assertWithMessage("before-5678").that(handler.hasMessages(5678)).isTrue(); shadowQueue.reset(); - assertThat(handler.hasMessages(1234)).named("after-1234").isFalse(); - assertThat(handler.hasMessages(5678)).named("after-5678").isFalse(); + assertWithMessage("after-1234").that(handler.hasMessages(1234)).isFalse(); + assertWithMessage("after-5678").that(handler.hasMessages(5678)).isFalse(); } @Test @@ -221,7 +222,7 @@ public class ShadowMessageQueueTest { scheduler.advanceToLastPostedRunnable(); removeSyncBarrier(queue, token); assertThat(shadowQueue.getHead()).isNull(); - assertThat(handler.handled).named("handled:after").containsExactly(testMessage); + assertWithMessage("handled:after").that(handler.handled).containsExactly(testMessage); } @Test @@ -233,7 +234,7 @@ public class ShadowMessageQueueTest { assertThat(shadowQueue.getHead()).isEqualTo(testMessage); scheduler.advanceToLastPostedRunnable(); assertThat(shadowQueue.getHead()).isNull(); - assertThat(handler.handled).named("handled:after").containsExactly(testMessage); + assertWithMessage("handled:after").that(handler.handled).containsExactly(testMessage); } @Test @@ -243,7 +244,7 @@ public class ShadowMessageQueueTest { scheduler.advanceToLastPostedRunnable(); removeSyncBarrier(queue, token); assertThat(shadowQueue.getHead()).isNull(); - assertThat(handler.handled).named("handled:after").containsExactly(testMessage); + assertWithMessage("handled:after").that(handler.handled).containsExactly(testMessage); } private static void removeSyncBarrier(MessageQueue queue, int token) { diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowMessageTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowMessageTest.java index 8699bd549..ad05cd0e1 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowMessageTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowMessageTest.java @@ -3,6 +3,7 @@ package org.robolectric.shadows; import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static org.robolectric.Shadows.shadowOf; import android.os.Bundle; @@ -175,7 +176,7 @@ public class ShadowMessageTest { Message msg2 = Message.obtain(); ShadowMessage sMsg = shadowOf(msg); sMsg.setNext(msg2); - assertThat(sMsg.getNext()).isSameAs(msg2); + assertThat(sMsg.getNext()).isSameInstanceAs(msg2); } @Test @@ -227,9 +228,9 @@ public class ShadowMessageTest { Message msg = Message.obtain(h, 234); msg.sendToTarget(); Scheduler scheduler = Robolectric.getForegroundThreadScheduler(); - assertThat(scheduler.size()).named("before recycle").isEqualTo(1); + assertWithMessage("before recycle").that(scheduler.size()).isEqualTo(1); shadowOf(msg).recycleUnchecked(); - assertThat(scheduler.size()).named("after recycle").isEqualTo(0); + assertWithMessage("after recycle").that(scheduler.size()).isEqualTo(0); } @Test @@ -237,11 +238,11 @@ public class ShadowMessageTest { Message dummy1 = Message.obtain(); shadowOf(dummy1).recycleUnchecked(); Message dummy2 = Message.obtain(); - assertThat(dummy2).named("before resetting").isSameAs(dummy1); + assertWithMessage("before resetting").that(dummy2).isSameInstanceAs(dummy1); shadowOf(dummy2).recycleUnchecked(); ShadowMessage.reset(); dummy1 = Message.obtain(); - assertThat(dummy1).named("after resetting").isNotSameAs(dummy2); + assertWithMessage("after resetting").that(dummy1).isNotSameInstanceAs(dummy2); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowNfcAdapterTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowNfcAdapterTest.java index 3dbbb9a21..88be8dc3c 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowNfcAdapterTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowNfcAdapterTest.java @@ -36,7 +36,7 @@ public class ShadowNfcAdapterTest { final NfcAdapter adapter = NfcAdapter.getDefaultAdapter(activity); adapter.setNdefPushMessageCallback(callback, activity); - assertThat(shadowOf(adapter).getNdefPushMessageCallback()).isSameAs(callback); + assertThat(shadowOf(adapter).getNdefPushMessageCallback()).isSameInstanceAs(callback); } @Test @@ -47,7 +47,7 @@ public class ShadowNfcAdapterTest { final NfcAdapter adapter = NfcAdapter.getDefaultAdapter(activity); adapter.setOnNdefPushCompleteCallback(callback, activity); - assertThat(shadowOf(adapter).getOnNdefPushCompleteCallback()).isSameAs(callback); + assertThat(shadowOf(adapter).getOnNdefPushCompleteCallback()).isSameInstanceAs(callback); } @Test @@ -128,7 +128,7 @@ public class ShadowNfcAdapterTest { adapter.setNdefPushMessage(message, activity); - assertThat(shadowOf(adapter).getNdefPushMessage()).isSameAs(message); + assertThat(shadowOf(adapter).getNdefPushMessage()).isSameInstanceAs(message); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowNotificationTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowNotificationTest.java index e7e51163e..5c326c881 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowNotificationTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowNotificationTest.java @@ -18,6 +18,6 @@ public class ShadowNotificationTest { PendingIntent pendingIntent = PendingIntent.getActivity(application, 0, new Intent(), 0); Notification notification = new Notification(); notification.setLatestEventInfo(application, "title", "content", pendingIntent); - assertThat(notification.contentIntent).isSameAs(pendingIntent); + assertThat(notification.contentIntent).isSameInstanceAs(pendingIntent); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowPackageManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPackageManagerTest.java index 46a8688d3..e5bf914e6 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPackageManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPackageManagerTest.java @@ -1302,8 +1302,8 @@ public class ShadowPackageManagerTest { shadowPackageManager.addActivityIcon(i, d); - assertThat(packageManager.getActivityIcon(i)).isSameAs(d); - assertThat(packageManager.getActivityIcon(i.getComponent())).isSameAs(d); + assertThat(packageManager.getActivityIcon(i)).isSameInstanceAs(d); + assertThat(packageManager.getActivityIcon(i.getComponent())).isSameInstanceAs(d); } @Test @@ -1593,7 +1593,7 @@ public class ShadowPackageManagerTest { Drawable drawable = ShadowDrawable.createFromStream(new ByteArrayInputStream(new byte[0]), "my_source"); shadowPackageManager.addDrawableResolution("com.example.foo", 4334, drawable); Drawable actual = packageManager.getDrawable("com.example.foo", 4334, null); - assertThat(actual).isSameAs(drawable); + assertThat(actual).isSameInstanceAs(drawable); } @Test @@ -2473,7 +2473,7 @@ public class ShadowPackageManagerTest { packageManager .getApplicationInfo(packageName, PackageManager.GET_SHARED_LIBRARY_FILES) .loadUnbadgedIcon(packageManager)) - .isSameAs(d); + .isSameInstanceAs(d); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowPaintTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPaintTest.java index 7921b6fa8..a6303ea12 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPaintTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPaintTest.java @@ -73,6 +73,6 @@ public class ShadowPaintTest { @Test public void createPaintFromPaint() throws Exception { Paint origPaint = new Paint(); - assertThat(new Paint(origPaint).getTextLocale()).isSameAs(origPaint.getTextLocale()); + assertThat(new Paint(origPaint).getTextLocale()).isSameInstanceAs(origPaint.getTextLocale()); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowPendingIntentTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPendingIntentTest.java index 4d666abeb..ae191c07e 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPendingIntentTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPendingIntentTest.java @@ -209,7 +209,7 @@ public class ShadowPendingIntentTest { Intent first = shadowActivity.getNextStartedActivity(); assertThat(first).isNotNull(); - assertThat(first).isSameAs(intents[0]); + assertThat(first).isSameInstanceAs(intents[0]); assertThat(first.hasExtra("TEST")).isFalse(); } @@ -251,7 +251,7 @@ public class ShadowPendingIntentTest { Intent i = shadowOf(otherContext).getNextStartedActivity(); assertThat(i).isNotNull(); - assertThat(i).isSameAs(intent); + assertThat(i).isSameInstanceAs(intent); assertThat(i.hasExtra("TEST")).isFalse(); } @@ -292,7 +292,7 @@ public class ShadowPendingIntentTest { Intent identical = new Intent(); PendingIntent saved = PendingIntent.getActivity(context, 99, identical, FLAG_NO_CREATE); assertThat(saved).isNotNull(); - assertThat(intent).isSameAs(shadowOf(saved).getSavedIntent()); + assertThat(intent).isSameInstanceAs(shadowOf(saved).getSavedIntent()); } @Test @@ -303,7 +303,7 @@ public class ShadowPendingIntentTest { Intent updated = new Intent(); PendingIntent saved = PendingIntent.getActivity(context, 99, updated, 0); assertThat(saved).isNotNull(); - assertThat(intent).isSameAs(shadowOf(saved).getSavedIntent()); + assertThat(intent).isSameInstanceAs(shadowOf(saved).getSavedIntent()); } @Test @@ -329,7 +329,7 @@ public class ShadowPendingIntentTest { PendingIntent saved = PendingIntent.getActivities(context, 99, identicalIntents, FLAG_NO_CREATE); assertThat(saved).isNotNull(); - assertThat(intents).isSameAs(shadowOf(saved).getSavedIntents()); + assertThat(intents).isSameInstanceAs(shadowOf(saved).getSavedIntents()); } @Test @@ -340,7 +340,7 @@ public class ShadowPendingIntentTest { Intent[] identicalIntents = {new Intent(Intent.ACTION_VIEW), new Intent(Intent.ACTION_PICK)}; PendingIntent saved = PendingIntent.getActivities(context, 99, identicalIntents, 0); assertThat(saved).isNotNull(); - assertThat(intents).isSameAs(shadowOf(saved).getSavedIntents()); + assertThat(intents).isSameInstanceAs(shadowOf(saved).getSavedIntents()); } @Test @@ -365,7 +365,7 @@ public class ShadowPendingIntentTest { Intent identical = new Intent(); PendingIntent saved = PendingIntent.getBroadcast(context, 99, identical, FLAG_NO_CREATE); assertThat(saved).isNotNull(); - assertThat(intent).isSameAs(shadowOf(saved).getSavedIntent()); + assertThat(intent).isSameInstanceAs(shadowOf(saved).getSavedIntent()); } @Test @@ -376,7 +376,7 @@ public class ShadowPendingIntentTest { Intent identical = new Intent(); PendingIntent saved = PendingIntent.getBroadcast(context, 99, identical, 0); assertThat(saved).isNotNull(); - assertThat(intent).isSameAs(shadowOf(saved).getSavedIntent()); + assertThat(intent).isSameInstanceAs(shadowOf(saved).getSavedIntent()); } @Test @@ -401,7 +401,7 @@ public class ShadowPendingIntentTest { Intent identical = new Intent(); PendingIntent saved = PendingIntent.getService(context, 99, identical, FLAG_NO_CREATE); assertThat(saved).isNotNull(); - assertThat(intent).isSameAs(shadowOf(saved).getSavedIntent()); + assertThat(intent).isSameInstanceAs(shadowOf(saved).getSavedIntent()); } @Test @@ -412,7 +412,7 @@ public class ShadowPendingIntentTest { Intent identical = new Intent(); PendingIntent saved = PendingIntent.getService(context, 99, identical, 0); assertThat(saved).isNotNull(); - assertThat(intent).isSameAs(shadowOf(saved).getSavedIntent()); + assertThat(intent).isSameInstanceAs(shadowOf(saved).getSavedIntent()); } @Test @@ -442,7 +442,7 @@ public class ShadowPendingIntentTest { PendingIntent saved = PendingIntent.getForegroundService(context, 99, identical, FLAG_NO_CREATE); assertThat(saved).isNotNull(); - assertThat(intent).isSameAs(shadowOf(saved).getSavedIntent()); + assertThat(intent).isSameInstanceAs(shadowOf(saved).getSavedIntent()); } @Test @@ -454,7 +454,7 @@ public class ShadowPendingIntentTest { Intent identical = new Intent(); PendingIntent saved = PendingIntent.getForegroundService(context, 99, identical, 0); assertThat(saved).isNotNull(); - assertThat(intent).isSameAs(shadowOf(saved).getSavedIntent()); + assertThat(intent).isSameInstanceAs(shadowOf(saved).getSavedIntent()); } @Test @@ -550,7 +550,7 @@ public class ShadowPendingIntentTest { Intent intent = new Intent(); PendingIntent oneShot = PendingIntent.getService(context, 0, intent, FLAG_ONE_SHOT); PendingIntent notOneShot = PendingIntent.getService(context, 0, intent, FLAG_UPDATE_CURRENT); - assertThat(oneShot).isNotSameAs(notOneShot); + assertThat(oneShot).isNotSameInstanceAs(notOneShot); } @Test @@ -558,7 +558,7 @@ public class ShadowPendingIntentTest { Intent intent = new Intent(); PendingIntent immutable = PendingIntent.getService(context, 0, intent, FLAG_IMMUTABLE); PendingIntent notImmutable = PendingIntent.getService(context, 0, intent, FLAG_UPDATE_CURRENT); - assertThat(immutable).isNotSameAs(notImmutable); + assertThat(immutable).isNotSameInstanceAs(notImmutable); } @Test @@ -568,7 +568,7 @@ public class ShadowPendingIntentTest { // Same type, requestCode and Intent action implies equality. assertThat(PendingIntent.getActivity(context, 99, new Intent("activity"), FLAG_NO_CREATE)) - .isSameAs(pendingIntent); + .isSameInstanceAs(pendingIntent); // Mismatched Intent action implies inequality. assertThat(PendingIntent.getActivity(context, 99, new Intent("activity2"), FLAG_NO_CREATE)) @@ -592,15 +592,15 @@ public class ShadowPendingIntentTest { Intent[] forward = {new Intent("activity"), new Intent("activity2")}; assertThat(PendingIntent.getActivities(context, 99, forward, FLAG_NO_CREATE)) - .isSameAs(pendingIntent); + .isSameInstanceAs(pendingIntent); Intent[] irrelevant = {new Intent("irrelevant"), new Intent("activity2")}; assertThat(PendingIntent.getActivities(context, 99, irrelevant, FLAG_NO_CREATE)) - .isSameAs(pendingIntent); + .isSameInstanceAs(pendingIntent); Intent single = new Intent("activity2"); assertThat(PendingIntent.getActivity(context, 99, single, FLAG_NO_CREATE)) - .isSameAs(pendingIntent); + .isSameInstanceAs(pendingIntent); Intent[] backward = {new Intent("activity2"), new Intent("activity")}; assertThat(PendingIntent.getActivities(context, 99, backward, FLAG_NO_CREATE)).isNull(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowPhoneWindowTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPhoneWindowTest.java index b534341fa..47be7c412 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPhoneWindowTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPhoneWindowTest.java @@ -34,6 +34,6 @@ public class ShadowPhoneWindowTest { public void getBackgroundDrawable() throws Exception { Drawable drawable = activity.getResources().getDrawable(android.R.drawable.bottom_bar); window.setBackgroundDrawable(drawable); - assertThat(shadowOf(window).getBackgroundDrawable()).isSameAs(drawable); + assertThat(shadowOf(window).getBackgroundDrawable()).isSameInstanceAs(drawable); } }
\ No newline at end of file diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowPowerManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPowerManagerTest.java index 04fac0957..c93e58621 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPowerManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPowerManagerTest.java @@ -72,13 +72,13 @@ public class ShadowPowerManagerTest { lock.acquire(); assertThat(ShadowPowerManager.getLatestWakeLock()).isNotNull(); - assertThat(ShadowPowerManager.getLatestWakeLock()).isSameAs(lock); + assertThat(ShadowPowerManager.getLatestWakeLock()).isSameInstanceAs(lock); assertThat(lock.isHeld()).isTrue(); lock.release(); assertThat(ShadowPowerManager.getLatestWakeLock()).isNotNull(); - assertThat(ShadowPowerManager.getLatestWakeLock()).isSameAs(lock); + assertThat(ShadowPowerManager.getLatestWakeLock()).isSameInstanceAs(lock); assertThat(lock.isHeld()).isFalse(); ShadowPowerManager.reset(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowPreferenceGroupTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPreferenceGroupTest.java index 5decabda6..f21c21fda 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPreferenceGroupTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPreferenceGroupTest.java @@ -85,8 +85,8 @@ public class ShadowPreferenceGroupTest { group.addPreference(pref1); group.addPreference(pref2); - assertThat(group.getPreference(0)).isSameAs(pref1); - assertThat(group.getPreference(1)).isSameAs(pref2); + assertThat(group.getPreference(0)).isSameInstanceAs(pref1); + assertThat(group.getPreference(1)).isSameInstanceAs(pref2); } @Test @@ -132,8 +132,8 @@ public class ShadowPreferenceGroupTest { group.addPreference(pref1); group.addPreference(pref2); - assertThat(group.findPreference(pref1.getKey())).isSameAs(pref1); - assertThat(group.findPreference(pref2.getKey())).isSameAs(pref2); + assertThat(group.findPreference(pref1.getKey())).isSameInstanceAs(pref1); + assertThat(group.findPreference(pref2.getKey())).isSameInstanceAs(pref2); } @Test @@ -145,7 +145,7 @@ public class ShadowPreferenceGroupTest { group.addPreference(pref1); group.addPreference(group2); - assertThat(group.findPreference(pref2.getKey())).isSameAs(pref2); + assertThat(group.findPreference(pref2.getKey())).isSameInstanceAs(pref2); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowRatingBarTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowRatingBarTest.java index 75313c73f..f50d4a9fd 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowRatingBarTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowRatingBarTest.java @@ -28,7 +28,7 @@ public class ShadowRatingBarTest { @Test public void testOnSeekBarChangedListener() { - assertThat(ratingBar.getOnRatingBarChangeListener()).isSameAs(listener); + assertThat(ratingBar.getOnRatingBarChangeListener()).isSameInstanceAs(listener); ratingBar.setOnRatingBarChangeListener(null); assertThat(ratingBar.getOnRatingBarChangeListener()).isNull(); } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowRemoteCallbackListTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowRemoteCallbackListTest.java index d75330c59..ad68b0296 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowRemoteCallbackListTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowRemoteCallbackListTest.java @@ -20,7 +20,7 @@ public class ShadowRemoteCallbackListTest { fooRemoteCallbackList.beginBroadcast(); - assertThat(fooRemoteCallbackList.getBroadcastItem(0)).isSameAs(callback); + assertThat(fooRemoteCallbackList.getBroadcastItem(0)).isSameInstanceAs(callback); } public static class Foo implements IInterface { diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSQLiteConnectionTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSQLiteConnectionTest.java index a1206a9a8..e7fc1ed80 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSQLiteConnectionTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSQLiteConnectionTest.java @@ -2,6 +2,7 @@ package org.robolectric.shadows; import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static org.junit.Assert.fail; import static org.robolectric.shadows.ShadowSQLiteConnection.convertSQLWithLocalizedUnicodeCollator; @@ -94,39 +95,39 @@ public class ShadowSQLiteConnectionTest { @Test public void nativeOpen_addsConnectionToPool() { assertThat(conn).isNotNull(); - assertThat(conn.isOpen()).named("open").isTrue(); + assertWithMessage("open").that(conn.isOpen()).isTrue(); } @Test public void nativeClose_closesConnection() { ShadowSQLiteConnection.nativeClose(ptr); - assertThat(conn.isOpen()).named("open").isFalse(); + assertWithMessage("open").that(conn.isOpen()).isFalse(); } @Test public void reset_closesConnection() { ShadowSQLiteConnection.reset(); - assertThat(conn.isOpen()).named("open").isFalse(); + assertWithMessage("open").that(conn.isOpen()).isFalse(); } @Test public void reset_clearsConnectionCache() { final Map<Long, SQLiteConnection> connectionsMap = ReflectionHelpers.getField(CONNECTIONS, "connectionsMap"); - assertThat(connectionsMap).named("connections before").isNotEmpty(); + assertWithMessage("connections before").that(connectionsMap).isNotEmpty(); ShadowSQLiteConnection.reset(); - assertThat(connectionsMap).named("connections after").isEmpty(); + assertWithMessage("connections after").that(connectionsMap).isEmpty(); } @Test public void reset_clearsStatementCache() { final Map<Long, SQLiteStatement> statementsMap = ReflectionHelpers.getField(CONNECTIONS, "statementsMap"); - assertThat(statementsMap).named("statements before").isNotEmpty(); + assertWithMessage("statements before").that(statementsMap).isNotEmpty(); ShadowSQLiteConnection.reset(); - assertThat(statementsMap).named("statements after").isEmpty(); + assertWithMessage("statements after").that(statementsMap).isEmpty(); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSeekBarTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSeekBarTest.java index c462c600a..2ef14a7da 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSeekBarTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSeekBarTest.java @@ -31,7 +31,7 @@ public class ShadowSeekBarTest { @Test public void testOnSeekBarChangedListener() { - assertThat(shadow.getOnSeekBarChangeListener()).isSameAs(listener); + assertThat(shadow.getOnSeekBarChangeListener()).isSameInstanceAs(listener); seekBar.setOnSeekBarChangeListener(null); assertThat(shadow.getOnSeekBarChangeListener()).isNull(); } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSensorManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSensorManagerTest.java index 29484ccac..7e65ddb9a 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSensorManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSensorManagerTest.java @@ -155,7 +155,7 @@ public class ShadowSensorManagerTest { public void getSensor_shouldBeConfigurable() { Sensor sensor = ShadowSensor.newInstance(Sensor.TYPE_ACCELEROMETER); shadowOf(sensorManager).addSensor(sensor); - assertThat(sensor).isSameAs(sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)); + assertThat(sensor).isSameInstanceAs(sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowServiceTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowServiceTest.java index 9493d8aad..0deb481e3 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowServiceTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowServiceTest.java @@ -74,9 +74,9 @@ public class ShadowServiceTest { public void startForeground() { Notification n = notBuilder.build(); service.startForeground(23, n); - assertThat(shadowOf(service).getLastForegroundNotification()).isSameAs(n); + assertThat(shadowOf(service).getLastForegroundNotification()).isSameInstanceAs(n); assertThat(shadowOf(service).getLastForegroundNotificationId()).isEqualTo(23); - assertThat(shadowOf(nm2).getNotification(23)).isSameAs(n); + assertThat(shadowOf(nm2).getNotification(23)).isSameInstanceAs(n); assertThat(n.flags & Notification.FLAG_FOREGROUND_SERVICE).isNotEqualTo(0); } @@ -103,7 +103,7 @@ public class ShadowServiceTest { Notification n = notBuilder.build(); service.startForeground(21, n); service.stopForeground(false); - assertThat(shadowOf(nm2).getNotification(21)).isSameAs(n); + assertThat(shadowOf(nm2).getNotification(21)).isSameInstanceAs(n); } /** diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowShapeDrawableTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowShapeDrawableTest.java index ca02d623c..25fd9541d 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowShapeDrawableTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowShapeDrawableTest.java @@ -16,6 +16,6 @@ public class ShadowShapeDrawableTest { ShapeDrawable shapeDrawable = new ShapeDrawable(); Paint paint = shapeDrawable.getPaint(); assertNotNull(paint); - assertThat(shapeDrawable.getPaint()).isSameAs(paint); + assertThat(shapeDrawable.getPaint()).isSameInstanceAs(paint); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSimpleCursorAdapterTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSimpleCursorAdapterTest.java index eb3cb741f..115d57b86 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSimpleCursorAdapterTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSimpleCursorAdapterTest.java @@ -31,7 +31,7 @@ public class ShadowSimpleCursorAdapterTest { adapter.changeCursor(cursor); - assertThat(adapter.getCursor()).isSameAs(cursor); + assertThat(adapter.getCursor()).isSameInstanceAs(cursor); } @Test @@ -43,7 +43,7 @@ public class ShadowSimpleCursorAdapterTest { adapter.swapCursor(cursor); - assertThat(adapter.getCursor()).isSameAs(cursor); + assertThat(adapter.getCursor()).isSameInstanceAs(cursor); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSmsManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSmsManagerTest.java index 1ee2455c8..a6b59fb65 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSmsManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSmsManagerTest.java @@ -90,8 +90,8 @@ public class ShadowSmsManagerTest { assertThat(params.getScAddress()).isEqualTo(scAddress); assertThat(params.getDestinationPort()).isEqualTo(destPort); assertThat(params.getData()).isEqualTo(data); - assertThat(params.getSentIntent()).isSameAs(sentIntent); - assertThat(params.getDeliveryIntent()).isSameAs(deliveryIntent); + assertThat(params.getSentIntent()).isSameInstanceAs(sentIntent); + assertThat(params.getDeliveryIntent()).isSameInstanceAs(deliveryIntent); } @Test(expected = IllegalArgumentException.class) diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSpannableStringTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSpannableStringTest.java index 31443c1b2..0d93e7e23 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSpannableStringTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSpannableStringTest.java @@ -23,7 +23,7 @@ public class ShadowSpannableStringTest { @Test public void testToString() { - assertThat(spanStr.toString()).isSameAs(TEST_STRING); + assertThat(spanStr.toString()).isSameInstanceAs(TEST_STRING); } @Test @@ -47,7 +47,7 @@ public class ShadowSpannableStringTest { Object[] spans = spanStr.getSpans(0, TEST_STRING.length(), Object.class); assertThat(spans).isNotNull(); assertThat(spans.length).isEqualTo(1); - assertThat((UnderlineSpan) spans[0]).isSameAs(s2); + assertThat((UnderlineSpan) spans[0]).isSameInstanceAs(s2); } @Test @@ -65,35 +65,35 @@ public class ShadowSpannableStringTest { spans = spanStr.getSpans(0, TEST_STRING.length(), URLSpan.class); assertThat(spans).isNotNull(); assertThat(spans.length).isEqualTo(1); - assertThat((URLSpan) spans[0]).isSameAs(s1); + assertThat((URLSpan) spans[0]).isSameInstanceAs(s1); spans = spanStr.getSpans(11, 35, Object.class); assertThat(spans).isNotNull(); assertThat(spans.length).isEqualTo(1); - assertThat((UnderlineSpan) spans[0]).isSameAs(s2); + assertThat((UnderlineSpan) spans[0]).isSameInstanceAs(s2); spans = spanStr.getSpans(21, 35, Object.class); assertThat(spans).isNotNull(); assertThat(spans.length).isEqualTo(1); - assertThat((UnderlineSpan) spans[0]).isSameAs(s2); + assertThat((UnderlineSpan) spans[0]).isSameInstanceAs(s2); spans = spanStr.getSpans(5, 15, Object.class); assertThat(spans).isNotNull(); assertThat(spans.length).isEqualTo(1); - assertThat((URLSpan) spans[0]).isSameAs(s1); + assertThat((URLSpan) spans[0]).isSameInstanceAs(s1); } private void assertBothSpans(URLSpan s1, UnderlineSpan s2) { Object[] spans = spanStr.getSpans(0, TEST_STRING.length(), Object.class); if (spans[0] instanceof URLSpan) { - assertThat((URLSpan) spans[0]).isSameAs(s1); + assertThat((URLSpan) spans[0]).isSameInstanceAs(s1); } else { - assertThat((UnderlineSpan) spans[0]).isSameAs(s2); + assertThat((UnderlineSpan) spans[0]).isSameInstanceAs(s2); } if (spans[1] instanceof UnderlineSpan) { - assertThat((UnderlineSpan) spans[1]).isSameAs(s2); + assertThat((UnderlineSpan) spans[1]).isSameInstanceAs(s2); } else { - assertThat((URLSpan) spans[1]).isSameAs(s1); + assertThat((URLSpan) spans[1]).isSameInstanceAs(s1); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSubscriptionManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSubscriptionManagerTest.java index fef53eff2..5bd2f240b 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSubscriptionManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSubscriptionManagerTest.java @@ -91,7 +91,7 @@ public class ShadowSubscriptionManagerTest { shadowSubscriptionManager.setActiveSubscriptionInfos(expectedSubscriptionInfo); assertThat(shadowSubscriptionManager.getActiveSubscriptionInfo(123)) - .isSameAs(expectedSubscriptionInfo); + .isSameInstanceAs(expectedSubscriptionInfo); } @Test @@ -101,7 +101,7 @@ public class ShadowSubscriptionManagerTest { shadowSubscriptionManager.setActiveSubscriptionInfos(expectedSubscriptionInfo); assertThat(shadowSubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(123)) - .isSameAs(expectedSubscriptionInfo); + .isSameInstanceAs(expectedSubscriptionInfo); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTabHostTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTabHostTest.java index 95eccbe5d..557ab193b 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTabHostTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTabHostTest.java @@ -49,8 +49,8 @@ public class ShadowTabHostTest { tabHost.addTab(foo); tabHost.addTab(bar); - assertThat(tabHost.getChildAt(0)).isSameAs(fooView); - assertThat(tabHost.getChildAt(1)).isSameAs(barView); + assertThat(tabHost.getChildAt(0)).isSameInstanceAs(fooView); + assertThat(tabHost.getChildAt(1)).isSameInstanceAs(barView); } @Test @@ -64,8 +64,8 @@ public class ShadowTabHostTest { tabHost.addTab(bar); tabHost.addTab(baz); - assertThat(shadowOf(tabHost).getSpecByTag("Bar")).isSameAs(bar); - assertThat(shadowOf(tabHost).getSpecByTag("Baz")).isSameAs(baz); + assertThat(shadowOf(tabHost).getSpecByTag("Bar")).isSameInstanceAs(bar); + assertThat(shadowOf(tabHost).getSpecByTag("Baz")).isSameInstanceAs(baz); assertNull(shadowOf(tabHost).getSpecByTag("Whammie")); } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTabSpecTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTabSpecTest.java index 702e0790d..ef917e1a5 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTabSpecTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTabSpecTest.java @@ -34,8 +34,8 @@ public class ShadowTabSpecTest { TabHost.TabSpec spec = new TabHost(context).newTabSpec("foo"); View view = new View(context); TabHost.TabSpec self = spec.setIndicator(view); - assertThat(self).isSameAs(spec); - assertThat(shadowOf(spec).getIndicatorAsView()).isSameAs(view); + assertThat(self).isSameInstanceAs(spec); + assertThat(shadowOf(spec).getIndicatorAsView()).isSameInstanceAs(view); } @Test @@ -43,8 +43,8 @@ public class ShadowTabSpecTest { TabHost.TabSpec spec = new TabHost(context).newTabSpec("foo"); Intent intent = new Intent(); TabHost.TabSpec self = spec.setContent(intent); - assertThat(self).isSameAs(spec); - assertThat(shadowOf(spec).getContentAsIntent()).isSameAs(intent); + assertThat(self).isSameInstanceAs(spec); + assertThat(shadowOf(spec).getContentAsIntent()).isSameInstanceAs(intent); } @Test @@ -66,7 +66,7 @@ public class ShadowTabSpecTest { assertThat(shadowOf(spec).getIndicatorLabel()).isEqualTo("labelText"); assertThat(shadowOf(spec).getText()).isEqualTo("labelText"); - assertThat(shadowOf(spec).getIndicatorIcon()).isSameAs(icon1); + assertThat(shadowOf(spec).getIndicatorIcon()).isSameInstanceAs(icon1); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTest.java index 8646217af..59ef9b903 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTest.java @@ -23,18 +23,18 @@ public class ShadowTest { @Test public void newInstanceOf() throws Exception { assertThat(Shadow.newInstanceOf(Activity.class.getName()).getClass().getClassLoader()) - .isSameAs(myClassLoader); + .isSameInstanceAs(myClassLoader); } @Test public void extractor() throws Exception { Activity activity = new Activity(); - assertThat((ShadowActivity) Shadow.extract(activity)).isSameAs(shadowOf(activity)); + assertThat((ShadowActivity) Shadow.extract(activity)).isSameInstanceAs(shadowOf(activity)); } @Test public void otherDeprecated_extractor() throws Exception { Activity activity = new Activity(); - assertThat(Shadow.<Object>extract(activity)).isSameAs(shadowOf(activity)); + assertThat(Shadow.<Object>extract(activity)).isSameInstanceAs(shadowOf(activity)); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTextViewTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTextViewTest.java index 7a4381b0f..cf95730ae 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTextViewTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTextViewTest.java @@ -73,7 +73,7 @@ public class ShadowTextViewTest { textView.onEditorAction(EditorInfo.IME_ACTION_GO); - assertThat(actionListener.textView).isSameAs(textView); + assertThat(actionListener.textView).isSameInstanceAs(textView); assertThat(actionListener.sentImeId).isEqualTo(EditorInfo.IME_ACTION_GO); } @@ -83,7 +83,7 @@ public class ShadowTextViewTest { textView.setOnEditorActionListener(actionListener); - assertThat(shadowOf(textView).getOnEditorActionListener()).isSameAs(actionListener); + assertThat(shadowOf(textView).getOnEditorActionListener()).isSameInstanceAs(actionListener); } @Test @@ -111,7 +111,7 @@ public class ShadowTextViewTest { assertNull(textView.getMovementMethod()); textView.setMovementMethod(movement); - assertThat(textView.getMovementMethod()).isSameAs(movement); + assertThat(textView.getMovementMethod()).isSameInstanceAs(movement); } @Test @@ -398,7 +398,7 @@ public class ShadowTextViewTest { public void canSetAndGetInputFilters() throws Exception { final InputFilter[] expectedFilters = new InputFilter[]{new InputFilter.LengthFilter(1)}; textView.setFilters(expectedFilters); - assertThat(textView.getFilters()).isSameAs(expectedFilters); + assertThat(textView.getFilters()).isSameInstanceAs(expectedFilters); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeZoneFinderQTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeZoneFinderQTest.java index c20451229..231eace34 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeZoneFinderQTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeZoneFinderQTest.java @@ -33,7 +33,7 @@ public class ShadowTimeZoneFinderQTest { ClassParameter.from(String.class, "us")); assertThat(timezones.stream().map(TimeZone::getID).collect(Collectors.toList())) - .containsAllOf("America/Los_Angeles", "America/New_York", "Pacific/Honolulu"); + .containsAtLeast("America/Los_Angeles", "America/New_York", "Pacific/Honolulu"); } } // END-INTERNAL diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeZoneFinderSTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeZoneFinderSTest.java index 782a15698..34c8efc13 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeZoneFinderSTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeZoneFinderSTest.java @@ -49,7 +49,7 @@ public class ShadowTimeZoneFinderSTest { ClassParameter.from(String.class, "us")); assertThat(timezones.stream().map(TimeZone::getID).collect(Collectors.toList())) - .containsAllOf("America/Los_Angeles", "America/New_York", "Pacific/Honolulu"); + .containsAtLeast("America/Los_Angeles", "America/New_York", "Pacific/Honolulu"); } } // END-INTERNAL diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeZoneFinderTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeZoneFinderTest.java index 433c13962..962eaff32 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeZoneFinderTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeZoneFinderTest.java @@ -31,6 +31,6 @@ public class ShadowTimeZoneFinderTest { ClassParameter.from(String.class, "us")); assertThat(timezones.stream().map(TimeZone::getID).collect(Collectors.toList())) - .containsAllOf("America/Los_Angeles", "America/New_York", "Pacific/Honolulu"); + .containsAtLeast("America/Los_Angeles", "America/New_York", "Pacific/Honolulu"); } } diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowToastTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowToastTest.java index 8f5e1e668..968248342 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowToastTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowToastTest.java @@ -45,7 +45,7 @@ public class ShadowToastTest { assertThat(toast).isNotNull(); assertThat(toast.getDuration()).isEqualTo(Toast.LENGTH_SHORT); toast.show(); - assertThat(ShadowToast.getLatestToast()).isSameAs(toast); + assertThat(ShadowToast.getLatestToast()).isSameInstanceAs(toast); assertThat(ShadowToast.getTextOfLatestToast()).isEqualTo("short toast"); assertThat(ShadowToast.showedToast("short toast")).isTrue(); } @@ -55,7 +55,7 @@ public class ShadowToastTest { Toast toast = Toast.makeText(context, "short toast", Toast.LENGTH_SHORT); toast.setText("other toast"); toast.show(); - assertThat(ShadowToast.getLatestToast()).isSameAs(toast); + assertThat(ShadowToast.getLatestToast()).isSameInstanceAs(toast); assertThat(ShadowToast.getTextOfLatestToast()).isEqualTo("other toast"); assertThat(ShadowToast.showedToast("other toast")).isTrue(); } @@ -65,7 +65,7 @@ public class ShadowToastTest { Toast toast = Toast.makeText(context, "short toast", Toast.LENGTH_SHORT); toast.setText(R.string.hello); toast.show(); - assertThat(ShadowToast.getLatestToast()).isSameAs(toast); + assertThat(ShadowToast.getLatestToast()).isSameInstanceAs(toast); assertThat(ShadowToast.getTextOfLatestToast()).isEqualTo("Hello"); assertThat(ShadowToast.showedToast("Hello")).isTrue(); } @@ -76,7 +76,7 @@ public class ShadowToastTest { toast.setDuration(Toast.LENGTH_SHORT); final View view = new TextView(context); toast.setView(view); - assertThat(toast.getView()).isSameAs(view); + assertThat(toast.getView()).isSameInstanceAs(view); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowVideoViewTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowVideoViewTest.java index 223af6636..4720249f7 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowVideoViewTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowVideoViewTest.java @@ -26,7 +26,7 @@ public class ShadowVideoViewTest { TestPreparedListener l = new TestPreparedListener(); view.setOnPreparedListener(l); ShadowVideoView shadowVideoView = shadowOf(view); - assertThat(shadowVideoView.getOnPreparedListener()).isSameAs(l); + assertThat(shadowVideoView.getOnPreparedListener()).isSameInstanceAs(l); } @Test @@ -34,7 +34,7 @@ public class ShadowVideoViewTest { TestErrorListener l = new TestErrorListener(); view.setOnErrorListener(l); ShadowVideoView shadowVideoView = shadowOf(view); - assertThat(shadowVideoView.getOnErrorListener()).isSameAs(l); + assertThat(shadowVideoView.getOnErrorListener()).isSameInstanceAs(l); } @Test @@ -42,7 +42,7 @@ public class ShadowVideoViewTest { TestCompletionListener l = new TestCompletionListener(); view.setOnCompletionListener(l); ShadowVideoView shadowVideoView = shadowOf(view); - assertThat(shadowVideoView.getOnCompletionListener()).isSameAs(l); + assertThat(shadowVideoView.getOnCompletionListener()).isSameInstanceAs(l); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowViewGroupTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowViewGroupTest.java index 8e6d1dd9d..0376b9245 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowViewGroupTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowViewGroupTest.java @@ -92,7 +92,7 @@ public class ShadowViewGroupTest { }; root.setLayoutAnimationListener(animationListener); - assertThat(root.getLayoutAnimationListener()).isSameAs(animationListener); + assertThat(root.getLayoutAnimationListener()).isSameInstanceAs(animationListener); } @Test @@ -100,7 +100,7 @@ public class ShadowViewGroupTest { assertThat(root.getLayoutAnimation()).isNull(); LayoutAnimationController layoutAnim = new LayoutAnimationController(context, null); root.setLayoutAnimation(layoutAnim); - assertThat(root.getLayoutAnimation()).isSameAs(layoutAnim); + assertThat(root.getLayoutAnimation()).isSameInstanceAs(layoutAnim); } @Test @@ -108,8 +108,8 @@ public class ShadowViewGroupTest { root.removeViewAt(1); assertThat(root.getChildCount()).isEqualTo(2); - assertThat(root.getChildAt(0)).isSameAs(child1); - assertThat(root.getChildAt(1)).isSameAs((View) child3); + assertThat(root.getChildAt(0)).isSameInstanceAs(child1); + assertThat(root.getChildAt(1)).isSameInstanceAs((View) child3); assertThat(child2.getParent()).isNull(); } @@ -120,9 +120,9 @@ public class ShadowViewGroupTest { root.addView(child1); root.addView(child2); root.addView(child3, 1); - assertThat(root.getChildAt(0)).isSameAs(child1); - assertThat(root.getChildAt(1)).isSameAs((View) child3); - assertThat(root.getChildAt(2)).isSameAs(child2); + assertThat(root.getChildAt(0)).isSameInstanceAs(child1); + assertThat(root.getChildAt(1)).isSameInstanceAs((View) child3); + assertThat(root.getChildAt(2)).isSameInstanceAs(child2); } @Test @@ -134,9 +134,9 @@ public class ShadowViewGroupTest { root.addView(child1); root.addView(child2); root.addView(child3, 1); - assertThat((View) root.findViewWithTag("tag1")).isSameAs(child1); - assertThat((View) root.findViewWithTag("tag2")).isSameAs((View) child2); - assertThat((ViewGroup) root.findViewWithTag("tag3")).isSameAs(child3); + assertThat((View) root.findViewWithTag("tag1")).isSameInstanceAs(child1); + assertThat((View) root.findViewWithTag("tag2")).isSameInstanceAs((View) child2); + assertThat((ViewGroup) root.findViewWithTag("tag3")).isSameInstanceAs(child3); } @Test @@ -166,13 +166,13 @@ public class ShadowViewGroupTest { child3b.setTag("tag2"); //can find views by tag from root - assertThat((View) root.findViewWithTag("tag1")).isSameAs(child1); - assertThat((View) root.findViewWithTag("tag2")).isSameAs((View) child2); - assertThat((ViewGroup) root.findViewWithTag("tag3")).isSameAs(child3); + assertThat((View) root.findViewWithTag("tag1")).isSameInstanceAs(child1); + assertThat((View) root.findViewWithTag("tag2")).isSameInstanceAs((View) child2); + assertThat((ViewGroup) root.findViewWithTag("tag3")).isSameInstanceAs(child3); //can find views by tag from child3 - assertThat((View) child3.findViewWithTag("tag1")).isSameAs(child3a); - assertThat((View) child3.findViewWithTag("tag2")).isSameAs(child3b); + assertThat((View) child3.findViewWithTag("tag1")).isSameInstanceAs(child3a); + assertThat((View) child3.findViewWithTag("tag2")).isSameInstanceAs(child3b); } @Test @@ -285,8 +285,8 @@ public class ShadowViewGroupTest { assertThat(root.getChildCount()).isEqualTo(3); root.removeView(child1); assertThat(root.getChildCount()).isEqualTo(2); - assertThat(root.getChildAt(0)).isSameAs(child2); - assertThat(root.getChildAt(1)).isSameAs((View) child3); + assertThat(root.getChildAt(0)).isSameInstanceAs(child2); + assertThat(root.getChildAt(1)).isSameInstanceAs((View) child3); assertThat(child1.getParent()).isNull(); } @@ -296,7 +296,7 @@ public class ShadowViewGroupTest { assertNotSame(child3a.getParent(), root); root.removeView(child3a); assertThat(root.getChildCount()).isEqualTo(3); - assertThat(child3a.getParent()).isSameAs((ViewParent) child3); + assertThat(child3a.getParent()).isSameInstanceAs((ViewParent) child3); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java index 0380aae26..28b8f6e61 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java @@ -3,6 +3,7 @@ package org.robolectric.shadows; import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR2; import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -167,7 +168,7 @@ public class ShadowViewTest { @Test public void shouldKnowIfThisOrAncestorsAreVisible() throws Exception { - assertThat(view.isShown()).named("view isn't considered shown unless it has a view root").isFalse(); + assertWithMessage("view isn't considered shown unless it has a view root").that(view.isShown()).isFalse(); shadowOf(view).setMyParent(ReflectionHelpers.createNullProxy(ViewParent.class)); assertThat(view.isShown()).isTrue(); shadowOf(view).setMyParent(null); @@ -283,7 +284,7 @@ public class ShadowViewTest { public void shouldRecordBackgroundDrawable() { Drawable drawable = new BitmapDrawable(BitmapFactory.decodeFile("some/fake/file")); view.setBackgroundDrawable(drawable); - assertThat(view.getBackground()).isSameAs(drawable); + assertThat(view.getBackground()).isSameInstanceAs(drawable); assertThat(ShadowView.visualize(view)).isEqualTo("background:\nBitmap for file:some/fake/file"); } @@ -389,13 +390,13 @@ public class ShadowViewTest { public void shouldSetAnimation() throws Exception { Animation anim = new TestAnimation(); view.setAnimation(anim); - assertThat(view.getAnimation()).isSameAs(anim); + assertThat(view.getAnimation()).isSameInstanceAs(anim); } @Test public void shouldFindViewWithTag() { view.setTag("tagged"); - assertThat((View) view.findViewWithTag("tagged")).isSameAs(view); + assertThat((View) view.findViewWithTag("tagged")).isSameInstanceAs(view); } @Test @@ -432,7 +433,7 @@ public class ShadowViewTest { public void getViewTreeObserver_shouldReturnTheSameObserverFromMultipleCalls() throws Exception { ViewTreeObserver observer = view.getViewTreeObserver(); assertThat(observer).isInstanceOf(ViewTreeObserver.class); - assertThat(view.getViewTreeObserver()).isSameAs(observer); + assertThat(view.getViewTreeObserver()).isSameInstanceAs(observer); } @Test @@ -440,9 +441,9 @@ public class ShadowViewTest { TouchableView touchableView = new TouchableView(context); MotionEvent event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 12f, 34f, 0); touchableView.dispatchTouchEvent(event); - assertThat(touchableView.event).isSameAs(event); + assertThat(touchableView.event).isSameInstanceAs(event); view.dispatchTouchEvent(event); - assertThat(shadowOf(view).getLastTouchEvent()).isSameAs(event); + assertThat(shadowOf(view).getLastTouchEvent()).isSameInstanceAs(event); } @Test @@ -456,7 +457,7 @@ public class ShadowViewTest { }); MotionEvent event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 12f, 34f, 0); view.dispatchTouchEvent(event); - assertThat(shadowOf(view).getLastTouchEvent()).isSameAs(event); + assertThat(shadowOf(view).getLastTouchEvent()).isSameInstanceAs(event); assertThat(called.get()).isTrue(); } @@ -850,7 +851,7 @@ public class ShadowViewTest { WindowId windowId = parent.getWindowId(); assertThat(windowId).isNotNull(); - assertThat(child.getWindowId()).isSameAs(windowId); + assertThat(child.getWindowId()).isSameInstanceAs(windowId); assertThat(child.getWindowId()).isEqualTo(windowId); // equals must work! MyView anotherChild = new MyView("another child", transcript); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowWebViewTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowWebViewTest.java index 0f5742875..259f9d347 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowWebViewTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowWebViewTest.java @@ -84,7 +84,7 @@ public class ShadowWebViewTest { assertThat(shadowOf(webView).getWebViewClient()).isNull(); webView.setWebViewClient(webViewClient); - assertThat(shadowOf(webView).getWebViewClient()).isSameAs(webViewClient); + assertThat(shadowOf(webView).getWebViewClient()).isSameInstanceAs(webViewClient); } @Test @@ -92,7 +92,7 @@ public class ShadowWebViewTest { WebChromeClient webChromeClient = new WebChromeClient(); assertThat(shadowOf(webView).getWebChromeClient()).isNull(); webView.setWebChromeClient(webChromeClient); - assertThat(shadowOf(webView).getWebChromeClient()).isSameAs(webChromeClient); + assertThat(shadowOf(webView).getWebChromeClient()).isSameInstanceAs(webChromeClient); } @Test @@ -102,7 +102,7 @@ public class ShadowWebViewTest { Object obj = new Object(); assertThat(shadowOf(webView).getJavascriptInterface(name)).isNull(); webView.addJavascriptInterface(obj, name); - assertThat(shadowOf(webView).getJavascriptInterface(name)).isSameAs(obj); + assertThat(shadowOf(webView).getJavascriptInterface(name)).isSameInstanceAs(obj); } } @@ -242,7 +242,7 @@ public class ShadowWebViewTest { assertThat(webView.getLayoutParams()).isNull(); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); webView.setLayoutParams(params); - assertThat(webView.getLayoutParams()).isSameAs(params); + assertThat(webView.getLayoutParams()).isSameInstanceAs(params); } @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowWifiManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowWifiManagerTest.java index 5b03f5994..05ad99ca6 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowWifiManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowWifiManagerTest.java @@ -46,7 +46,7 @@ public class ShadowWifiManagerTest { public void setWifiInfo_shouldUpdateWifiInfo() { WifiInfo wifiInfo = new WifiInfo(); shadowOf(wifiManager).setConnectionInfo(wifiInfo); - assertThat(wifiManager.getConnectionInfo()).isSameAs(wifiInfo); + assertThat(wifiManager.getConnectionInfo()).isSameInstanceAs(wifiInfo); } @Test @@ -144,14 +144,14 @@ public class ShadowWifiManagerTest { public void shouldReturnSetScanResults() throws Exception { List<ScanResult> scanResults = new ArrayList<>(); shadowOf(wifiManager).setScanResults(scanResults); - assertThat(wifiManager.getScanResults()).isSameAs(scanResults); + assertThat(wifiManager.getScanResults()).isSameInstanceAs(scanResults); } @Test public void shouldReturnDhcpInfo() { DhcpInfo dhcpInfo = new DhcpInfo(); shadowOf(wifiManager).setDhcpInfo(dhcpInfo); - assertThat(wifiManager.getDhcpInfo()).isSameAs(dhcpInfo); + assertThat(wifiManager.getDhcpInfo()).isSameInstanceAs(dhcpInfo); } @Test @@ -160,7 +160,7 @@ public class ShadowWifiManagerTest { wifiConfiguration.networkId = -1; int networkId = wifiManager.addNetwork(wifiConfiguration); assertThat(networkId).isEqualTo(0); - assertThat(wifiManager.getConfiguredNetworks().get(0)).isNotSameAs(wifiConfiguration); + assertThat(wifiManager.getConfiguredNetworks().get(0)).isNotSameInstanceAs(wifiConfiguration); assertThat(wifiConfiguration.networkId).isEqualTo(-1); assertThat(wifiManager.getConfiguredNetworks().get(0).networkId).isEqualTo(0); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowWindowManagerImplTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowWindowManagerImplTest.java index bf9dcbd91..46ddef720 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowWindowManagerImplTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowWindowManagerImplTest.java @@ -55,7 +55,7 @@ public class ShadowWindowManagerImplTest { List<View> views = ((ShadowWindowManagerImpl) shadowOf(windowManager)).getViews(); assertThat(views).hasSize(1); - assertThat(views.get(0)).isSameAs(view); + assertThat(views.get(0)).isSameInstanceAs(view); } @Test |