Add test case for dark theme scheduler.

Bug: 189722519
Test: atest com.android.settings.display.darkmode.DarkThemeScheduleComponentTest
Change-Id: I94cbff123af0eaef7834aa636e3b38c6da3f2235
This commit is contained in:
Syaoran Kuo
2021-06-15 14:25:41 +08:00
parent 483b89c575
commit 278b1e8cce
3 changed files with 192 additions and 0 deletions

View File

@@ -23,9 +23,11 @@ import android.util.Log;
import androidx.test.platform.app.InstrumentationRegistry;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
import java.util.stream.Collectors;
public class AdbUtils {
public static boolean checkStringInAdbCommandOutput(String logTag, String command,
@@ -59,4 +61,23 @@ public class AdbUtils {
return false;
}
public static String shell(String shellCommand) {
String returnValue = "";
try (ParcelFileDescriptor.AutoCloseInputStream in =
new ParcelFileDescriptor.AutoCloseInputStream(
InstrumentationRegistry.getInstrumentation()
.getUiAutomation()
.executeShellCommand(shellCommand))) {
try (BufferedReader br =
new BufferedReader(
new InputStreamReader(in, StandardCharsets.UTF_8))) {
returnValue = br.lines().collect(Collectors.joining());
}
} catch (IOException e) {
e.printStackTrace();
}
return returnValue;
}
}