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

Side by Side Diff: grit/format/android_xml_unittest.py

Issue 1291173002: Remove support for product attributes in Android xml files. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk
Patch Set: fixed >80 line Created 5 years, 4 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
« no previous file with comments | « grit/format/android_xml.py ('k') | grit/testdata/android.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 """Unittest for android_xml.py.""" 6 """Unittest for android_xml.py."""
7 7
8 import os 8 import os
9 import StringIO 9 import StringIO
10 import sys 10 import sys
(...skipping 21 matching lines...) Expand all
32 out loud, "Why don't I build a flying car?" 32 out loud, "Why don't I build a flying car?"
33 </message> 33 </message>
34 <message name="IDS_MULTILINE" desc="A string split over several lines" > 34 <message name="IDS_MULTILINE" desc="A string split over several lines" >
35 She gathered 35 She gathered
36 wood, charcoal, and 36 wood, charcoal, and
37 a sledge hammer. 37 a sledge hammer.
38 </message> 38 </message>
39 <message name="IDS_WHITESPACE" desc="A string with extra whitespace."> 39 <message name="IDS_WHITESPACE" desc="A string with extra whitespace.">
40 ''' How old fashioned -- she thought. ''' 40 ''' How old fashioned -- she thought. '''
41 </message> 41 </message>
42 <message name="IDS_PRODUCT_SPECIFIC_product_nosdcard"
43 desc="A string that only applies if there's no sdcard">
44 Lasers will probably be helpful.
45 </message>
46 <message name="IDS_PRODUCT_DEFAULT" desc="New style product tag"
47 formatter_data="android_java_product=default android_java_name=cus tom_name">
48 You have an SD card
49 </message>
50 <message name="IDS_PLACEHOLDERS" desc="A string with placeholders"> 42 <message name="IDS_PLACEHOLDERS" desc="A string with placeholders">
51 I'll buy a <ph name="WAVELENGTH">%d<ex>200</ex></ph> nm laser at <ph name="STORE_NAME">%s<ex>the grocery store</ex></ph>. 43 I'll buy a <ph name="WAVELENGTH">%d<ex>200</ex></ph> nm laser at <ph name="STORE_NAME">%s<ex>the grocery store</ex></ph>.
52 </message> 44 </message>
53 <message name="IDS_PLURALS" desc="A string using the ICU plural format "> 45 <message name="IDS_PLURALS" desc="A string using the ICU plural format ">
54 {NUM_THINGS, plural, 46 {NUM_THINGS, plural,
55 =1 {Maybe I'll get one laser.} 47 =1 {Maybe I'll get one laser.}
56 other {Maybe I'll get # lasers.}} 48 other {Maybe I'll get # lasers.}}
57 </message> 49 </message>
58 </messages> 50 </messages>
59 """) 51 """)
60 52
61 buf = StringIO.StringIO() 53 buf = StringIO.StringIO()
62 build.RcBuilder.ProcessNode(root, DummyOutput('android', 'en'), buf) 54 build.RcBuilder.ProcessNode(root, DummyOutput('android', 'en'), buf)
63 output = buf.getvalue() 55 output = buf.getvalue()
64 expected = ur""" 56 expected = ur"""
65 <?xml version="1.0" encoding="utf-8"?> 57 <?xml version="1.0" encoding="utf-8"?>
66 <resources xmlns:android="http://schemas.android.com/apk/res/android"> 58 <resources xmlns:android="http://schemas.android.com/apk/res/android">
67 <string name="simple">"Martha"</string> 59 <string name="simple">"Martha"</string>
68 <string name="one_line">"sat and wondered"</string> 60 <string name="one_line">"sat and wondered"</string>
69 <string name="quotes">"out loud, \"Why don\'t I build a flying car?\""</string> 61 <string name="quotes">"out loud, \"Why don\'t I build a flying car?\""</string>
70 <string name="multiline">"She gathered 62 <string name="multiline">"She gathered
71 wood, charcoal, and 63 wood, charcoal, and
72 a sledge hammer."</string> 64 a sledge hammer."</string>
73 <string name="whitespace">" How old fashioned -- she thought. "</string> 65 <string name="whitespace">" How old fashioned -- she thought. "</string>
74 <string name="product_specific" product="nosdcard">"Lasers will probably be help ful."</string>
75 <string name="custom_name" product="default">"You have an SD card"</string>
76 <string name="placeholders">"I\'ll buy a %d nm laser at %s."</string> 66 <string name="placeholders">"I\'ll buy a %d nm laser at %s."</string>
77 <plurals name="plurals"> 67 <plurals name="plurals">
78 <item quantity="one">"Maybe I\'ll get one laser."</item> 68 <item quantity="one">"Maybe I\'ll get one laser."</item>
79 <item quantity="other">"Maybe I\'ll get %d lasers."</item> 69 <item quantity="other">"Maybe I\'ll get %d lasers."</item>
80 </plurals> 70 </plurals>
81 </resources> 71 </resources>
82 """ 72 """
83 self.assertEqual(output.strip(), expected.strip()) 73 self.assertEqual(output.strip(), expected.strip())
84 74
85 def testTaggedOnly(self): 75 def testTaggedOnly(self):
(...skipping 25 matching lines...) Expand all
111 return self.type 101 return self.type
112 102
113 def GetLanguage(self): 103 def GetLanguage(self):
114 return self.language 104 return self.language
115 105
116 def GetOutputFilename(self): 106 def GetOutputFilename(self):
117 return 'hello.gif' 107 return 'hello.gif'
118 108
119 if __name__ == '__main__': 109 if __name__ == '__main__':
120 unittest.main() 110 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/android_xml.py ('k') | grit/testdata/android.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698