Merge "Migrate away from deprecated Truth APIs."

This commit is contained in:
Alexander Dorokhine
2020-10-13 19:20:53 +00:00
committed by Gerrit Code Review
30 changed files with 93 additions and 112 deletions

View File

@@ -847,7 +847,7 @@ private val whitelistedPkgs = listOf("my.whitelisted.package")
@Test
fun onlySomeAppsAreAllowedToHavePermissionGranted() {
assertThat(whitelistedPkgs).containsAllIn(
assertThat(whitelistedPkgs).containsAtLeastElementsIn(
context.packageManager.getInstalledPackages(MATCH_ALL)
.filter { pkg ->
context.checkPermission(android.Manifest.permission.MY_PRIVILEGED_PERMISSION, -1,

View File

@@ -117,8 +117,8 @@ public class NotificationHistoryTest {
history.addNotificationToWrite(n);
assertThat(history.getNotificationsToWrite().size()).isEqualTo(2);
assertThat(history.getNotificationsToWrite().get(0)).isSameAs(n2);
assertThat(history.getNotificationsToWrite().get(1)).isSameAs(n);
assertThat(history.getNotificationsToWrite().get(0)).isSameInstanceAs(n2);
assertThat(history.getNotificationsToWrite().get(1)).isSameInstanceAs(n);
assertThat(history.getHistoryCount()).isEqualTo(2);
}
@@ -141,11 +141,11 @@ public class NotificationHistoryTest {
history.addNotificationsToWrite(secondHistory);
assertThat(history.getNotificationsToWrite().size()).isEqualTo(5);
assertThat(history.getNotificationsToWrite().get(0)).isSameAs(n3);
assertThat(history.getNotificationsToWrite().get(1)).isSameAs(n);
assertThat(history.getNotificationsToWrite().get(2)).isSameAs(n4);
assertThat(history.getNotificationsToWrite().get(3)).isSameAs(n2);
assertThat(history.getNotificationsToWrite().get(4)).isSameAs(n5);
assertThat(history.getNotificationsToWrite().get(0)).isSameInstanceAs(n3);
assertThat(history.getNotificationsToWrite().get(1)).isSameInstanceAs(n);
assertThat(history.getNotificationsToWrite().get(2)).isSameInstanceAs(n4);
assertThat(history.getNotificationsToWrite().get(3)).isSameInstanceAs(n2);
assertThat(history.getNotificationsToWrite().get(4)).isSameInstanceAs(n5);
assertThat(history.getHistoryCount()).isEqualTo(5);
assertThat(history.getPooledStringsToWrite()).asList().contains(n2.getChannelName());

View File

@@ -45,7 +45,8 @@ public class CompoundFormulaTest {
CompoundFormula.AND, Arrays.asList(ATOMIC_FORMULA_1, ATOMIC_FORMULA_2));
assertThat(compoundFormula.getConnector()).isEqualTo(CompoundFormula.AND);
assertThat(compoundFormula.getFormulas()).containsAllOf(ATOMIC_FORMULA_1, ATOMIC_FORMULA_2);
assertThat(compoundFormula.getFormulas())
.containsAtLeast(ATOMIC_FORMULA_1, ATOMIC_FORMULA_2);
}
@Test

View File

@@ -113,7 +113,7 @@ class ParseInputAndResultTest {
assertError(result)
assertThat(result.errorCode).isEqualTo(errorCode)
assertThat(result.errorMessage).isEqualTo(errorMessage)
assertThat(result.exception).isSameAs(exception)
assertThat(result.exception).isSameInstanceAs(exception)
}
@Test
@@ -125,13 +125,13 @@ class ParseInputAndResultTest {
assertError(result)
assertThat(result.errorCode).isEqualTo(errorCode)
assertThat(result.errorMessage).isEqualTo(errorMessage)
assertThat(result.exception).isSameAs(exception)
assertThat(result.exception).isSameInstanceAs(exception)
val carriedResult = input.error<Int>(result)
assertError(carriedResult)
assertThat(carriedResult.errorCode).isEqualTo(errorCode)
assertThat(carriedResult.errorMessage).isEqualTo(errorMessage)
assertThat(carriedResult.exception).isSameAs(exception)
assertThat(carriedResult.exception).isSameInstanceAs(exception)
}
@Test
@@ -259,7 +259,7 @@ class ParseInputAndResultTest {
private fun assertSuccess(expected: Any? = null, result: ParseResult<*>) {
assertThat(result.isError).isFalse()
assertThat(result.isSuccess).isTrue()
assertThat(result.result).isSameAs(expected)
assertThat(result.result).isSameInstanceAs(expected)
assertThat(result.errorCode).isEqualTo(PackageManager.INSTALL_SUCCEEDED)
assertThat(result.errorMessage).isNull()
assertThat(result.exception).isNull()

View File

@@ -52,7 +52,8 @@ public class TextClassificationManagerTest {
@Test
public void testGetLocalTextClassifier() {
assertThat(mTcm.getTextClassifier(TextClassifier.LOCAL)).isSameAs(TextClassifier.NO_OP);
assertThat(mTcm.getTextClassifier(TextClassifier.LOCAL))
.isSameInstanceAs(TextClassifier.NO_OP);
}
@Test

View File

@@ -81,7 +81,7 @@ public class AndroidFutureTest {
future.completeExceptionally(origException);
ExecutionException executionException =
expectThrows(ExecutionException.class, future::get);
assertThat(executionException.getCause()).isSameAs(origException);
assertThat(executionException.getCause()).isSameInstanceAs(origException);
}
@Test
@@ -92,7 +92,7 @@ public class AndroidFutureTest {
CountDownLatch latch = new CountDownLatch(1);
future.whenComplete((obj, err) -> {
assertThat(obj).isNull();
assertThat(err).isSameAs(origException);
assertThat(err).isSameInstanceAs(origException);
latch.countDown();
});
latch.await();

View File

@@ -107,7 +107,7 @@ public class BinderDeathDispatcherTest {
if (!isAlive) {
return false;
}
assertThat(mRecipient).isSameAs(recipient);
assertThat(mRecipient).isSameInstanceAs(recipient);
mRecipient = null;
return true;
}

View File

@@ -74,7 +74,7 @@ public class RegisterStatusBarResultTest {
assertThat(copy.mImeBackDisposition).isEqualTo(original.mImeBackDisposition);
assertThat(copy.mShowImeSwitcher).isEqualTo(original.mShowImeSwitcher);
assertThat(copy.mDisabledFlags2).isEqualTo(original.mDisabledFlags2);
assertThat(copy.mImeToken).isSameAs(original.mImeToken);
assertThat(copy.mImeToken).isSameInstanceAs(original.mImeToken);
assertThat(copy.mNavbarColorManagedByIme).isEqualTo(original.mNavbarColorManagedByIme);
assertThat(copy.mAppFullscreen).isEqualTo(original.mAppFullscreen);
assertThat(copy.mAppImmersive).isEqualTo(original.mAppImmersive);

View File

@@ -1090,7 +1090,7 @@ public class WifiTrackerTest {
// Verify second update AP is the same object as the first update AP
assertThat(passpointAccessPointsFirstUpdate.get(0))
.isSameAs(passpointAccessPointsSecondUpdate.get(0));
.isSameInstanceAs(passpointAccessPointsSecondUpdate.get(0));
// Verify second update AP has the average of the first and second update RSSIs
assertThat(passpointAccessPointsSecondUpdate.get(0).getRssi())
.isEqualTo((prevRssi + newRssi) / 2);
@@ -1210,7 +1210,8 @@ public class WifiTrackerTest {
providersAndScans, cachedAccessPoints);
// Verify second update AP is the same object as the first update AP
assertThat(osuAccessPointsFirstUpdate.get(0)).isSameAs(osuAccessPointsSecondUpdate.get(0));
assertThat(osuAccessPointsFirstUpdate.get(0))
.isSameInstanceAs(osuAccessPointsSecondUpdate.get(0));
// Verify second update AP has the average of the first and second update RSSIs
assertThat(osuAccessPointsSecondUpdate.get(0).getRssi())
.isEqualTo((prevRssi + newRssi) / 2);

View File

@@ -69,7 +69,7 @@ public class IpAddressPreferenceControllerTest {
assertWithMessage("Intent filter should contain expected intents")
.that(ipAddressPreferenceController.getConnectivityIntents())
.asList().containsAllIn(expectedIntents);
.asList().containsAtLeastElementsIn(expectedIntents);
}
private static class ConcreteIpAddressPreferenceController extends

View File

@@ -90,7 +90,7 @@ public class WifiMacAddressPreferenceControllerTest {
assertWithMessage("Intent filter should contain expected intents")
.that(mController.getConnectivityIntents())
.asList().containsAllIn(expectedIntents);
.asList().containsAtLeastElementsIn(expectedIntents);
}
@Test

View File

@@ -281,7 +281,7 @@ public class TileUtilsTest {
assertThat(outTiles).hasSize(1);
final Bundle newMetaData = outTiles.get(0).getMetaData();
assertThat(newMetaData).isNotSameAs(oldMetadata);
assertThat(newMetaData).isNotSameInstanceAs(oldMetadata);
}
@Test

View File

@@ -168,7 +168,7 @@ public final class ClockManagerTest extends SysuiTestCase {
verify(mMockListener2).onClockChanged(captor2.capture());
assertThat(captor1.getValue()).isInstanceOf(BUBBLE_CLOCK_CLASS);
assertThat(captor2.getValue()).isInstanceOf(BUBBLE_CLOCK_CLASS);
assertThat(captor1.getValue()).isNotSameAs(captor2.getValue());
assertThat(captor1.getValue()).isNotSameInstanceAs(captor2.getValue());
}
@Test

View File

@@ -19,6 +19,7 @@ package com.android.systemui.bubbles;
import static com.android.systemui.statusbar.NotificationEntryHelper.modifyRanking;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
@@ -793,47 +794,48 @@ public class BubbleDataTest extends SysuiTestCase {
private void assertBubbleAdded(Bubble expected) {
BubbleData.Update update = mUpdateCaptor.getValue();
assertThat(update.addedBubble).named("addedBubble").isEqualTo(expected);
assertWithMessage("addedBubble").that(update.addedBubble).isEqualTo(expected);
}
private void assertBubbleRemoved(Bubble expected, @BubbleController.DismissReason int reason) {
BubbleData.Update update = mUpdateCaptor.getValue();
assertThat(update.removedBubbles).named("removedBubbles")
assertWithMessage("removedBubbles").that(update.removedBubbles)
.isEqualTo(ImmutableList.of(Pair.create(expected, reason)));
}
private void assertOrderNotChanged() {
BubbleData.Update update = mUpdateCaptor.getValue();
assertThat(update.orderChanged).named("orderChanged").isFalse();
assertWithMessage("orderChanged").that(update.orderChanged).isFalse();
}
private void assertOrderChangedTo(Bubble... order) {
BubbleData.Update update = mUpdateCaptor.getValue();
assertThat(update.orderChanged).named("orderChanged").isTrue();
assertThat(update.bubbles).named("bubble order").isEqualTo(ImmutableList.copyOf(order));
assertWithMessage("orderChanged").that(update.orderChanged).isTrue();
assertWithMessage("bubble order").that(update.bubbles)
.isEqualTo(ImmutableList.copyOf(order));
}
private void assertSelectionNotChanged() {
BubbleData.Update update = mUpdateCaptor.getValue();
assertThat(update.selectionChanged).named("selectionChanged").isFalse();
assertWithMessage("selectionChanged").that(update.selectionChanged).isFalse();
}
private void assertSelectionChangedTo(Bubble bubble) {
BubbleData.Update update = mUpdateCaptor.getValue();
assertThat(update.selectionChanged).named("selectionChanged").isTrue();
assertThat(update.selectedBubble).named("selectedBubble").isEqualTo(bubble);
assertWithMessage("selectionChanged").that(update.selectionChanged).isTrue();
assertWithMessage("selectedBubble").that(update.selectedBubble).isEqualTo(bubble);
}
private void assertSelectionCleared() {
BubbleData.Update update = mUpdateCaptor.getValue();
assertThat(update.selectionChanged).named("selectionChanged").isTrue();
assertThat(update.selectedBubble).named("selectedBubble").isNull();
assertWithMessage("selectionChanged").that(update.selectionChanged).isTrue();
assertWithMessage("selectedBubble").that(update.selectedBubble).isNull();
}
private void assertExpandedChangedTo(boolean expected) {
BubbleData.Update update = mUpdateCaptor.getValue();
assertThat(update.expandedChanged).named("expandedChanged").isTrue();
assertThat(update.expanded).named("expanded").isEqualTo(expected);
assertWithMessage("expandedChanged").that(update.expandedChanged).isTrue();
assertWithMessage("expanded").that(update.expanded).isEqualTo(expected);
}
private void assertOverflowChangedTo(ImmutableList<Bubble> bubbles) {
@@ -895,4 +897,4 @@ public class BubbleDataTest extends SysuiTestCase {
setCurrentTime(time);
mBubbleData.setExpanded(shouldBeExpanded);
}
}
}

View File

@@ -80,7 +80,7 @@ class MediaArtworkProcessorTest : SysuiTestCase() {
val background2 = processor.processArtwork(context, artwork)!!
// THEN the two bitmaps are the same
// Note: This is currently broken and trying to use caching causes issues
assertThat(background1).isNotSameAs(background2)
assertThat(background1).isNotSameInstanceAs(background2)
}
@Test

View File

@@ -118,7 +118,7 @@ class PeopleHubViewControllerTest : SysuiTestCase() {
val people = viewModel.people.toList()
assertThat(people.size).isEqualTo(1)
assertThat(people[0].name).isEqualTo("name")
assertThat(people[0].icon).isSameAs(fakePerson.avatar)
assertThat(people[0].icon).isSameInstanceAs(fakePerson.avatar)
people[0].onClick()

View File

@@ -326,7 +326,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
mAccessibiltyDelegate.onInitializeAccessibilityNodeInfo(mView, nodeInfo);
List<AccessibilityNodeInfo.AccessibilityAction> actionList = nodeInfo.getActionList();
assertThat(actionList).containsAllIn(
assertThat(actionList).containsAtLeastElementsIn(
new AccessibilityNodeInfo.AccessibilityAction[] {
AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD,
AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_UP}

View File

@@ -41,6 +41,7 @@ import static com.android.server.backup.testing.Utils.oneTimeIterable;
import static com.android.server.backup.testing.Utils.transferStreamedData;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -2814,8 +2815,8 @@ public class KeyValueBackupTaskTest {
}
private static IterableSubject assertDirectory(Path directory) throws IOException {
return assertThat(oneTimeIterable(Files.newDirectoryStream(directory).iterator()))
.named("directory " + directory);
return assertWithMessage("directory " + directory).that(
oneTimeIterable(Files.newDirectoryStream(directory).iterator()));
}
private static void assertJournalDoesNotContain(

View File

@@ -17,6 +17,7 @@
package com.android.server.backup.testing;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.robolectric.Shadows.shadowOf;
@@ -95,8 +96,8 @@ public class TestUtils {
* logcat before that.
*/
public static void assertLogcatAtMost(String tag, int level) {
assertThat(ShadowLog.getLogsForTag(tag).stream().allMatch(logItem -> logItem.type <= level))
.named("All logs <= " + level)
assertWithMessage("All logs <= " + level).that(
ShadowLog.getLogsForTag(tag).stream().allMatch(logItem -> logItem.type <= level))
.isTrue();
}
@@ -105,8 +106,8 @@ public class TestUtils {
* logcat before that.
*/
public static void assertLogcatAtLeast(String tag, int level) {
assertThat(ShadowLog.getLogsForTag(tag).stream().anyMatch(logItem -> logItem.type >= level))
.named("Any log >= " + level)
assertWithMessage("Any log >= " + level).that(
ShadowLog.getLogsForTag(tag).stream().anyMatch(logItem -> logItem.type >= level))
.isTrue();
}
@@ -121,11 +122,10 @@ public class TestUtils {
* that uses logcat before that.
*/
public static void assertLogcat(String tag, int... logs) {
assertThat(
assertWithMessage("Log items (specified per level)").that(
ShadowLog.getLogsForTag(tag).stream()
.map(logItem -> logItem.type)
.collect(toSet()))
.named("Log items (specified per level)")
.containsExactly(IntStream.of(logs).boxed().toArray());
}
@@ -135,15 +135,13 @@ public class TestUtils {
/** Declare shadow {@link ShadowEventLog} to use this. */
public static void assertEventLogged(int tag, Object... values) {
assertThat(ShadowEventLog.getEntries())
.named("Event logs")
assertWithMessage("Event logs").that(ShadowEventLog.getEntries())
.contains(new ShadowEventLog.Entry(tag, Arrays.asList(values)));
}
/** Declare shadow {@link ShadowEventLog} to use this. */
public static void assertEventNotLogged(int tag, Object... values) {
assertThat(ShadowEventLog.getEntries())
.named("Event logs")
assertWithMessage("Event logs").that(ShadowEventLog.getEntries())
.doesNotContain(new ShadowEventLog.Entry(tag, Arrays.asList(values)));
}

View File

@@ -79,7 +79,7 @@ public class LocationFudgerTest {
Location coarse = mFudger.createCoarse(fine);
assertThat(coarse).isNotNull();
assertThat(coarse).isNotSameAs(fine);
assertThat(coarse).isNotSameInstanceAs(fine);
assertThat(coarse.hasBearing()).isFalse();
assertThat(coarse.hasSpeed()).isFalse();
assertThat(coarse.hasAltitude()).isFalse();

View File

@@ -194,7 +194,7 @@ public class IntegrityFileManagerTest {
assertThat(rulesFetched.size())
.isEqualTo(INDEXING_BLOCK_SIZE * 2 + unindexedRuleCount);
assertThat(rulesFetched)
.containsAllOf(
.containsAtLeast(
getPackageNameIndexedRule(installedPackageName),
getAppCertificateIndexedRule(installedAppCertificate));
}

View File

@@ -71,7 +71,7 @@ public class TestOnlyInsecureCertificateHelperTest {
Map<String, Pair<SecretKey, byte[]>> filteredKeys =
mHelper.keepOnlyWhitelistedInsecureKeys(rawKeys);
assertThat(filteredKeys.entrySet()).containsExactlyElementsIn(expectedResult.entrySet());
assertThat(filteredKeys.entrySet()).containsAllIn(rawKeys.entrySet());
assertThat(filteredKeys.entrySet()).containsAtLeastElementsIn(rawKeys.entrySet());
}
@Test
@@ -85,7 +85,7 @@ public class TestOnlyInsecureCertificateHelperTest {
Map<String, Pair<SecretKey, byte[]>> filteredKeys =
mHelper.keepOnlyWhitelistedInsecureKeys(rawKeys);
assertThat(filteredKeys.entrySet()).containsExactlyElementsIn(expectedResult.entrySet());
assertThat(rawKeys.entrySet()).containsAllIn(filteredKeys.entrySet());
assertThat(rawKeys.entrySet()).containsAtLeastElementsIn(filteredKeys.entrySet());
}
@Test
@@ -100,7 +100,7 @@ public class TestOnlyInsecureCertificateHelperTest {
Map<String, Pair<SecretKey, byte[]>> filteredKeys =
mHelper.keepOnlyWhitelistedInsecureKeys(rawKeys);
assertThat(filteredKeys.entrySet()).containsExactlyElementsIn(expectedResult.entrySet());
assertThat(rawKeys.entrySet()).containsAllIn(filteredKeys.entrySet());
assertThat(rawKeys.entrySet()).containsAtLeastElementsIn(filteredKeys.entrySet());
}
@Test
@@ -122,7 +122,7 @@ public class TestOnlyInsecureCertificateHelperTest {
Map<String, Pair<SecretKey, byte[]>> filteredKeys =
mHelper.keepOnlyWhitelistedInsecureKeys(rawKeys);
assertThat(filteredKeys.entrySet()).containsExactlyElementsIn(expectedResult.entrySet());
assertThat(rawKeys.entrySet()).containsAllIn(filteredKeys.entrySet());
assertThat(rawKeys.entrySet()).containsAtLeastElementsIn(filteredKeys.entrySet());
}
@Test

View File

@@ -70,7 +70,7 @@ public final class CertXmlTest {
CertXml certXml = CertXml.parse(certXmlBytes);
List<X509Certificate> endpointCerts = certXml.getAllEndpointCerts();
assertThat(endpointCerts).hasSize(3);
assertThat(endpointCerts).containsAllOf(TestData.LEAF_CERT_1, TestData.LEAF_CERT_2);
assertThat(endpointCerts).containsAtLeast(TestData.LEAF_CERT_1, TestData.LEAF_CERT_2);
}
@Test

View File

@@ -639,7 +639,7 @@ public final class UserManagerTest {
UserInfo user1 = createUser("User 1", 0);
UserInfo user2 = createUser("User 2", 0);
long[] serialNumbersOfUsers = mUserManager.getSerialNumbersOfUsers(false);
assertThat(serialNumbersOfUsers).asList().containsAllOf(
assertThat(serialNumbersOfUsers).asList().containsAtLeast(
(long) user1.serialNumber, (long) user2.serialNumber);
}

View File

@@ -48,41 +48,25 @@ public class RollbackStoreTest {
private static final String INSTALLER = "some.installer";
private static final Correspondence<VersionedPackage, VersionedPackage> VER_PKG_CORR =
new Correspondence<VersionedPackage, VersionedPackage>() {
@Override
public boolean compare(VersionedPackage a, VersionedPackage b) {
if (a == null || b == null) {
return a == b;
}
return a.equals(b);
Correspondence.from((VersionedPackage a, VersionedPackage b) -> {
if (a == null || b == null) {
return a == b;
}
@Override
public String toString() {
return "is the same as";
}
};
return a.equals(b);
}, "is the same as");
private static final Correspondence<PackageRollbackInfo.RestoreInfo,
PackageRollbackInfo.RestoreInfo>
RESTORE_INFO_CORR =
new Correspondence<PackageRollbackInfo.RestoreInfo, PackageRollbackInfo.RestoreInfo>() {
@Override
public boolean compare(PackageRollbackInfo.RestoreInfo a,
PackageRollbackInfo.RestoreInfo b) {
if (a == null || b == null) {
return a == b;
}
return a.userId == b.userId
&& a.appId == b.appId
&& Objects.equals(a.seInfo, b.seInfo);
Correspondence.from((PackageRollbackInfo.RestoreInfo a,
PackageRollbackInfo.RestoreInfo b) -> {
if (a == null || b == null) {
return a == b;
}
@Override
public String toString() {
return "is the same as";
}
};
return a.userId == b.userId
&& a.appId == b.appId
&& Objects.equals(a.seInfo, b.seInfo);
}, "is the same as");
private static final String JSON_ROLLBACK_NO_EXT = "{'info':{'rollbackId':123,'packages':"
+ "[{'versionRolledBackFrom':{'packageName':'blah','longVersionCode':55},"

View File

@@ -132,7 +132,7 @@ public class DiskStatsFileLoggerTest extends AndroidTestCase {
appSizes.getLong(i), cacheSizes.getLong(i));
apps.add(app);
}
assertThat(apps).containsAllOf(new AppSizeGrouping("com.test.app", 1100, 20),
assertThat(apps).containsAtLeast(new AppSizeGrouping("com.test.app", 1100, 20),
new AppSizeGrouping("com.test.app2", 11, 2));
}

View File

@@ -81,9 +81,7 @@ public class TunerResourceManagerServiceTest {
// A correspondence to compare a FrontendResource and a TunerFrontendInfo.
private static final Correspondence<FrontendResource, TunerFrontendInfo> FR_TFI_COMPARE =
new Correspondence<FrontendResource, TunerFrontendInfo>() {
@Override
public boolean compare(FrontendResource actual, TunerFrontendInfo expected) {
Correspondence.from((FrontendResource actual, TunerFrontendInfo expected) -> {
if (actual == null || expected == null) {
return (actual == null) && (expected == null);
}
@@ -91,13 +89,7 @@ public class TunerResourceManagerServiceTest {
return actual.getId() == expected.getId()
&& actual.getType() == expected.getFrontendType()
&& actual.getExclusiveGroupId() == expected.getExclusiveGroupId();
}
@Override
public String toString() {
return "is correctly configured from ";
}
};
}, "is correctly configured from ");
@Before
public void setUp() throws Exception {

View File

@@ -305,6 +305,7 @@ public class ShortcutHelperTest extends UiServiceTestCase {
//when(mShortcutServiceInternal.isSharingShortcut(anyInt(), anyString(), anyString(),
// anyString(), anyInt(), any())).thenReturn(true);
assertThat(mShortcutHelper.getValidShortcutInfo("a", "p", UserHandle.SYSTEM)).isSameAs(si);
assertThat(mShortcutHelper.getValidShortcutInfo("a", "p", UserHandle.SYSTEM))
.isSameInstanceAs(si);
}
}

View File

@@ -124,7 +124,7 @@ class ParcelablesTest<T : Parcelable>(private val inputData: InputData<T>) {
data class InputData<T : Parcelable>(val valid: T, val validCopy: T, val validOther: T) {
val kls = valid.javaClass
init {
assertThat(valid).isNotSameAs(validCopy)
assertThat(valid).isNotSameInstanceAs(validCopy)
// Don't use isInstanceOf because of phantom warnings in intellij about Class!
assertThat(validCopy.javaClass).isEqualTo(valid.javaClass)
assertThat(validOther.javaClass).isEqualTo(valid.javaClass)

View File

@@ -80,12 +80,12 @@ public class SoftApConfigurationTest {
assertThat(original.getMaxNumberOfClients()).isEqualTo(0);
SoftApConfiguration unparceled = parcelUnparcel(original);
assertThat(unparceled).isNotSameAs(original);
assertThat(unparceled).isNotSameInstanceAs(original);
assertThat(unparceled).isEqualTo(original);
assertThat(unparceled.hashCode()).isEqualTo(original.hashCode());
SoftApConfiguration copy = new SoftApConfiguration.Builder(original).build();
assertThat(copy).isNotSameAs(original);
assertThat(copy).isNotSameInstanceAs(original);
assertThat(copy).isEqualTo(original);
assertThat(copy.hashCode()).isEqualTo(original.hashCode());
}
@@ -104,12 +104,12 @@ public class SoftApConfigurationTest {
assertThat(original.getMaxNumberOfClients()).isEqualTo(0);
SoftApConfiguration unparceled = parcelUnparcel(original);
assertThat(unparceled).isNotSameAs(original);
assertThat(unparceled).isNotSameInstanceAs(original);
assertThat(unparceled).isEqualTo(original);
assertThat(unparceled.hashCode()).isEqualTo(original.hashCode());
SoftApConfiguration copy = new SoftApConfiguration.Builder(original).build();
assertThat(copy).isNotSameAs(original);
assertThat(copy).isNotSameInstanceAs(original);
assertThat(copy).isEqualTo(original);
assertThat(copy.hashCode()).isEqualTo(original.hashCode());
}
@@ -145,12 +145,12 @@ public class SoftApConfigurationTest {
assertThat(original.getAllowedClientList()).isEqualTo(testAllowedClientList);
SoftApConfiguration unparceled = parcelUnparcel(original);
assertThat(unparceled).isNotSameAs(original);
assertThat(unparceled).isNotSameInstanceAs(original);
assertThat(unparceled).isEqualTo(original);
assertThat(unparceled.hashCode()).isEqualTo(original.hashCode());
SoftApConfiguration copy = new SoftApConfiguration.Builder(original).build();
assertThat(copy).isNotSameAs(original);
assertThat(copy).isNotSameInstanceAs(original);
assertThat(copy).isEqualTo(original);
assertThat(copy.hashCode()).isEqualTo(original.hashCode());
}
@@ -171,12 +171,12 @@ public class SoftApConfigurationTest {
SoftApConfiguration unparceled = parcelUnparcel(original);
assertThat(unparceled).isNotSameAs(original);
assertThat(unparceled).isNotSameInstanceAs(original);
assertThat(unparceled).isEqualTo(original);
assertThat(unparceled.hashCode()).isEqualTo(original.hashCode());
SoftApConfiguration copy = new SoftApConfiguration.Builder(original).build();
assertThat(copy).isNotSameAs(original);
assertThat(copy).isNotSameInstanceAs(original);
assertThat(copy).isEqualTo(original);
assertThat(copy.hashCode()).isEqualTo(original.hashCode());
}
@@ -198,12 +198,12 @@ public class SoftApConfigurationTest {
SoftApConfiguration unparceled = parcelUnparcel(original);
assertThat(unparceled).isNotSameAs(original);
assertThat(unparceled).isNotSameInstanceAs(original);
assertThat(unparceled).isEqualTo(original);
assertThat(unparceled.hashCode()).isEqualTo(original.hashCode());
SoftApConfiguration copy = new SoftApConfiguration.Builder(original).build();
assertThat(copy).isNotSameAs(original);
assertThat(copy).isNotSameInstanceAs(original);
assertThat(copy).isEqualTo(original);
assertThat(copy.hashCode()).isEqualTo(original.hashCode());
}