| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import unittest | 6 import unittest |
| 7 | 7 |
| 8 from chroot_file_system import ChrootFileSystem | 8 from chroot_file_system import ChrootFileSystem |
| 9 from file_system import StatInfo | 9 from file_system import StatInfo |
| 10 from test_file_system import TestFileSystem | 10 from test_file_system import TestFileSystem |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 }, _SortListValues(chroot_fs.Read( | 55 }, _SortListValues(chroot_fs.Read( |
| 56 ('moremanifest/usb.html', '', 'moremanifest/', 'sockets.html') | 56 ('moremanifest/usb.html', '', 'moremanifest/', 'sockets.html') |
| 57 ).Get())) | 57 ).Get())) |
| 58 | 58 |
| 59 def testEmptyRoot(self): | 59 def testEmptyRoot(self): |
| 60 chroot_fs = ChrootFileSystem(self._test_fs, '') | 60 chroot_fs = ChrootFileSystem(self._test_fs, '') |
| 61 self.assertEqual('404.html contents', | 61 self.assertEqual('404.html contents', |
| 62 chroot_fs.ReadSingle('404.html').Get()) | 62 chroot_fs.ReadSingle('404.html').Get()) |
| 63 | 63 |
| 64 def testStat(self): | 64 def testStat(self): |
| 65 self._test_fs.IncrementStat('extensions/manifest/', by=2) | 65 self._test_fs.IncrementStat('extensions/manifest/sockets.html', by=2) |
| 66 self._test_fs.IncrementStat('extensions/manifest/moremanifest/csp.html') | 66 self._test_fs.IncrementStat('extensions/manifest/moremanifest/csp.html') |
| 67 for prefix in ('', '/'): | 67 for prefix in ('', '/'): |
| 68 for suffix in ('', '/'): | 68 for suffix in ('', '/'): |
| 69 chroot_fs = ChrootFileSystem(self._test_fs, | 69 chroot_fs = ChrootFileSystem(self._test_fs, |
| 70 prefix + 'extensions' + suffix) | 70 prefix + 'extensions' + suffix) |
| 71 self.assertEqual(StatInfo('0', child_versions={ | 71 self.assertEqual(StatInfo('2', child_versions={ |
| 72 'activeTab.html': '0', | 72 'activeTab.html': '0', |
| 73 'alarms.html': '0', | 73 'alarms.html': '0', |
| 74 'manifest/': '2', | 74 'manifest/': '2', |
| 75 }), chroot_fs.Stat('')) | 75 }), chroot_fs.Stat('')) |
| 76 self.assertEqual(StatInfo('0'), chroot_fs.Stat('activeTab.html')) | 76 self.assertEqual(StatInfo('0'), chroot_fs.Stat('activeTab.html')) |
| 77 self.assertEqual(StatInfo('2', child_versions={ | 77 self.assertEqual(StatInfo('2', child_versions={ |
| 78 'moremanifest/': '0', | 78 'moremanifest/': '1', |
| 79 'sockets.html': '0', | 79 'sockets.html': '2', |
| 80 }), chroot_fs.Stat('manifest/')) | 80 }), chroot_fs.Stat('manifest/')) |
| 81 self.assertEqual(StatInfo('0'), chroot_fs.Stat('manifest/sockets.html')) | 81 self.assertEqual(StatInfo('2'), chroot_fs.Stat('manifest/sockets.html')) |
| 82 self.assertEqual(StatInfo('0', child_versions={ | 82 self.assertEqual(StatInfo('1', child_versions={ |
| 83 'csp.html': '1', | 83 'csp.html': '1', |
| 84 'usb.html': '0', | 84 'usb.html': '0', |
| 85 }), chroot_fs.Stat('manifest/moremanifest/')) | 85 }), chroot_fs.Stat('manifest/moremanifest/')) |
| 86 self.assertEqual(StatInfo('1'), | 86 self.assertEqual(StatInfo('1'), |
| 87 chroot_fs.Stat('manifest/moremanifest/csp.html')) | 87 chroot_fs.Stat('manifest/moremanifest/csp.html')) |
| 88 self.assertEqual(StatInfo('0'), | 88 self.assertEqual(StatInfo('0'), |
| 89 chroot_fs.Stat('manifest/moremanifest/usb.html')) | 89 chroot_fs.Stat('manifest/moremanifest/usb.html')) |
| 90 | 90 |
| 91 def testIdentity(self): | 91 def testIdentity(self): |
| 92 chroot_fs1 = ChrootFileSystem(self._test_fs, '1') | 92 chroot_fs1 = ChrootFileSystem(self._test_fs, '1') |
| 93 chroot_fs1b = ChrootFileSystem(self._test_fs, '1') | 93 chroot_fs1b = ChrootFileSystem(self._test_fs, '1') |
| 94 chroot_fs2 = ChrootFileSystem(self._test_fs, '2') | 94 chroot_fs2 = ChrootFileSystem(self._test_fs, '2') |
| 95 self.assertNotEqual(self._test_fs.GetIdentity(), chroot_fs1.GetIdentity()) | 95 self.assertNotEqual(self._test_fs.GetIdentity(), chroot_fs1.GetIdentity()) |
| 96 self.assertNotEqual(self._test_fs.GetIdentity(), chroot_fs2.GetIdentity()) | 96 self.assertNotEqual(self._test_fs.GetIdentity(), chroot_fs2.GetIdentity()) |
| 97 self.assertNotEqual(chroot_fs1.GetIdentity(), chroot_fs2.GetIdentity()) | 97 self.assertNotEqual(chroot_fs1.GetIdentity(), chroot_fs2.GetIdentity()) |
| 98 self.assertEqual(chroot_fs1.GetIdentity(), chroot_fs1b.GetIdentity()) | 98 self.assertEqual(chroot_fs1.GetIdentity(), chroot_fs1b.GetIdentity()) |
| 99 | 99 |
| 100 | 100 |
| 101 if __name__ == '__main__': | 101 if __name__ == '__main__': |
| 102 unittest.main() | 102 unittest.main() |
| OLD | NEW |