roll libyuv to r1450 from r1444. Adds direct YUY2ToNV12 and UYVYToNV12 conversions...
[chromium-blink-merge.git] / build / android / gyp / util / md5_check_test.py
blob4f89fc2be83267733c4bd979a65f4243b057156a
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import tempfile
6 import unittest
8 import md5_check # pylint: disable=W0403
11 class TestMd5Check(unittest.TestCase):
12 def setUp(self):
13 self.called = False
15 def testCallAndRecordIfStale(self):
16 input_strings = ['string1', 'string2']
17 input_file1 = tempfile.NamedTemporaryFile()
18 input_file2 = tempfile.NamedTemporaryFile()
19 file1_contents = 'input file 1'
20 file2_contents = 'input file 2'
21 input_file1.write(file1_contents)
22 input_file1.flush()
23 input_file2.write(file2_contents)
24 input_file2.flush()
25 input_files = [input_file1.name, input_file2.name]
27 record_path = tempfile.NamedTemporaryFile(suffix='.stamp')
29 def CheckCallAndRecord(should_call, message, force=False):
30 self.called = False
31 def MarkCalled():
32 self.called = True
33 md5_check.CallAndRecordIfStale(
34 MarkCalled,
35 record_path=record_path.name,
36 input_paths=input_files,
37 input_strings=input_strings,
38 force=force)
39 self.failUnlessEqual(should_call, self.called, message)
41 CheckCallAndRecord(True, 'should call when record doesn\'t exist')
42 CheckCallAndRecord(False, 'should not call when nothing changed')
43 CheckCallAndRecord(True, force=True, message='should call when forced')
45 input_file1.write('some more input')
46 input_file1.flush()
47 CheckCallAndRecord(True, 'changed input file should trigger call')
49 input_files = input_files[::-1]
50 CheckCallAndRecord(False, 'reordering of inputs shouldn\'t trigger call')
52 input_files = input_files[:1]
53 CheckCallAndRecord(True, 'removing file should trigger call')
55 input_files.append(input_file2.name)
56 CheckCallAndRecord(True, 'added input file should trigger call')
58 input_strings[0] = input_strings[0] + ' a bit longer'
59 CheckCallAndRecord(True, 'changed input string should trigger call')
61 input_strings = input_strings[::-1]
62 CheckCallAndRecord(True, 'reordering of string inputs should trigger call')
64 input_strings = input_strings[:1]
65 CheckCallAndRecord(True, 'removing a string should trigger call')
67 input_strings.append('a brand new string')
68 CheckCallAndRecord(True, 'added input string should trigger call')
71 if __name__ == '__main__':
72 unittest.main()