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

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

Issue 2829933003: WebUI: Swap Uglify with Closure Compiler NodeJS version.
Patch Set: Fix ChromeOS Created 3 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2017 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import unittest
7 import rewrite_licenses
8
9
10
11 class RewriteLicensesTest(unittest.TestCase):
12 def testRewrite(self):
13 test_input = '\n'.join([
14 "// Copyright (c) 2011 The Chromium Authors. All rights reserved.",
15 "// Use of this source code is governed by a BSD-style license that " \
16 "can be",
17 "// found in the LICENSE file.",
18 "var foo = 'bar';",
19 "// Copyright 2013 The Chromium Authors. All rights reserved.",
20 "// Use of this source code is governed by a BSD-style license that " \
21 "can be",
22 "// found in the LICENSE file.",
23 "// Some other comment here.",
24 ])
25
26 expected_output = '\n'.join([
27 "/**",
28 " * @license",
29 " * Copyright (c) 2011 The Chromium Authors. All rights reserved.",
30 " * Use of this source code is governed by a BSD-style license that " \
31 "can be",
32 " * found in the LICENSE file.",
33 " */",
34 "var foo = 'bar';",
35 "/**",
36 " * @license",
37 " * Copyright 2013 The Chromium Authors. All rights reserved.",
38 " * Use of this source code is governed by a BSD-style license that " \
39 "can be",
40 " * found in the LICENSE file.",
41 " */",
42 "// Some other comment here.",
43 ])
44
45 self.assertSequenceEqual(
46 expected_output, rewrite_licenses.rewrite(test_input))
47
48 # When a file is included with
49 # // <include src="..."
50 # the license header is preceeded by "//". Ensure that this is handled
51 # correctly.
52 def testRewriteIncludeTag(self):
53 test_input = '\n'.join([
54 "// // Copyright (c) 2011 The Chromium Authors. All rights reserved.",
55 "// Use of this source code is governed by a BSD-style license that " \
56 "can be",
57 "// found in the LICENSE file.",
58 "var foo = 'bar';",
59 ])
60
61 expected_output = '\n'.join([
62 "/**",
63 " * @license",
64 " * Copyright (c) 2011 The Chromium Authors. All rights reserved.",
65 " * Use of this source code is governed by a BSD-style license that " \
66 "can be",
67 " * found in the LICENSE file.",
68 " */",
69 "var foo = 'bar';",
70 ])
71
72 self.assertSequenceEqual(
73 expected_output, rewrite_licenses.rewrite(test_input))
74
75 if __name__ == '__main__':
76 unittest.main()
OLDNEW
« no previous file with comments | « chrome/browser/resources/rewrite_licenses.py ('k') | chrome/browser/resources/settings/prefs/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698