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

Unified Diff: chrome/browser/web_dev_style/resource_checker_test.py

Issue 1242383003: Split web_dev_style tests into separate files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/web_dev_style/js_checker_test.py ('k') | chrome/browser/web_dev_style/test_util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/web_dev_style/resource_checker_test.py
diff --git a/chrome/browser/web_dev_style/resource_checker_test.py b/chrome/browser/web_dev_style/resource_checker_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..f6cb0f2fa8b0c04eaf386237c23389999ec08400
--- /dev/null
+++ b/chrome/browser/web_dev_style/resource_checker_test.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+# Copyright 2015 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.
+
+from os import path as os_path
+import re
+import resource_checker
+from sys import path as sys_path
+import test_util
+import unittest
+
+_HERE = os_path.dirname(os_path.abspath(__file__))
+sys_path.append(os_path.join(_HERE, '..', '..', '..', 'tools'))
+
+import find_depot_tools # pylint: disable=W0611
+from testing_support.super_mox import SuperMoxTestBase
+
+
+class ResourceCheckerTest(SuperMoxTestBase):
+ def setUp(self):
+ SuperMoxTestBase.setUp(self)
+
+ input_api = self.mox.CreateMockAnything()
+ input_api.re = re
+ output_api = self.mox.CreateMockAnything()
+ self.checker = resource_checker.ResourceChecker(input_api, output_api)
+
+ def ShouldFailIncludeCheck(self, line):
+ """Checks that the '</include>' checker flags |line| as a style error."""
+ error = self.checker.IncludeCheck(1, line)
+ self.assertNotEqual('', error,
+ 'Should be flagged as style error: ' + line)
+ highlight = test_util.GetHighlight(line, error).strip()
+ self.assertTrue('include' in highlight and highlight[0] == '<')
+
+ def ShouldPassIncludeCheck(self, line):
+ """Checks that the '</include>' checker doesn't flag |line| as an error."""
+ self.assertEqual('', self.checker.IncludeCheck(1, line),
+ 'Should not be flagged as style error: ' + line)
+
+ def testIncludeFails(self):
+ lines = [
+ "</include> ",
+ " </include>",
+ " </include> ",
+ ' <include src="blah.js" /> ',
+ '<include src="blee.js"/>',
+ ]
+ for line in lines:
+ self.ShouldFailIncludeCheck(line)
+
+ def testIncludePasses(self):
+ lines = [
+ '<include src="assert.js">',
+ "<include src='../../assert.js'>",
+ "<i>include src='blah'</i>",
+ "</i>nclude",
+ "</i>include",
+ ]
+ for line in lines:
+ self.ShouldPassIncludeCheck(line)
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « chrome/browser/web_dev_style/js_checker_test.py ('k') | chrome/browser/web_dev_style/test_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698