Merge "Implemented AtomicFile.toString()"
This commit is contained in:
@@ -330,6 +330,11 @@ public class AtomicFile {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AtomicFile[" + mBaseName + "]";
|
||||
}
|
||||
|
||||
private static void rename(File source, File target) {
|
||||
// We used to delete the target file before rename, but that isn't atomic, and the rename()
|
||||
// syscall should atomically replace the target file. However in the case where the target
|
||||
|
||||
@@ -33,6 +33,7 @@ android_test {
|
||||
"frameworks-base-testutils",
|
||||
"mockito-target-minus-junit4",
|
||||
"androidx.test.ext.junit",
|
||||
"truth-prebuilt",
|
||||
],
|
||||
|
||||
libs: [
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.util;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -257,6 +259,16 @@ public class AtomicFileTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() throws Exception {
|
||||
AtomicFile atomicFile = new AtomicFile(mBaseFile);
|
||||
|
||||
String toString = atomicFile.toString();
|
||||
|
||||
assertThat(toString).contains("AtomicFile");
|
||||
assertThat(toString).contains(mBaseFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
private static void writeBytes(@NonNull File file, @NonNull byte[] bytes) throws IOException {
|
||||
try (FileOutputStream outputStream = new FileOutputStream(file)) {
|
||||
outputStream.write(bytes);
|
||||
|
||||
Reference in New Issue
Block a user