| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Verify that crx_id.py generates a reasonable string for a canned CRX file. | 7 """Verify that crx_id.py generates a reasonable string for a canned CRX file. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import crx_id | 10 import crx_id |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 self.assertEqual(crx_id.GetCRXHash(temp_unpacked_crx), | 56 self.assertEqual(crx_id.GetCRXHash(temp_unpacked_crx), |
| 57 self.UNPACKED_HASH_BYTES) | 57 self.UNPACKED_HASH_BYTES) |
| 58 self.assertTrue(crx_id.HasPublicKey(temp_unpacked_crx)) | 58 self.assertTrue(crx_id.HasPublicKey(temp_unpacked_crx)) |
| 59 shutil.rmtree(temp_unpacked_crx) | 59 shutil.rmtree(temp_unpacked_crx) |
| 60 | 60 |
| 61 def testFromFilePath(self): | 61 def testFromFilePath(self): |
| 62 """ Test calculation of extension id from file paths. """ | 62 """ Test calculation of extension id from file paths. """ |
| 63 self.assertEqual(crx_id.GetCRXAppID('/tmp/temp_extension', | 63 self.assertEqual(crx_id.GetCRXAppID('/tmp/temp_extension', |
| 64 from_file_path=True), | 64 from_file_path=True), |
| 65 'ajbbicncdkdlchpjplgjaglppbcbmaji') | 65 'ajbbicncdkdlchpjplgjaglppbcbmaji') |
| 66 |
| 67 def testFromWindowsPath(self): |
| 68 self.assertEqual(crx_id.GetCRXAppID('D:\Documents\chrome\test_extension', |
| 69 from_file_path=True, |
| 70 encode_path_for_windows=True), |
| 71 'ppjciedebanjecfjlgmjbodeknmlkplo') |
| 72 |
| 66 # Test drive letter normalization. | 73 # Test drive letter normalization. |
| 67 kWinPathId = 'popnagglbbhjlobnnbcjnckakjoegnjp' | 74 kWinPathId = 'fkdneihlpljnkeaganlandjfcdmglnoe' |
| 68 self.assertEqual(crx_id.GetCRXAppID('c:\temp_extension', | 75 self.assertEqual(crx_id.GetCRXAppID('c:\temp_extension', |
| 69 from_file_path=True), | 76 from_file_path=True, |
| 77 encode_path_for_windows=True), |
| 70 kWinPathId) | 78 kWinPathId) |
| 71 self.assertEqual(crx_id.GetCRXAppID('C:\temp_extension', | 79 self.assertEqual(crx_id.GetCRXAppID('C:\temp_extension', |
| 72 from_file_path=True), | 80 from_file_path=True, |
| 81 encode_path_for_windows=True), |
| 73 kWinPathId) | 82 kWinPathId) |
| 74 | 83 |
| 75 if __name__ == '__main__': | 84 if __name__ == '__main__': |
| 76 unittest.main() | 85 unittest.main() |
| OLD | NEW |