Assert and verify setting system property in UserManagerServiceTest.

Bug: 264667464
Bug: 264667776
Bug: 264666926
Test: atest FrameworksServicesTests:com.android.server.pm.UserManagerServiceTest
Change-Id: Iaa90d1d6470220e915fdb2088d3865483ee243c5
This commit is contained in:
Yasin Kilicdere
2023-07-03 14:49:24 +01:00
parent 25b51a1a18
commit 5a8660b97e

View File

@@ -19,6 +19,7 @@ package com.android.server.pm;
import static android.os.UserManager.DISALLOW_USER_SWITCH;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import android.app.ActivityManager;
import android.app.PropertyInvalidatedCache;
@@ -28,6 +29,7 @@ import android.os.Bundle;
import android.os.FileUtils;
import android.os.Looper;
import android.os.Parcelable;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.platform.test.annotations.Postsubmit;
@@ -307,8 +309,10 @@ public class UserManagerServiceTest {
private static String setSystemProperty(String name, String value) throws Exception {
final String oldValue = runShellCommand("getprop " + name);
assertThat(runShellCommand("setprop " + name + " " + value))
.isEqualTo("");
assertWithMessage("can not set system property")
.that(runShellCommand("setprop " + name + " " + value)).isEqualTo("");
assertWithMessage("failed to set system property")
.that(SystemProperties.get(name)).isEqualTo(value);
return oldValue;
}