Tidy up changes

Extracted improvements from a later commit which are orthogonal to the
purpose of that change.

Bug: 236624675
Test: build / treehugger only
Change-Id: I10d9a227cdde0f87e091cab23a67d7e49ebc7d15
This commit is contained in:
Neil Fuller
2022-11-14 15:51:50 +00:00
parent 9429d4dcf7
commit 161e9f1bb7
12 changed files with 31 additions and 30 deletions

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package android.app.timezonedetector;
package android.app.time;
import static org.junit.Assert.assertEquals;
@@ -48,6 +48,13 @@ public final class ParcelableTestSupport {
}
public static <T extends Parcelable> void assertRoundTripParcelable(T instance) {
assertEquals(instance, roundTripParcelable(instance));
assertEqualsAndHashCode(instance, roundTripParcelable(instance));
}
/** Asserts that the objects are equal and return identical hash codes. */
public static void assertEqualsAndHashCode(Object one, Object two) {
assertEquals(one, two);
assertEquals(two, one);
assertEquals(one.hashCode(), two.hashCode());
}
}

View File

@@ -21,7 +21,8 @@ import static android.app.time.Capabilities.CAPABILITY_NOT_ALLOWED;
import static android.app.time.Capabilities.CAPABILITY_NOT_APPLICABLE;
import static android.app.time.Capabilities.CAPABILITY_NOT_SUPPORTED;
import static android.app.time.Capabilities.CAPABILITY_POSSESSED;
import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.time.ParcelableTestSupport.assertEqualsAndHashCode;
import static android.app.time.ParcelableTestSupport.assertRoundTripParcelable;
import static com.google.common.truth.Truth.assertThat;
@@ -55,7 +56,7 @@ public class TimeCapabilitiesTest {
{
TimeCapabilities one = builder1.build();
TimeCapabilities two = builder2.build();
assertEquals(one, two);
assertEqualsAndHashCode(one, two);
}
builder2.setConfigureAutoDetectionEnabledCapability(CAPABILITY_NOT_ALLOWED);
@@ -69,7 +70,7 @@ public class TimeCapabilitiesTest {
{
TimeCapabilities one = builder1.build();
TimeCapabilities two = builder2.build();
assertEquals(one, two);
assertEqualsAndHashCode(one, two);
}
builder2.setSetManualTimeCapability(CAPABILITY_NOT_ALLOWED);
@@ -83,7 +84,7 @@ public class TimeCapabilitiesTest {
{
TimeCapabilities one = builder1.build();
TimeCapabilities two = builder2.build();
assertEquals(one, two);
assertEqualsAndHashCode(one, two);
}
}

View File

@@ -16,7 +16,8 @@
package android.app.time;
import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.time.ParcelableTestSupport.assertEqualsAndHashCode;
import static android.app.time.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.timezonedetector.ShellCommandTestSupport.createShellCommandWithArgsAndOptions;
import static org.junit.Assert.assertEquals;
@@ -52,11 +53,6 @@ public class TimeStateTest {
assertNotEquals(time1False_1, time2False);
}
private static void assertEqualsAndHashCode(Object one, Object two) {
assertEquals(one, two);
assertEquals(one.hashCode(), two.hashCode());
}
@Test
public void testParceling() {
UnixEpochTime time = new UnixEpochTime(1, 2);

View File

@@ -18,7 +18,7 @@ package android.app.time;
import static android.app.time.Capabilities.CAPABILITY_NOT_ALLOWED;
import static android.app.time.Capabilities.CAPABILITY_POSSESSED;
import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.time.ParcelableTestSupport.assertRoundTripParcelable;
import static com.google.common.truth.Truth.assertThat;

View File

@@ -16,7 +16,8 @@
package android.app.time;
import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.time.ParcelableTestSupport.assertEqualsAndHashCode;
import static android.app.time.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.timezonedetector.ShellCommandTestSupport.createShellCommandWithArgsAndOptions;
import static org.junit.Assert.assertEquals;
@@ -52,11 +53,6 @@ public class TimeZoneStateTest {
assertNotEquals(zone1False_1, zone2False);
}
private static void assertEqualsAndHashCode(Object one, Object two) {
assertEquals(one, two);
assertEquals(one.hashCode(), two.hashCode());
}
@Test
public void testParceling() {
assertRoundTripParcelable(new TimeZoneState("Europe/London", true));

View File

@@ -16,8 +16,8 @@
package android.app.timedetector;
import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.timezonedetector.ParcelableTestSupport.roundTripParcelable;
import static android.app.time.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.time.ParcelableTestSupport.roundTripParcelable;
import static android.app.timezonedetector.ShellCommandTestSupport.createShellCommandWithArgsAndOptions;
import static org.junit.Assert.assertEquals;

View File

@@ -16,8 +16,8 @@
package android.app.timedetector;
import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.timezonedetector.ParcelableTestSupport.roundTripParcelable;
import static android.app.time.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.time.ParcelableTestSupport.roundTripParcelable;
import static android.app.timezonedetector.ShellCommandTestSupport.createShellCommandWithArgsAndOptions;
import static org.junit.Assert.assertEquals;

View File

@@ -16,8 +16,8 @@
package android.app.timezonedetector;
import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.timezonedetector.ParcelableTestSupport.roundTripParcelable;
import static android.app.time.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.time.ParcelableTestSupport.roundTripParcelable;
import static android.app.timezonedetector.ShellCommandTestSupport.createShellCommandWithArgsAndOptions;
import static org.junit.Assert.assertEquals;

View File

@@ -16,8 +16,8 @@
package android.app.timezonedetector;
import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.timezonedetector.ParcelableTestSupport.roundTripParcelable;
import static android.app.time.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.time.ParcelableTestSupport.roundTripParcelable;
import static android.app.timezonedetector.ShellCommandTestSupport.createShellCommandWithArgsAndOptions;
import static org.junit.Assert.assertEquals;

View File

@@ -16,7 +16,7 @@
package android.service.timezone;
import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.time.ParcelableTestSupport.assertRoundTripParcelable;
import static android.service.timezone.TimeZoneProviderEvent.EVENT_TYPE_PERMANENT_FAILURE;
import static android.service.timezone.TimeZoneProviderEvent.EVENT_TYPE_SUGGESTION;
import static android.service.timezone.TimeZoneProviderEvent.EVENT_TYPE_UNCERTAIN;

View File

@@ -16,7 +16,7 @@
package android.service.timezone;
import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.time.ParcelableTestSupport.assertRoundTripParcelable;
import static android.service.timezone.TimeZoneProviderStatus.DEPENDENCY_STATUS_BLOCKED_BY_ENVIRONMENT;
import static android.service.timezone.TimeZoneProviderStatus.DEPENDENCY_STATUS_BLOCKED_BY_SETTINGS;
import static android.service.timezone.TimeZoneProviderStatus.DEPENDENCY_STATUS_OK;

View File

@@ -128,4 +128,5 @@ final class EnvironmentImpl implements TimeDetectorStrategyImpl.Environment {
@Override
public void dumpDebugLog(@NonNull PrintWriter printWriter) {
SystemClockTime.dump(printWriter);
}}
}
}