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
Change-Id: I46269fc7dba3888841ee8fe68a2e4c781b53a49d
diff --git a/functional_tests/hostside/src/com/android/game/qualification/test/VkJsonTests.java b/functional_tests/hostside/src/com/android/game/qualification/test/VkJsonTests.java
index ee75031..71396f9 100644
--- a/functional_tests/hostside/src/com/android/game/qualification/test/VkJsonTests.java
+++ b/functional_tests/hostside/src/com/android/game/qualification/test/VkJsonTests.java
@@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
-import static com.google.common.truth.Truth.assert_;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
@@ -89,10 +88,11 @@
try {
mVkJson = gson.fromJson(cmdString, VkJson.class);
} catch (JsonSyntaxException e) {
- assert_().fail(
+ assertWithMessage(
"Error parsing JSON from 'cmd gpu vkjson': %s\nresult: %s",
e.getMessage(),
- cmdString);
+ cmdString)
+ .fail();
}
assertThat(mVkJson.devices).isNotNull();
@@ -106,9 +106,8 @@
public void checkRequiredVersion() {
final long apiVersion = mVkJson.devices.get(0).properties.apiVersion;
final long vulkan11Version = 0x401000;
- assertWithMessage("Supported Vulkan version must be at least 1.1")
+ assertWithMessage("supported vulkan version: Supported Vulkan version must be at least 1.1")
.that(apiVersion)
- .named("supported vulkan version")
.isAtLeast(vulkan11Version);
}
@@ -126,10 +125,9 @@
List<String> extensions = mVkJson.devices.get(0).extensions.stream()
.map(it -> it.extensionName)
.collect(Collectors.toList());
- assertWithMessage("Required Vulkan extensions are not supported")
+ assertWithMessage("supported extensions: Required Vulkan extensions are not supported")
.that(extensions)
- .named("supported extensions")
- .containsAllIn(REQUIRED_EXTENSIONS);
+ .containsAtLeastElementsIn(REQUIRED_EXTENSIONS);
}
/**
@@ -143,25 +141,24 @@
final short SUBMINOR = 2;
final String DRIVER_CONFORMANCE_VERSION = MAJOR + "." + MINOR + "." + SUBMINOR;
- assertWithMessage("VK_KHR_driver_properties is not supported")
+ assertWithMessage("VK_KHR_driver_properties: VK_KHR_driver_properties is not supported")
.that(mVkJson.devices.get(0).VK_KHR_driver_properties)
- .named("VK_KHR_driver_properties")
.isNotNull();
VkPhysicalDeviceDriverPropertiesKHR properties =
mVkJson.devices.get(0).VK_KHR_driver_properties.driverPropertiesKHR;
- assertWithMessage("VK_KHR_driver_properties is not supported")
- .that(properties).named("driverPropertiesKHR").isNotNull();
+ assertWithMessage("driverPropertiesKHR: VK_KHR_driver_properties is not supported")
+ .that(properties).isNotNull();
VkConformanceVersionKHR version = properties.conformanceVersion;
- assertThat(version).named("driverPropertiesKHR.conformanceVersion").isNotNull();
+ assertWithMessage("driverPropertiesKHR.conformanceVersion").that(version).isNotNull();
String msg = "Driver conformance version must be at least " + DRIVER_CONFORMANCE_VERSION;
- assertWithMessage(msg).that(version.major).named("major version").isAtLeast(MAJOR);
+ assertWithMessage("major version: " + msg).that(version.major).isAtLeast(MAJOR);
if (version.major == MAJOR) {
- assertWithMessage(msg).that(version.minor).named("minor version").isAtLeast(MINOR);
+ assertWithMessage("minor version: " + msg).that(version.minor).isAtLeast(MINOR);
if (version.minor == MINOR) {
- assertWithMessage(msg).that(version.subminor).named("subminor version")
+ assertWithMessage("subminor version: " + msg).that(version.subminor)
.isAtLeast(SUBMINOR);
}
}
diff --git a/functional_tests/java/src/com/android/game/qualification/tests/ChoreoTest.java b/functional_tests/java/src/com/android/game/qualification/tests/ChoreoTest.java
index 56f8ffe..50ef351 100644
--- a/functional_tests/java/src/com/android/game/qualification/tests/ChoreoTest.java
+++ b/functional_tests/java/src/com/android/game/qualification/tests/ChoreoTest.java
@@ -67,9 +67,8 @@
int maxIndex = 0;
assertWithMessage(
- "Need an adequate amount of frames in order to test Choreographer")
+ "number of frames: Need an adequate amount of frames in order to test Choreographer")
.that(intervals.size())
- .named("number of frames")
.isGreaterThan(60);
for (int i = 0; i < intervals.size(); i++) {
@@ -91,15 +90,14 @@
// TODO: Handle phones with different refresh rates like 90Hz
assertWithMessage(
- "Choreographer callbacks must occur at roughly the same pace as the refresh rate")
+ "mean callback time: Choreographer callbacks must occur at roughly the same pace as "
+ + "the refresh rate")
.that(mean)
- .named("mean callback time")
.isIn(Range.closed(16.45, 16.75));
assertWithMessage(
- "Choreographer callbacks must not deviate too much from the mean")
+ "callback time range: Choreographer callbacks must not deviate too much from the mean")
.that(range)
- .named("callback time range")
.isLessThan(2.0);
}
}
diff --git a/functional_tests/java/src/com/android/game/qualification/tests/SurfaceFlingerTest.java b/functional_tests/java/src/com/android/game/qualification/tests/SurfaceFlingerTest.java
index 2196a16..2c1a27c 100644
--- a/functional_tests/java/src/com/android/game/qualification/tests/SurfaceFlingerTest.java
+++ b/functional_tests/java/src/com/android/game/qualification/tests/SurfaceFlingerTest.java
@@ -73,9 +73,9 @@
// because the latch time is slightly before the actual condition check in the
// surface flinger.
assertWithMessage(
- "SurfaceFlinger must latch after GPU work is completed for the frame")
+ "latch time: SurfaceFlinger must latch after GPU work is completed for the "
+ + "frame")
.that(latchTimes[i])
- .named("latch time")
.isGreaterThan(readyTimes[i] - 100_000);
}
}