X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftools%2Fperf%2Fpage_sets%2Fpresubmit_unittest.py;h=6e8962d354e90d33a48e2c2f1f3c3ab5bc2b80bd;hb=004985e17e624662a4c85c76a7654039dc83f028;hp=9e3a0a9dde38157d1eb73c2baabdc860b1cfd74e;hpb=2f108dbacb161091e42a3479f4e171339b7e7623;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/tools/perf/page_sets/presubmit_unittest.py b/src/tools/perf/page_sets/presubmit_unittest.py index 9e3a0a9..6e8962d 100644 --- a/src/tools/perf/page_sets/presubmit_unittest.py +++ b/src/tools/perf/page_sets/presubmit_unittest.py @@ -16,25 +16,42 @@ from page_sets import PRESUBMIT class AffectedFileStub(object): - def __init__(self, absolute_local_path): + def __init__(self, absolute_local_path, action): self._absolute_local_path = absolute_local_path + self.action = action def AbsoluteLocalPath(self): return self._absolute_local_path + def Action(self): + return self.action class InputAPIStub(object): - def __init__(self, paths, deleted_paths=None): + def __init__(self, paths, deleted_paths=None, added_paths=None): self._paths = paths - if deleted_paths: - self._deleted_paths = deleted_paths - else: - self._deleted_paths = [] + self._deleted_paths = deleted_paths if deleted_paths else [] + self._added_paths = added_paths if added_paths else [] + + def AffectedFiles(self, include_deletes=True, file_filter=None): + if not file_filter: + file_filter = lambda x: True + + affected_files = [] + for path in self._paths: + affected_file_stub = AffectedFileStub(path, 'M') + if file_filter(affected_file_stub): + affected_files.append(affected_file_stub) + + for path in self._added_paths: + affected_file_stub = AffectedFileStub(path, 'A') + if file_filter(affected_file_stub): + affected_files.append(affected_file_stub) - def AffectedFiles(self, include_deletes=True): - affected_files = [AffectedFileStub(path) for path in self._paths] if include_deletes: - affected_files += [AffectedFileStub(path) for path in self._deleted_paths] + for path in self._deleted_paths: + affected_file_stub = AffectedFileStub(path, 'D') + if file_filter(affected_file_stub): + affected_files.append(affected_file_stub) return affected_files def AbsoluteLocalPaths(self): @@ -99,8 +116,8 @@ class PresubmitTest(unittest.TestCase): msg='Expected %d notifications, but got %d. Results: %s' % (expected_notifications, actual_notifications, results)) - def _CheckUpload(self, paths, deleted_paths=None): - input_api = InputAPIStub(paths, deleted_paths) + def _CheckUpload(self, paths, deleted_paths=None, added_paths=None): + input_api = InputAPIStub(paths, deleted_paths, added_paths) return PRESUBMIT.CheckChangeOnUpload(input_api, OutputAPIStub()) def testIgnoreDeleted(self):