Skip to content

Commit 08d0622

Browse files
adb unittest: make test_unicode_paths stricter
After pushing to a Unicode path, use 'adb shell ls' to verify that the path was created with the right name. This verifies that the UTF-16 to UTF-8 conversion is done properly. When pulling to a Unicode path, verify that the local file has been created with the expected name. This should test UTF-16 to UTF-8 (command line to internal data structures) and UTF-8 to UTF-16 (internal data structures to CreateFileW()). Change-Id: I8b80aae731cf0d058cb0c3259e7f58256e86b771 Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
1 parent 084d084 commit 08d0622

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

python-packages/adb/test_device.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -917,20 +917,24 @@ def test_unicode_paths(self):
917917
"""Ensure that we can support non-ASCII paths, even on Windows."""
918918
name = u'로보카 폴리'
919919

920+
self.device.shell(['rm', '-f', '/data/local/tmp/adb-test-*'])
921+
remote_path = u'/data/local/tmp/adb-test-{}'.format(name)
922+
920923
## push.
921924
tf = tempfile.NamedTemporaryFile('wb', suffix=name, delete=False)
922925
tf.close()
923-
self.device.push(tf.name, u'/data/local/tmp/adb-test-{}'.format(name))
926+
self.device.push(tf.name, remote_path)
924927
os.remove(tf.name)
925-
self.device.shell(['rm', '-f', '/data/local/tmp/adb-test-*'])
928+
self.assertFalse(os.path.exists(tf.name))
926929

927-
# pull.
928-
cmd = ['touch', u'"/data/local/tmp/adb-test-{}"'.format(name)]
929-
self.device.shell(cmd)
930+
# Verify that the device ended up with the expected UTF-8 path
931+
output = self.device.shell(
932+
['ls', '/data/local/tmp/adb-test-*'])[0].strip()
933+
self.assertEqual(remote_path.encode('utf-8'), output)
930934

931-
tf = tempfile.NamedTemporaryFile('wb', suffix=name, delete=False)
932-
tf.close()
933-
self.device.pull(u'/data/local/tmp/adb-test-{}'.format(name), tf.name)
935+
# pull.
936+
self.device.pull(remote_path, tf.name)
937+
self.assertTrue(os.path.exists(tf.name))
934938
os.remove(tf.name)
935939
self.device.shell(['rm', '-f', '/data/local/tmp/adb-test-*'])
936940

0 commit comments

Comments
 (0)