Make FileLogTest use robolectric
This allows it to run fast locally on the JVM without an emulator or physical device. Change-Id: Idb9c94e6f3fce94a86978ea0709eadd72280432c
This commit is contained in:
parent
b1513bd811
commit
499a0c932e
|
@ -1,13 +1,11 @@
|
||||||
package com.android.launcher3.logging;
|
package com.android.launcher3.logging;
|
||||||
|
|
||||||
import androidx.test.InstrumentationRegistry;
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
@ -20,8 +18,7 @@ import static org.junit.Assert.assertTrue;
|
||||||
/**
|
/**
|
||||||
* Tests for {@link FileLog}
|
* Tests for {@link FileLog}
|
||||||
*/
|
*/
|
||||||
@SmallTest
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class FileLogTest {
|
public class FileLogTest {
|
||||||
|
|
||||||
private File mTempDir;
|
private File mTempDir;
|
||||||
|
@ -30,9 +27,9 @@ public class FileLogTest {
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
do {
|
do {
|
||||||
mTempDir = new File(InstrumentationRegistry.getTargetContext().getCacheDir(),
|
mTempDir = new File(RuntimeEnvironment.application.getCacheDir(),
|
||||||
"log-test-" + (count++));
|
"log-test-" + (count++));
|
||||||
} while(!mTempDir.mkdir());
|
} while (!mTempDir.mkdir());
|
||||||
|
|
||||||
FileLog.setDir(mTempDir);
|
FileLog.setDir(mTempDir);
|
||||||
}
|
}
|
Loading…
Reference in New Issue