vidstige / jadb

ADB Client in pure Java.
Apache License 2.0
640 stars 178 forks source link

Allow multi-byte characters in payload #112

Closed phantamanta44 closed 5 years ago

phantamanta44 commented 5 years ago

At the moment, JadbDevice#list fails if the dir name contains multi-byte characters (for example, chinese characters) because it makes the assumption that each character is only one byte

vidstige commented 5 years ago

Nice catch! And thanks for the PR. If you got the time, could you please add a unit test case also for this? In MockedTestCases.java for example.

Some example code to get you started. Note: I haven't tried this or compiled.

    @Test
    public void testListMultibyte() throws Exception {
        server.add("serial-123");
        server.expectList("serial-123", "/remote/path").withContent(new String[]{"normal.file", "multibyte example here please :-).extension"});
        JadbDevice device = connection.getDevices().get(0);
        List<RemoteFile> files = device.list("/remote/path");
        // TODO: Assert files contains correct file names
    }
janosvitok commented 5 years ago

Note: expectList is not implemented (or I didn't find it). Implementing it is the main thing to do here. Once you have expectList the actual unit test is trivial.

phantamanta44 commented 5 years ago

turns out there were no existing facilities whatsoever for testing file listing, so i just implemented all of that as well as the unicode thing

phantamanta44 commented 5 years ago

tested on my LG V35