Fix JobStoreTest after adding defensive copy to NetworkRequest.Builder
JobStatus.createFromJobInfo() uses the NetworkRequest.Builder(NetworkRequest) API, which previously failed to create a copy of the passed NetworkRequest. This means, that up until now, SOME_UID was not only set on the second job status, but also on the first, as the NetworkRequest used came from first.getRequiredNetwork(). Since JobStatus changes the JobInfo object, the second JobInfo object should be compared a a JobInfo object that has also been changed by JobStatus in the same way. Test: atest JobStoreTest Bug: 233580437 Change-Id: Ic4584575e2bc092c49b7b9ecb9b115da189bdfed
This commit is contained in:
@@ -475,15 +475,16 @@ public class JobStoreTest {
|
||||
* Helper function to kick a {@link JobInfo} through a persistence cycle and
|
||||
* assert that it's unchanged.
|
||||
*/
|
||||
private void assertPersistedEquals(JobInfo first) throws Exception {
|
||||
private void assertPersistedEquals(JobInfo firstInfo) throws Exception {
|
||||
mTaskStoreUnderTest.clear();
|
||||
mTaskStoreUnderTest.add(JobStatus.createFromJobInfo(first, SOME_UID, null, -1, null));
|
||||
JobStatus first = JobStatus.createFromJobInfo(firstInfo, SOME_UID, null, -1, null);
|
||||
mTaskStoreUnderTest.add(first);
|
||||
waitForPendingIo();
|
||||
|
||||
final JobSet jobStatusSet = new JobSet();
|
||||
mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet, true);
|
||||
final JobStatus second = jobStatusSet.getAllJobs().iterator().next();
|
||||
assertTasksEqual(first, second.getJob());
|
||||
assertTasksEqual(first.getJob(), second.getJob());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user