Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: tests/test_packagerEdge.py

Issue 29542845: Issue 5668 - Replace 3rd component of version in AppxManifest.xml with build number (Closed)
Patch Set: Created Sept. 12, 2017, 11:56 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« packagerEdge.py ('K') | « packagerEdge.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # This Source Code Form is subject to the terms of the Mozilla Public 1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 4
5 import ConfigParser 5 import ConfigParser
6 import json 6 import json
7 import os 7 import os
8 import shutil 8 import shutil
9 import xml.etree.ElementTree as ET 9 import xml.etree.ElementTree as ET
10 import zipfile 10 import zipfile
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 def attr(attr): 146 def attr(attr):
147 def wrapper(elem): 147 def wrapper(elem):
148 return elem.attrib[attr] 148 return elem.attrib[attr]
149 return wrapper 149 return wrapper
150 150
151 base = [ 151 base = [
152 ('.//*', [len], 21.0), 152 ('.//*', [len], 21.0),
153 ('./ns:Identity', [first, attr('Publisher')], 153 ('./ns:Identity', [first, attr('Publisher')],
154 'CN=4F066043-8AFE-41C9-B762-6C15E77E3F88'), 154 'CN=4F066043-8AFE-41C9-B762-6C15E77E3F88'),
155 ('./ns:Identity', [first, attr('Version')], '1.2.3.0'),
156 ('./ns:Properties/ns:PublisherDisplayName', [first, text], 155 ('./ns:Properties/ns:PublisherDisplayName', [first, text],
157 'Eyeo GmbH'), 156 'Eyeo GmbH'),
158 ('./ns:Properties/ns:Logo', [first, text], 'Assets\\logo_50.png'), 157 ('./ns:Properties/ns:Logo', [first, text], 'Assets\\logo_50.png'),
159 ('./ns:Dependencies/ns:TargetDeviceFamily', 158 ('./ns:Dependencies/ns:TargetDeviceFamily',
160 [first, attr('MinVersion')], 159 [first, attr('MinVersion')],
161 '10.0.14332.0'), 160 '10.0.14332.0'),
162 ('./ns:Dependencies/ns:TargetDeviceFamily', 161 ('./ns:Dependencies/ns:TargetDeviceFamily',
163 [first, attr('MaxVersionTested')], 162 [first, attr('MaxVersionTested')],
164 '12.0.0.0'), 163 '12.0.0.0'),
165 ('./ns:Applications/ns:Application/uap:VisualElements', 164 ('./ns:Applications/ns:Application/uap:VisualElements',
166 [first, attr('Square150x150Logo')], 165 [first, attr('Square150x150Logo')],
167 'Assets\\logo_150.png'), 166 'Assets\\logo_150.png'),
168 ('./ns:Applications/ns:Application/uap:VisualElements', 167 ('./ns:Applications/ns:Application/uap:VisualElements',
169 [first, attr('Square44x44Logo')], 168 [first, attr('Square44x44Logo')],
170 'Assets\\logo_44.png'), 169 'Assets\\logo_44.png'),
171 ('./ns:Applications/ns:Application/uap:VisualElements', 170 ('./ns:Applications/ns:Application/uap:VisualElements',
172 [first, attr('Description')], 171 [first, attr('Description')],
173 'Adblock Plus is the most popular ad blocker ever, and also ' 172 'Adblock Plus is the most popular ad blocker ever, and also '
174 'supports websites by not blocking unobstrusive ads by ' 173 'supports websites by not blocking unobstrusive ads by '
175 'default (configurable).'), 174 'default (configurable).'),
176 ('./ns:Applications/ns:Application/uap:VisualElements', 175 ('./ns:Applications/ns:Application/uap:VisualElements',
177 [first, attr('BackgroundColor')], 176 [first, attr('BackgroundColor')],
178 'red'), 177 'red'),
179 ] 178 ]
180 179
181 devbuild = base + [ 180 devbuild = base + [
182 ('./ns:Identity', [first, attr('Name')], 181 ('./ns:Identity', [first, attr('Name')],
183 'EyeoGmbH.AdblockPlusdevelopmentbuild'), 182 'EyeoGmbH.AdblockPlusdevelopmentbuild'),
183 ('./ns:Identity', [first, attr('Version')], '1.2.1000.0'),
184 ('./ns:Properties/ns:DisplayName', [first, text], 'devbuild-marker'), 184 ('./ns:Properties/ns:DisplayName', [first, text], 'devbuild-marker'),
185 ('./ns:Applications/ns:Application/uap:VisualElements', 185 ('./ns:Applications/ns:Application/uap:VisualElements',
186 [first, attr('DisplayName')], 186 [first, attr('DisplayName')],
187 'devbuild-marker'), 187 'devbuild-marker'),
188 ('./ns:Applications/ns:Application/ns:Extensions/uap3:Extension/' 188 ('./ns:Applications/ns:Application/ns:Extensions/uap3:Extension/'
189 'uap3:AppExtension', 189 'uap3:AppExtension',
190 [first, attr('Id')], 190 [first, attr('Id')],
191 'EdgeExtension'), 191 'EdgeExtension'),
192 ('./ns:Applications/ns:Application/ns:Extensions/uap3:Extension/' 192 ('./ns:Applications/ns:Application/ns:Extensions/uap3:Extension/'
193 'uap3:AppExtension', 193 'uap3:AppExtension',
194 [first, attr('DisplayName')], 194 [first, attr('DisplayName')],
195 'devbuild-marker'), 195 'devbuild-marker'),
196 ] 196 ]
197 197
198 release = base + [ 198 release = base + [
199 ('./ns:Identity', [first, attr('Name')], 'EyeoGmbH.AdblockPlus'), 199 ('./ns:Identity', [first, attr('Name')], 'EyeoGmbH.AdblockPlus'),
200 ('./ns:Identity', [first, attr('Version')], '1.2.3.0'),
200 ('./ns:Properties/ns:DisplayName', [first, text], 'Adblock Plus'), 201 ('./ns:Properties/ns:DisplayName', [first, text], 'Adblock Plus'),
201 ('./ns:Applications/ns:Application/uap:VisualElements', 202 ('./ns:Applications/ns:Application/uap:VisualElements',
202 [first, attr('DisplayName')], 203 [first, attr('DisplayName')],
203 'Adblock Plus'), 204 'Adblock Plus'),
204 ('./ns:Applications/ns:Application/ns:Extensions/uap3:Extension/' 205 ('./ns:Applications/ns:Application/ns:Extensions/uap3:Extension/'
205 'uap3:AppExtension', 206 'uap3:AppExtension',
206 [first, attr('Id')], 207 [first, attr('Id')],
207 '1.0'), 208 '1.0'),
208 ('./ns:Applications/ns:Application/ns:Extensions/uap3:Extension/' 209 ('./ns:Applications/ns:Application/ns:Extensions/uap3:Extension/'
209 'uap3:AppExtension', 210 'uap3:AppExtension',
210 [first, attr('DisplayName')], 211 [first, attr('DisplayName')],
211 'Adblock Plus'), 212 'Adblock Plus'),
212 ] 213 ]
213 214
214 for release_build, pairs in [(False, devbuild), (True, release)]: 215 for args, pairs in [(('1000', False), devbuild), ((None, True), release)]:
215 manifest = ET.fromstring(packagerEdge.create_appx_manifest( 216 manifest = ET.fromstring(packagerEdge.create_appx_manifest(
216 {'metadata': metadata, 'version': '1.2.3.4'}, 217 {'metadata': metadata}, files, *args
217 files, 218 ))
218 release_build=release_build))
219 for expression, modifiers, value in pairs: 219 for expression, modifiers, value in pairs:
220 res = reduce( 220 res = reduce(
221 lambda val, func: func(val), 221 lambda val, func: func(val),
222 modifiers, 222 modifiers,
223 manifest.findall(expression, namespaces=namespaces)) 223 manifest.findall(expression, namespaces=namespaces))
224 assert res == value 224 assert res == value
225 225
226 226
227 def test_move_files_to_extension(): 227 def test_move_files_to_extension():
228 files = packager.Files(set(), set()) 228 files = packager.Files(set(), set())
(...skipping 21 matching lines...) Expand all
250 assert 'devbuild-marker' not in appx.read('AppxManifest.xml') 250 assert 'devbuild-marker' not in appx.read('AppxManifest.xml')
251 assert appx.read('Assets/logo_44.png') == '44' 251 assert appx.read('Assets/logo_44.png') == '44'
252 assert appx.read('Extension/icons/abp-44.png') == '44' 252 assert appx.read('Extension/icons/abp-44.png') == '44'
253 253
254 254
255 def test_create_devbuild(tmpdir, srcdir): 255 def test_create_devbuild(tmpdir, srcdir):
256 out_file = str(tmpdir.join('abp.appx')) 256 out_file = str(tmpdir.join('abp.appx'))
257 packagerEdge.createBuild(str(srcdir), outFile=out_file, releaseBuild=False) 257 packagerEdge.createBuild(str(srcdir), outFile=out_file, releaseBuild=False)
258 appx = zipfile.ZipFile(out_file) 258 appx = zipfile.ZipFile(out_file)
259 assert 'devbuild-marker' in appx.read('AppxManifest.xml') 259 assert 'devbuild-marker' in appx.read('AppxManifest.xml')
OLDNEW
« packagerEdge.py ('K') | « packagerEdge.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld