chrome_names_unittest.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Lint as: python3
  2. # Copyright 2020 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """Unit tests for dependency_analysis.print_dependencies_helper."""
  6. import unittest
  7. import chrome_names
  8. class TestChromeNames_ShortenClass(unittest.TestCase):
  9. """Unit tests for shorten_class."""
  10. def test_shorten_chrome_browser_class(self):
  11. self.assertEqual(
  12. '.c.b.flags.ChromeFeatureList',
  13. chrome_names.shorten_class(
  14. 'org.chromium.chrome.browser.flags.ChromeFeatureList'))
  15. def test_shorten_base_class(self):
  16. self.assertEqual(
  17. '.base.Callback',
  18. chrome_names.shorten_class('org.chromium.base.Callback'))
  19. def test_shorten_components_class(self):
  20. self.assertEqual(
  21. '.components.prefs.PrefService',
  22. chrome_names.shorten_class(
  23. 'org.chromium.components.prefs.PrefService'))
  24. def test_does_not_shorten_third_party_class(self):
  25. self.assertEqual('org.other_project.Class',
  26. chrome_names.shorten_class('org.other_project.Class'))
  27. class TestChromeNames_ShortenBuildTarget(unittest.TestCase):
  28. """Unit tests for shorten_build_target."""
  29. def test_shorten_chrome_java(self):
  30. self.assertEqual(
  31. 'chrome_java',
  32. chrome_names.shorten_build_target('//chrome/android:chrome_java'))
  33. def test_shorten_chrome_browser(self):
  34. self.assertEqual(
  35. '//c/b/flags:java',
  36. chrome_names.shorten_build_target('//chrome/browser/flags:java'))
  37. def test_does_not_shorten_other_directories(self):
  38. self.assertEqual('//base:base_java',
  39. chrome_names.shorten_build_target('//base:base_java'))