1 #!/usr/bin/env python 2 # Copyright (c) 2012 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 6 import unittest 7 8 from layouttests import LayoutTests 9 from test_expectations import TestExpectations 10 11 12 class TestLayoutTests(unittest.TestCase): 13 """Unit tests for the LayoutTests class.""" 14 15 def testJoinWithTestExpectation(self): 16 layouttests = LayoutTests(parent_location_list=['media/']) 17 test_expectations = TestExpectations() 18 test_info_map = layouttests.JoinWithTestExpectation(test_expectations) 19 # TODO(imasaki): have better assertion below. Currently, the test 20 # expectation file is obtained dynamically so the strict assertion is 21 # impossible. 22 self.assertTrue(any(['media/' in k for k in test_info_map.keys()]), 23 msg=('Analyzer result should contain at least one ' 24 'media test cases since we only retrieved media ' 25 'related test')) 26 27 def testGetTestDescriptionsFromSVN(self): 28 desc1 = LayoutTests.GetTestDescriptionFromSVN( 29 'media/video-play-empty-events.html') 30 self.assertEquals(desc1, 31 ('Test that play() from EMPTY network state triggers ' 32 'load() and async play event.'), 33 msg='Extracted test description is wrong') 34 desc2 = LayoutTests.GetTestDescriptionFromSVN('jquery/data.html') 35 self.assertEquals(desc2, 'UNKNOWN', 36 msg='Extracted test description is wrong') 37 38 def testGetParentDirectoryList(self): 39 testname_list = ['hoge1/hoge2/hoge3.html', 'hoge1/x.html', 40 'hoge1/hoge2/hoge4.html'] 41 expected_result = ['hoge1/', 'hoge1/hoge2/'] 42 self.assertEquals(LayoutTests.GetParentDirectoryList(testname_list), 43 expected_result) 44 45 46 if __name__ == '__main__': 47 unittest.main() 48