1#! /usr/bin/env vpython3 2# Copyright 2016 The Chromium Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import os 7import unittest 8 9from pylib import constants 10from pylib.utils import device_dependencies 11 12 13class DevicePathComponentsForTest(unittest.TestCase): 14 15 def testCheckedInFile(self): 16 test_path = os.path.join(constants.DIR_SOURCE_ROOT, 'foo', 'bar', 'baz.txt') 17 output_directory = os.path.join( 18 constants.DIR_SOURCE_ROOT, 'out-foo', 'Release') 19 self.assertEqual([None, 'foo', 'bar', 'baz.txt'], 20 device_dependencies.DevicePathComponentsFor( 21 test_path, output_directory)) 22 23 def testOutputDirectoryFile(self): 24 test_path = os.path.join(constants.DIR_SOURCE_ROOT, 'out-foo', 'Release', 25 'icudtl.dat') 26 output_directory = os.path.join( 27 constants.DIR_SOURCE_ROOT, 'out-foo', 'Release') 28 self.assertEqual([None, 'icudtl.dat'], 29 device_dependencies.DevicePathComponentsFor( 30 test_path, output_directory)) 31 32 def testOutputDirectorySubdirFile(self): 33 test_path = os.path.join(constants.DIR_SOURCE_ROOT, 'out-foo', 'Release', 34 'test_dir', 'icudtl.dat') 35 output_directory = os.path.join( 36 constants.DIR_SOURCE_ROOT, 'out-foo', 'Release') 37 self.assertEqual([None, 'test_dir', 'icudtl.dat'], 38 device_dependencies.DevicePathComponentsFor( 39 test_path, output_directory)) 40 41 def testOutputDirectoryPakFile(self): 42 test_path = os.path.join(constants.DIR_SOURCE_ROOT, 'out-foo', 'Release', 43 'foo.pak') 44 output_directory = os.path.join( 45 constants.DIR_SOURCE_ROOT, 'out-foo', 'Release') 46 self.assertEqual([None, 'paks', 'foo.pak'], 47 device_dependencies.DevicePathComponentsFor( 48 test_path, output_directory)) 49 50 51if __name__ == '__main__': 52 unittest.main() 53