From 08d0622fa5cd87be5d94ade946003656a53ba76a Mon Sep 17 00:00:00 2001 From: Spencer Low Date: Tue, 10 Nov 2015 23:30:35 -0800 Subject: [PATCH] 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 --- python-packages/adb/test_device.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/python-packages/adb/test_device.py b/python-packages/adb/test_device.py index 0b1bb641d..0b24bf739 100644 --- a/python-packages/adb/test_device.py +++ b/python-packages/adb/test_device.py @@ -917,20 +917,24 @@ class FileOperationsTest(DeviceTest): """Ensure that we can support non-ASCII paths, even on Windows.""" name = u'로보카 폴리' + self.device.shell(['rm', '-f', '/data/local/tmp/adb-test-*']) + remote_path = u'/data/local/tmp/adb-test-{}'.format(name) + ## push. tf = tempfile.NamedTemporaryFile('wb', suffix=name, delete=False) 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) - 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. - cmd = ['touch', u'"/data/local/tmp/adb-test-{}"'.format(name)] - self.device.shell(cmd) - - tf = tempfile.NamedTemporaryFile('wb', suffix=name, delete=False) - tf.close() - self.device.pull(u'/data/local/tmp/adb-test-{}'.format(name), tf.name) + self.device.pull(remote_path, tf.name) + self.assertTrue(os.path.exists(tf.name)) os.remove(tf.name) self.device.shell(['rm', '-f', '/data/local/tmp/adb-test-*'])