Index: chrome/browser/resources/rewrite_licenses_test.py |
diff --git a/chrome/browser/resources/rewrite_licenses_test.py b/chrome/browser/resources/rewrite_licenses_test.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..b1d2b627e4bbb1e90e8b3d741d1a6dfc38fcb66c |
--- /dev/null |
+++ b/chrome/browser/resources/rewrite_licenses_test.py |
@@ -0,0 +1,76 @@ |
+#!/usr/bin/env python |
+# Copyright 2017 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 unittest |
+import rewrite_licenses |
+ |
+ |
+ |
+class RewriteLicensesTest(unittest.TestCase): |
+ def testRewrite(self): |
+ test_input = '\n'.join([ |
+ "// Copyright (c) 2011 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.", |
+ "var foo = 'bar';", |
+ "// Copyright 2013 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.", |
+ "// Some other comment here.", |
+ ]) |
+ |
+ expected_output = '\n'.join([ |
+ "/**", |
+ " * @license", |
+ " * Copyright (c) 2011 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.", |
+ " */", |
+ "var foo = 'bar';", |
+ "/**", |
+ " * @license", |
+ " * Copyright 2013 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.", |
+ " */", |
+ "// Some other comment here.", |
+ ]) |
+ |
+ self.assertSequenceEqual( |
+ expected_output, rewrite_licenses.rewrite(test_input)) |
+ |
+ # When a file is included with |
+ # // <include src="..." |
+ # the license header is preceeded by "//". Ensure that this is handled |
+ # correctly. |
+ def testRewriteIncludeTag(self): |
+ test_input = '\n'.join([ |
+ "// // Copyright (c) 2011 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.", |
+ "var foo = 'bar';", |
+ ]) |
+ |
+ expected_output = '\n'.join([ |
+ "/**", |
+ " * @license", |
+ " * Copyright (c) 2011 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.", |
+ " */", |
+ "var foo = 'bar';", |
+ ]) |
+ |
+ self.assertSequenceEqual( |
+ expected_output, rewrite_licenses.rewrite(test_input)) |
+ |
+if __name__ == '__main__': |
+ unittest.main() |