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

Side by Side Diff: grit/format/policy_templates/writers/json_writer_unittest.py

Issue 642443004: Add a chromium version to policy template files. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 '''Unit tests for grit.format.policy_templates.writers.json_writer''' 6 '''Unit tests for grit.format.policy_templates.writers.json_writer'''
7 7
8 8
9 import os 9 import os
10 import sys 10 import sys
11 if __name__ == '__main__': 11 if __name__ == '__main__':
12 sys.path.append(os.path.join(os.path.dirname(__file__), '../../../..')) 12 sys.path.append(os.path.join(os.path.dirname(__file__), '../../../..'))
13 13
14 import unittest 14 import unittest
15 15
16 from grit.format.policy_templates.writers import writer_unittest_common 16 from grit.format.policy_templates.writers import writer_unittest_common
17 17
18 18
19 TEMPLATE_HEADER="""\ 19 TEMPLATE_HEADER="""\
20 // Policy template for Linux. 20 // Policy template for Linux.
21 // Uncomment the policies you wish to activate and change their values to 21 // Uncomment the policies you wish to activate and change their values to
22 // something useful for your case. The provided values are for reference only 22 // something useful for your case. The provided values are for reference only
23 // and do not provide meaningful defaults! 23 // and do not provide meaningful defaults!
24 { 24 {
25 """ 25 """
26 26
27 TEMPLATE_HEADER_WITH_VERSION="""\
28 // chromium version: 39.0.0.0
29 // Policy template for Linux.
30 // Uncomment the policies you wish to activate and change their values to
31 // something useful for your case. The provided values are for reference only
32 // and do not provide meaningful defaults!
33 {
34 """
35
27 36
28 HEADER_DELIMETER="""\ 37 HEADER_DELIMETER="""\
29 //------------------------------------------------------------------------- 38 //-------------------------------------------------------------------------
30 """ 39 """
31 40
32 41
33 class JsonWriterUnittest(writer_unittest_common.WriterUnittestCommon): 42 class JsonWriterUnittest(writer_unittest_common.WriterUnittestCommon):
34 '''Unit tests for JsonWriter.''' 43 '''Unit tests for JsonWriter.'''
35 44
36 def CompareOutputs(self, output, expected_output): 45 def CompareOutputs(self, output, expected_output):
(...skipping 11 matching lines...) Expand all
48 expected_output.strip()) 57 expected_output.strip())
49 58
50 def testEmpty(self): 59 def testEmpty(self):
51 # Test the handling of an empty policy list. 60 # Test the handling of an empty policy list.
52 grd = self.PrepareTest( 61 grd = self.PrepareTest(
53 '{' 62 '{'
54 ' "policy_definitions": [],' 63 ' "policy_definitions": [],'
55 ' "placeholders": [],' 64 ' "placeholders": [],'
56 ' "messages": {},' 65 ' "messages": {},'
57 '}') 66 '}')
58 output = self.GetOutput(grd, 'fr', {'_chromium': '1',}, 'json', 'en') 67 output = self.GetOutput(grd, 'fr', {'_chromium': '1'}, 'json', 'en')
59 expected_output = TEMPLATE_HEADER + '}' 68 expected_output = TEMPLATE_HEADER + '}'
60 self.CompareOutputs(output, expected_output) 69 self.CompareOutputs(output, expected_output)
61 70
71 def testEmptyWithVersion(self):
72 # Test the handling of an empty policy list.
73 grd = self.PrepareTest(
74 '{'
75 ' "policy_definitions": [],'
76 ' "placeholders": [],'
77 ' "messages": {},'
78 '}')
79 output = self.GetOutput(
80 grd, 'fr', {'_chromium': '1', 'version':'39.0.0.0'}, 'json', 'en')
81 expected_output = TEMPLATE_HEADER_WITH_VERSION + '}'
82 self.CompareOutputs(output, expected_output)
83
62 def testMainPolicy(self): 84 def testMainPolicy(self):
63 # Tests a policy group with a single policy of type 'main'. 85 # Tests a policy group with a single policy of type 'main'.
64 grd = self.PrepareTest( 86 grd = self.PrepareTest(
65 '{' 87 '{'
66 ' "policy_definitions": [' 88 ' "policy_definitions": ['
67 ' {' 89 ' {'
68 ' "name": "MainPolicy",' 90 ' "name": "MainPolicy",'
69 ' "type": "main",' 91 ' "type": "main",'
70 ' "caption": "Example Main Policy",' 92 ' "caption": "Example Main Policy",'
71 ' "desc": "Example Main Policy",' 93 ' "desc": "Example Main Policy",'
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 ' // Policy Two\n' + 420 ' // Policy Two\n' +
399 HEADER_DELIMETER + 421 HEADER_DELIMETER +
400 ' // Policy Two\n\n' 422 ' // Policy Two\n\n'
401 ' //"Policy2": "c"\n\n' 423 ' //"Policy2": "c"\n\n'
402 '}') 424 '}')
403 self.CompareOutputs(output, expected_output) 425 self.CompareOutputs(output, expected_output)
404 426
405 427
406 if __name__ == '__main__': 428 if __name__ == '__main__':
407 unittest.main() 429 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/policy_templates/writers/json_writer.py ('k') | grit/format/policy_templates/writers/plist_strings_writer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698