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

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

Issue 1442863002: Remove contents of grit's SVN repository. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 5 years, 1 month 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
(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 '
30 'in a single line because it is very important.\nIgnore this.'
31 }
32 writer = android_policy_writer.GetWriter({})
33 writer.Init()
34 writer.BeginTemplate()
35 writer.WritePolicy(policy)
36 self.assertEquals(
37 writer._resources.toxml(),
38 '<resources>'
39 '<string name="_policy_nameTitle">_policy_caption</string>'
40 '<string name="_policy_nameDesc">This is a long policy caption. More '
41 'than one sentence in a single line because it is very important.'
42 '</string>'
43 '</resources>')
44
45 def testPolicyWithItems(self):
46 # Test an example policy without items.
47 policy = {
48 'name': '_policy_name',
49 'caption': '_policy_caption',
50 'desc': '_policy_desc_first.\n_ignored_policy_desc',
51 'items': [
52 {
53 'caption':'_caption1',
54 'value':'_value1',
55 },
56 {
57 'caption':'_caption2',
58 'value':'_value2',
59 }
60 ]
61 }
62 writer = android_policy_writer.GetWriter({})
63 writer.Init()
64 writer.BeginTemplate()
65 writer.WritePolicy(policy)
66 self.assertEquals(
67 writer._resources.toxml(),
68 '<resources>'
69 '<string name="_policy_nameTitle">_policy_caption</string>'
70 '<string name="_policy_nameDesc">_policy_desc_first.</string>'
71 '<string-array name="_policy_nameEntries">'
72 '<item>_caption1</item>'
73 '<item>_caption2</item>'
74 '</string-array>'
75 '<string-array name="_policy_nameValues">'
76 '<item>_value1</item>'
77 '<item>_value2</item>'
78 '</string-array>'
79 '</resources>')
80
81 if __name__ == '__main__':
82 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/policy_templates/writers/android_policy_writer.py ('k') | grit/format/policy_templates/writers/doc_writer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698