blob: 925db9bbc8a81bfd9089917d98c8fc6c92fd3434 [file] [log] [blame]
#!/usr/bin/env python
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import unittest
from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi, MockFile
class CheckChangeOnUploadTest(unittest.TestCase):
def testCheckPNGFormat(self):
correct_paths = [
'', # Check will be skipped for non-PNG files
wrong_paths = [
'expected.pdf.0.png', # Missing '_expected'
'test1_expected.0.png', # Missing '.pdf'
'test2_expected.pdf.png', # Missing page number
'test3_expected.pdf.x.png', # Wrong character for page number
'test4_expected_mac_skia.pdf.0.png', # Wrong order of keywords
'test5_expected_useskia.pdf.0.png', # Wrong keyword
mock_input_api = MockInputApi()
mock_output_api = MockOutputApi()
mock_input_api.files = map(MockFile, correct_paths + wrong_paths)
errors = map(str, PRESUBMIT._CheckPNGFormat(mock_input_api,
self.assertEqual(len(wrong_paths), len(errors))
self.assertFalse('' in errors[0])
for path, error in zip(wrong_paths, errors):
self.assertIn(path, error)
if __name__ == '__main__':