Index: chrome/browser/resources/PRESUBMIT_test.py |
diff --git a/chrome/browser/resources/PRESUBMIT_test.py b/chrome/browser/resources/PRESUBMIT_test.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..58a3908c72d08eb18a634815f257dbc4f10aab0a |
--- /dev/null |
+++ b/chrome/browser/resources/PRESUBMIT_test.py |
@@ -0,0 +1,50 @@ |
+# Copyright (c) 2014 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import os |
+import sys |
+import imp |
+import unittest |
+import PRESUBMIT |
+ |
+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.
|
+from PRESUBMIT_test_mockobjects import MockFile, MockInputApi, MockOutputApi |
+ |
+_TEST_DATA_DIR = 'base/test/data/presubmit/' |
+ |
+class HTMLActionAdditionTest(unittest.TestCase): |
+ |
+ def testActionXMLChanged(self): |
+ mock_input_api = MockInputApi() |
+ mock_input_api.files = [ |
+ MockFile('path/valid.html', ''), |
+ MockFile('actions.xml', '') ] |
+ |
+ warnings = PRESUBMIT.CheckUserActionUpdate(mock_input_api, MockOutputApi()) |
+ self.assertEqual(0, len(warnings)) |
+ |
+ |
+ def testValidChange(self): |
+ lines = ['<input id="testinput" pref="testpref"', |
+ 'metric="validaction" type="checkbox" dialog-pref>'] |
+ 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.
|
+ mock_input_api = MockInputApi() |
+ mock_input_api.files = [MockFile('path/test.html', lines)] |
+ |
+ warnings = PRESUBMIT.CheckUserActionUpdate(mock_input_api, MockOutputApi()) |
+ self.assertEqual(0, len(warnings)) |
+ |
+ |
+ def testInvalidChange(self): |
+ lines = ['<input id="testinput" pref="testpref"', |
+ '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.
|
+ PRESUBMIT.action_xml_path = _TEST_DATA_DIR + "actions.xml" |
+ mock_input_api = MockInputApi() |
+ mock_input_api.files = [MockFile('path/test.html', lines)] |
+ |
+ warnings = PRESUBMIT.CheckUserActionUpdate(mock_input_api, MockOutputApi()) |
+ self.assertEqual(1, len(warnings)) |
+ |
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.
|
+if __name__ == '__main__': |
+ unittest.main() |