Add clean up to SysuiBaseFragmentTest
Also, set up AAA++ test for inheritance. Test: atest SystemUITests Fixes: 2133482724 Change-Id: If2484040f613b3112c224e8001d6e617dc5005b8
This commit is contained in:
@@ -128,9 +128,16 @@ android_library {
|
||||
plugins: ["dagger2-compiler"],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "AAA-src",
|
||||
srcs: ["tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java"],
|
||||
path: "tests/src",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "SystemUI-tests-utils",
|
||||
srcs: [
|
||||
"tests/src/com/android/systemui/SysuiBaseFragmentTest.java",
|
||||
"tests/src/com/android/systemui/SysuiTestCase.java",
|
||||
"tests/src/com/android/systemui/TestableDependency.java",
|
||||
"tests/src/com/android/systemui/classifier/FalsingManagerFake.java",
|
||||
|
||||
@@ -110,6 +110,17 @@ public class AAAPlusPlusVerifySysuiRequiredTestPropertiesTest extends SysuiTestC
|
||||
private Collection<String> getClassNamesFromClassPath() {
|
||||
ClassPathScanner scanner = new ClassPathScanner(mContext.getPackageCodePath());
|
||||
|
||||
ChainedClassNameFilter filter = makeClassNameFilter();
|
||||
|
||||
try {
|
||||
return scanner.getClassPathEntries(filter);
|
||||
} catch (IOException e) {
|
||||
Log.e(getTag(), "Failed to scan classes", e);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
protected ChainedClassNameFilter makeClassNameFilter() {
|
||||
ChainedClassNameFilter filter = new ChainedClassNameFilter();
|
||||
|
||||
filter.add(new ExternalClassNameFilter());
|
||||
@@ -122,13 +133,7 @@ public class AAAPlusPlusVerifySysuiRequiredTestPropertiesTest extends SysuiTestC
|
||||
// the main SystemUI process. Therefore, exclude this package
|
||||
// from the base class whitelist.
|
||||
filter.add(s -> !s.startsWith("com.android.systemui.screenshot"));
|
||||
|
||||
try {
|
||||
return scanner.getClassPathEntries(filter);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to scan classes", e);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
return filter;
|
||||
}
|
||||
|
||||
private String getClsStr() {
|
||||
@@ -212,8 +217,12 @@ public class AAAPlusPlusVerifySysuiRequiredTestPropertiesTest extends SysuiTestC
|
||||
* as loggable to limit log spam during normal use.
|
||||
*/
|
||||
private void logDebug(String msg) {
|
||||
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
||||
Log.d(TAG, msg);
|
||||
if (Log.isLoggable(getTag(), Log.DEBUG)) {
|
||||
Log.d(getTag(), msg);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,10 @@ import com.android.systemui.utils.leaks.LeakCheckedTest;
|
||||
import com.android.systemui.utils.leaks.LeakCheckedTest.SysuiLeakCheck;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
public abstract class SysuiBaseFragmentTest extends BaseFragmentTest {
|
||||
|
||||
@@ -78,6 +80,11 @@ public abstract class SysuiBaseFragmentTest extends BaseFragmentTest {
|
||||
SystemUIFactory.cleanup();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void mockitoTeardown() {
|
||||
Mockito.framework().clearInlineMocks();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SysuiTestableContext getContext() {
|
||||
return new SysuiTestableContext(InstrumentationRegistry.getContext(), mLeakCheck);
|
||||
|
||||
Reference in New Issue
Block a user