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>
This commit is contained in:
Spencer Low
2015-11-10 23:30:35 -08:00
parent 084d084bbc
commit 08d0622fa5

View File

@@ -917,20 +917,24 @@ class FileOperationsTest(DeviceTest):
"""Ensure that we can support non-ASCII paths, even on Windows.""" """Ensure that we can support non-ASCII paths, even on Windows."""
name = u'로보카 폴리' name = u'로보카 폴리'
self.device.shell(['rm', '-f', '/data/local/tmp/adb-test-*'])
remote_path = u'/data/local/tmp/adb-test-{}'.format(name)
## push. ## push.
tf = tempfile.NamedTemporaryFile('wb', suffix=name, delete=False) tf = tempfile.NamedTemporaryFile('wb', suffix=name, delete=False)
tf.close() tf.close()
self.device.push(tf.name, u'/data/local/tmp/adb-test-{}'.format(name)) self.device.push(tf.name, remote_path)
os.remove(tf.name) os.remove(tf.name)
self.device.shell(['rm', '-f', '/data/local/tmp/adb-test-*']) self.assertFalse(os.path.exists(tf.name))
# Verify that the device ended up with the expected UTF-8 path
output = self.device.shell(
['ls', '/data/local/tmp/adb-test-*'])[0].strip()
self.assertEqual(remote_path.encode('utf-8'), output)
# pull. # pull.
cmd = ['touch', u'"/data/local/tmp/adb-test-{}"'.format(name)] self.device.pull(remote_path, tf.name)
self.device.shell(cmd) self.assertTrue(os.path.exists(tf.name))
tf = tempfile.NamedTemporaryFile('wb', suffix=name, delete=False)
tf.close()
self.device.pull(u'/data/local/tmp/adb-test-{}'.format(name), tf.name)
os.remove(tf.name) os.remove(tf.name)
self.device.shell(['rm', '-f', '/data/local/tmp/adb-test-*']) self.device.shell(['rm', '-f', '/data/local/tmp/adb-test-*'])