Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: chrome/browser/resources/PRESUBMIT_test.py

Issue 719463003: Presubmit checks for user actions intorduced in HTML files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments fix. changed check for boolean actions. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 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__) + '/../../../'))
12 from PRESUBMIT_test_mocks import MockFile, MockInputApi, MockOutputApi
13
14 _TEST_DATA_DIR = 'base/test/data/presubmit/'
15 _ACTION_XML_PATH = _TEST_DATA_DIR + "actions.xml"
16
17 class HTMLActionAdditionTest(unittest.TestCase):
18
19 def testActionXMLChanged(self):
20 mock_input_api = MockInputApi()
21 mock_input_api.files = [
22 MockFile('path/valid.html', ''),
23 MockFile('actions.xml', '') ]
24
25 warnings = PRESUBMIT.CheckUserActionUpdate(mock_input_api,
26 MockOutputApi(),
27 _ACTION_XML_PATH)
28 self.assertEqual(0, len(warnings))
29
M-A Ruel 2014/11/26 18:15:48 normally, 1 empty line between class methods
gayane -on leave until 09-2017 2014/11/26 20:28:46 Done.
30
31 def testValidChange_StartOfLine(self):
32 lines = ['<input id="testinput" pref="testpref"',
33 'metric="validaction" type="checkbox" dialog-pref>']
34 warnings = self._testChange(lines)
35 self.assertEqual(0, len(warnings))
M-A Ruel 2014/11/26 18:15:48 self.assertEqual([], self._testChange(lines)) woul
gayane -on leave until 09-2017 2014/11/26 20:28:46 Done.
36
37
38 def testValidChange_StartsWithSpace(self):
39 lines = ['<input id="testinput" pref="testpref"',
40 ' metric="validaction" type="checkbox" dialog-pref>']
41 warnings = self._testChange(lines)
42 self.assertEqual(0, len(warnings))
43
44
45 def testValidChange_Radio(self):
46 lines = ['<input id="testinput" pref="testpref"',
47 ' metric="validaction" type="radio" dialog-pref value="true">']
48 warnings = self._testChange(lines)
49 self.assertEqual(0, len(warnings))
50
51
52 def testValidChange_UsingDatatype(self):
53 lines = ['<input id="testinput" pref="testpref"',
54 ' metric="validaction" datatype="boolean" dialog-pref>']
55 warnings = self._testChange(lines)
56 self.assertEqual(0, len(warnings))
57
58
59 def testValidChange_NotBoolean(self):
60 lines = ['<input id="testinput" pref="testpref"',
61 ' metric="notboolean_validaction" dialog-pref>']
62 warnings = self._testChange(lines)
63 self.assertEqual(0, len(warnings))
64
65
66 def testInvalidChange(self):
67 lines = ['<input id="testinput" pref="testpref"',
68 'metric="invalidaction" type="checkbox" dialog-pref>']
69 warnings = self._testChange(lines)
70 self.assertEqual(1, len(warnings))
71
72
73 def testInValidChange_Radio(self):
74 lines = ['<input id="testinput" pref="testpref"',
75 ' metric="validaction" type="radio" dialog-pref value="string">']
76 warnings = self._testChange(lines)
77 self.assertEqual(1, len(warnings))
78
79
80 def _testChange(self, lines):
81 action_xml_path = _TEST_DATA_DIR + "actions.xml"
82 mock_input_api = MockInputApi()
83 mock_input_api.files = [MockFile('path/test.html', lines)]
84
85 return PRESUBMIT.CheckUserActionUpdate(mock_input_api,
86 MockOutputApi(),
87 _ACTION_XML_PATH)
88
89
90 if __name__ == '__main__':
91 unittest.main()
OLDNEW
« chrome/browser/resources/PRESUBMIT.py ('K') | « chrome/browser/resources/PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698