Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3421c3c authored by Yu Shan's avatar Yu Shan
Browse files

Support '--user-hal' in FakeVehicleHardware.

Support dump fake user hal command in FakeVehicleHardware.

Test: atest FakeVehicleHardwareTest
Bug: 228218366
Change-Id: I9884a1a216d07da6ccb58af1fa869266c959f80c
parent 6923449c
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -577,6 +577,12 @@ DumpResult FakeVehicleHardware::dump(const std::vector<std::string>& options) {
        result.buffer = dumpSpecificProperty(options);
    } else if (EqualsIgnoreCase(option, "--set")) {
        result.buffer = dumpSetProperties(options);
    } else if (EqualsIgnoreCase(option, kUserHalDumpOption)) {
        if (options.size() == 1) {
            result.buffer = mFakeUserHal->showDumpHelp();
        } else {
            result.buffer = mFakeUserHal->dump(options[1]);
        }
    } else {
        result.buffer = StringPrintf("Invalid option: %s\n", option.c_str());
    }
@@ -594,7 +600,9 @@ std::string FakeVehicleHardware::dumpHelp() {
           "[-b BYTES_VALUE] [-a AREA_ID] : sets the value of property PROP. "
           "Notice that the string, bytes and area value can be set just once, while the other can"
           " have multiple values (so they're used in the respective array), "
           "BYTES_VALUE is in the form of 0xXXXX, e.g. 0xdeadbeef.\n";
           "BYTES_VALUE is in the form of 0xXXXX, e.g. 0xdeadbeef.\n\n"
           "Fake user HAL usage: \n" +
           mFakeUserHal->showDumpHelp();
}

std::string FakeVehicleHardware::dumpAllProperties() {
+22 −0
Original line number Diff line number Diff line
@@ -1405,6 +1405,28 @@ TEST_F(FakeVehicleHardwareTest, testDumpInvalidOptions) {
    ASSERT_THAT(result.buffer, ContainsRegex("Invalid option: --invalid"));
}

TEST_F(FakeVehicleHardwareTest, testDumpFakeUserHalHelp) {
    std::vector<std::string> options;
    options.push_back("--user-hal");

    DumpResult result = getHardware()->dump(options);
    ASSERT_FALSE(result.callerShouldDumpState);
    ASSERT_NE(result.buffer, "");
    ASSERT_THAT(result.buffer, ContainsRegex("dumps state used for user management"));
}

TEST_F(FakeVehicleHardwareTest, testDumpFakeUserHal) {
    std::vector<std::string> options;
    options.push_back("--user-hal");
    // Indent: " ".
    options.push_back(" ");

    DumpResult result = getHardware()->dump(options);
    ASSERT_FALSE(result.callerShouldDumpState);
    ASSERT_NE(result.buffer, "");
    ASSERT_THAT(result.buffer, ContainsRegex(" No InitialUserInfo response\n"));
}

struct SetPropTestCase {
    std::string test_name;
    std::vector<std::string> options;