OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2015 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 '''Unit tests for grit.format.policy_templates.writers.android_policy_writer''' | |
7 | |
8 | |
9 import os | |
10 import sys | |
11 if __name__ == '__main__': | |
12 sys.path.append(os.path.join(os.path.dirname(__file__), '../../../..')) | |
13 | |
14 import unittest | |
15 from xml.dom import minidom | |
16 | |
17 from grit.format.policy_templates.writers import writer_unittest_common | |
18 from grit.format.policy_templates.writers import android_policy_writer | |
19 | |
20 | |
21 class AndroidPolicyWriterUnittest(writer_unittest_common.WriterUnittestCommon): | |
22 '''Unit tests to test assumptions in Android Policy Writer''' | |
23 | |
24 def testPolicyWithoutItems(self): | |
25 # Test an example policy without items. | |
26 policy = { | |
27 'name': '_policy_name', | |
28 'caption': '_policy_caption', | |
29 'desc': 'This is a long policy caption. More than one sentence in a single line because it is very important.\nIgnore this.' | |
Bernhard Bauer
2015/03/03 10:52:15
Break this line? (Concatenate the strings without
knn
2015/03/03 16:09:52
Done.
| |
30 } | |
31 writer = android_policy_writer.GetWriter({}) | |
32 writer.Init() | |
33 writer.BeginTemplate() | |
34 writer.WritePolicy(policy) | |
35 self.assertEquals( | |
36 writer._resources.toxml(), | |
37 '<resources>' | |
38 '<string name="_policy_nameTitle">_policy_caption</string>' | |
39 '<string name="_policy_nameDesc">This is a long policy caption.' | |
40 ' More than one sentence in a single line because it is very important.< /string>' | |
Bernhard Bauer
2015/03/03 10:52:15
And this line.
knn
2015/03/03 16:09:52
Done.
| |
41 '</resources>') | |
42 | |
43 def testPolicyWithItems(self): | |
44 # Test an example policy without items. | |
45 policy = { | |
46 'name': '_policy_name', | |
47 'caption': '_policy_caption', | |
48 'desc': '_policy_desc_first.\n_ignored_policy_desc', | |
49 'items': [ | |
50 { | |
51 'caption':'_caption1', | |
52 'value':'_value1', | |
53 }, | |
54 { | |
55 'caption':'_caption2', | |
56 'value':'_value2', | |
57 } | |
58 ] | |
59 } | |
60 writer = android_policy_writer.GetWriter({}) | |
61 writer.Init() | |
62 writer.BeginTemplate() | |
63 writer.WritePolicy(policy) | |
64 self.assertEquals( | |
65 writer._resources.toxml(), | |
66 '<resources>' | |
67 '<string name="_policy_nameTitle">_policy_caption</string>' | |
68 '<string name="_policy_nameDesc">_policy_desc_first.</string>' | |
69 '<string-array name="_policy_nameEntries">' | |
70 '<item>_caption1</item>' | |
Bernhard Bauer
2015/03/03 10:52:15
Can you indent these?
knn
2015/03/03 16:09:52
Done.
| |
71 '<item>_caption2</item>' | |
72 '</string-array>' | |
73 '<string-array name="_policy_nameValues">' | |
74 '<item>_value1</item>' | |
75 '<item>_value2</item>' | |
76 '</string-array>' | |
77 '</resources>') | |
78 | |
79 if __name__ == '__main__': | |
80 unittest.main() | |
OLD | NEW |