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

Unified Diff: chrome/browser/web_dev_style/closure_lint_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/test_presubmit.py ('k') | chrome/browser/web_dev_style/css_checker_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/web_dev_style/closure_lint_test.py
diff --git a/chrome/browser/web_dev_style/closure_lint_test.py b/chrome/browser/web_dev_style/closure_lint_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..b9a7382ca8103308dd1caabf3d028463353b7a3a
--- /dev/null
+++ b/chrome/browser/web_dev_style/closure_lint_test.py
@@ -0,0 +1,90 @@
+#!/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.
+
+import js_checker
+from os import path as os_path
+import re
+from sys import path as sys_path
+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 ClosureLintTest(SuperMoxTestBase):
+ def setUp(self):
+ SuperMoxTestBase.setUp(self)
+
+ input_api = self.mox.CreateMockAnything()
+ input_api.os_path = os_path
+ input_api.re = re
+
+ input_api.change = self.mox.CreateMockAnything()
+ self.mox.StubOutWithMock(input_api.change, 'RepositoryRoot')
+ src_root = os_path.join(os_path.dirname(__file__), '..', '..', '..')
+ input_api.change.RepositoryRoot().MultipleTimes().AndReturn(src_root)
+
+ output_api = self.mox.CreateMockAnything()
+
+ self.mox.ReplayAll()
+
+ self.checker = js_checker.JSChecker(input_api, output_api)
+
+ def ShouldPassClosureLint(self, source):
+ errors = self.checker.ClosureLint('', source=source)
+
+ for error in errors:
+ print 'Error: ' + error.message
+
+ self.assertListEqual([], errors)
+
+ def testBindFalsePositives(self):
+ sources = [
+ [
+ 'var addOne = function(prop) {\n',
+ ' this[prop] += 1;\n',
+ '}.bind(counter, timer);\n',
+ '\n',
+ 'setInterval(addOne, 1000);\n',
+ '\n',
+ ],
+ [
+ '/** Da clickz. */\n',
+ 'button.onclick = function() { this.add_(this.total_); }.bind(this);\n',
+ ],
+ ]
+ for source in sources:
+ self.ShouldPassClosureLint(source)
+
+ def testPromiseFalsePositives(self):
+ sources = [
+ [
+ 'Promise.reject(1).catch(function(error) {\n',
+ ' alert(error);\n',
+ '});\n',
+ ],
+ [
+ 'var loaded = new Promise();\n',
+ 'loaded.then(runAwesomeApp);\n',
+ 'loaded.catch(showSadFace);\n',
+ '\n',
+ '/** Da loadz. */\n',
+ 'document.onload = function() { loaded.resolve(); };\n',
+ '\n',
+ '/** Da errorz. */\n',
+ 'document.onerror = function() { loaded.reject(); };\n',
+ '\n',
+ "if (document.readystate == 'complete') loaded.resolve();\n",
+ ],
+ ]
+ for source in sources:
+ self.ShouldPassClosureLint(source)
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « chrome/browser/test_presubmit.py ('k') | chrome/browser/web_dev_style/css_checker_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698