OLD | NEW |
---|---|
(Empty) | |
1 # Copyright (c) 2014 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. | |
4 | |
5 import os | |
6 import sys | |
7 import imp | |
8 import unittest | |
9 import PRESUBMIT | |
10 | |
11 sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/' +'../../../')) | |
Alexei Svitkine (slow)
2014/11/12 22:27:00
Nit: Remove the second + and just have those strin
gayane -on leave until 09-2017
2014/11/15 00:09:09
Done.
| |
12 from PRESUBMIT_test_mockobjects import MockFile, MockInputApi, MockOutputApi | |
13 | |
14 _TEST_DATA_DIR = 'base/test/data/presubmit/' | |
15 | |
16 class HTMLActionAdditionTest(unittest.TestCase): | |
17 | |
18 def testActionXMLChanged(self): | |
19 mock_input_api = MockInputApi() | |
20 mock_input_api.files = [ | |
21 MockFile('path/valid.html', ''), | |
22 MockFile('actions.xml', '') ] | |
23 | |
24 warnings = PRESUBMIT.CheckUserActionUpdate(mock_input_api, MockOutputApi()) | |
25 self.assertEqual(0, len(warnings)) | |
26 | |
27 | |
28 def testValidChange(self): | |
29 lines = ['<input id="testinput" pref="testpref"', | |
30 'metric="validaction" type="checkbox" dialog-pref>'] | |
31 PRESUBMIT.action_xml_path = _TEST_DATA_DIR + "actions.xml" | |
Alexei Svitkine (slow)
2014/11/12 22:27:00
Instead of overriding this global, how about makin
gayane -on leave until 09-2017
2014/11/15 00:09:09
Done.
| |
32 mock_input_api = MockInputApi() | |
33 mock_input_api.files = [MockFile('path/test.html', lines)] | |
34 | |
35 warnings = PRESUBMIT.CheckUserActionUpdate(mock_input_api, MockOutputApi()) | |
36 self.assertEqual(0, len(warnings)) | |
37 | |
38 | |
39 def testInvalidChange(self): | |
40 lines = ['<input id="testinput" pref="testpref"', | |
41 'metric="invalidaction" type="checkbox" dialog-pref>'] | |
yao
2014/11/12 22:23:21
Could you test the case where "metrics=" is not at
gayane -on leave until 09-2017
2014/11/15 00:09:09
Done.
| |
42 PRESUBMIT.action_xml_path = _TEST_DATA_DIR + "actions.xml" | |
43 mock_input_api = MockInputApi() | |
44 mock_input_api.files = [MockFile('path/test.html', lines)] | |
45 | |
46 warnings = PRESUBMIT.CheckUserActionUpdate(mock_input_api, MockOutputApi()) | |
47 self.assertEqual(1, len(warnings)) | |
48 | |
Alexei Svitkine (slow)
2014/11/12 22:27:00
Nit: Add an extra line.
gayane -on leave until 09-2017
2014/11/15 00:09:09
Done.
| |
49 if __name__ == '__main__': | |
50 unittest.main() | |
OLD | NEW |