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

Side by Side Diff: tests/test_packagerEdge.py

Issue 29368690: [buildtools] Issue 4578 - Make uap3:AppExtension.Id configurable for Microsoft Edge builds (Closed)
Patch Set: Removed extension_id_devbuild option from test metadata Created Jan. 10, 2017, 8:08 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/metadata.edge ('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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 'png': 'image/png', 123 'png': 'image/png',
124 'xml': 'application/xml' 124 'xml': 'application/xml'
125 } 125 }
126 assert ctm_dict['overrides'] == { 126 assert ctm_dict['overrides'] == {
127 '/AppxBlockMap.xml': 'application/vnd.ms-appx.blockmap+xml', 127 '/AppxBlockMap.xml': 'application/vnd.ms-appx.blockmap+xml',
128 '/AppxManifest.xml': 'application/vnd.ms-appx.manifest+xml' 128 '/AppxManifest.xml': 'application/vnd.ms-appx.manifest+xml'
129 } 129 }
130 130
131 131
132 def test_create_appx_manifest(metadata, files): 132 def test_create_appx_manifest(metadata, files):
133 manifest = packagerEdge.create_appx_manifest( 133 namespaces = {
134 {'metadata': metadata}, files, release_build=True, 134 'ns': 'http://schemas.microsoft.com/'
135 ) 135 'appx/manifest/foundation/windows10',
136 with open(os.path.join(TEST_DIR, 'AppManifest.xml.expect')) as fp: 136 'uap': 'http://schemas.microsoft.com/appx/manifest/uap/windows10',
137 manifest_expect = fp.read() 137 'uap3': 'http://schemas.microsoft.com/appx/manifest/uap/windows10/3',
138 assert manifest.strip() == manifest_expect.strip() 138 }
139 139
140 def first(elem):
141 return elem[0]
140 142
141 def test_create_devbuild_appx_manifest(metadata, files): 143 def text(elem):
142 manifest = packagerEdge.create_appx_manifest( 144 return elem.text
143 {'metadata': metadata}, files, release_build=False, 145
144 ) 146 def attr(attr):
145 assert 'devbuild-marker' in manifest 147 def wrapper(elem):
148 return elem.attrib[attr]
149 return wrapper
150
151 base = [
152 ('.//*', [len], 21.0),
153 ('./ns:Identity', [first, attr('Name')], 'EyeoGmbH.AdblockPlus'),
154 ('./ns:Identity', [first, attr('Publisher')],
155 'CN=4F066043-8AFE-41C9-B762-6C15E77E3F88'),
156 ('./ns:Identity', [first, attr('Version')], '1.2.3.0'),
157 ('./ns:Properties/ns:PublisherDisplayName', [first, text],
158 'Eyeo GmbH'),
159 ('./ns:Properties/ns:Logo', [first, text], 'Assets\\logo_50.png'),
160 ('./ns:Dependencies/ns:TargetDeviceFamily',
161 [first, attr('MinVersion')],
162 '10.0.14332.0'),
163 ('./ns:Dependencies/ns:TargetDeviceFamily',
164 [first, attr('MaxVersionTested')],
165 '12.0.0.0'),
166 ('./ns:Applications/ns:Application/uap:VisualElements',
167 [first, attr('Square150x150Logo')],
168 'Assets\\logo_150.png'),
169 ('./ns:Applications/ns:Application/uap:VisualElements',
170 [first, attr('Square44x44Logo')],
171 'Assets\\logo_44.png'),
172 ('./ns:Applications/ns:Application/uap:VisualElements',
173 [first, attr('Description')],
174 'Adblock Plus is the most popular ad blocker ever, and also '
175 'supports websites by not blocking unobstrusive ads by '
176 'default (configurable).'),
177 ('./ns:Applications/ns:Application/uap:VisualElements',
178 [first, attr('BackgroundColor')],
179 'red'),
180 ]
181
182 devbuild = base + [
183 ('./ns:Properties/ns:DisplayName', [first, text], 'devbuild-marker'),
184 ('./ns:Applications/ns:Application/uap:VisualElements',
185 [first, attr('DisplayName')],
186 'devbuild-marker'),
187 ('./ns:Applications/ns:Application/ns:Extensions/uap3:Extension/'
188 'uap3:AppExtension',
189 [first, attr('Id')],
190 'EdgeExtension'),
191 ('./ns:Applications/ns:Application/ns:Extensions/uap3:Extension/'
192 'uap3:AppExtension',
193 [first, attr('DisplayName')],
194 'devbuild-marker'),
195 ]
196
197 release = base + [
198 ('./ns:Properties/ns:DisplayName', [first, text], 'Adblock Plus'),
199 ('./ns:Applications/ns:Application/uap:VisualElements',
200 [first, attr('DisplayName')],
201 'Adblock Plus'),
202 ('./ns:Applications/ns:Application/ns:Extensions/uap3:Extension/'
203 'uap3:AppExtension',
204 [first, attr('Id')],
205 '1.0'),
206 ('./ns:Applications/ns:Application/ns:Extensions/uap3:Extension/'
207 'uap3:AppExtension',
208 [first, attr('DisplayName')],
209 'Adblock Plus'),
210 ]
211
212 for release_build, pairs in [(False, devbuild), (True, release)]:
213 manifest = ET.fromstring(packagerEdge.create_appx_manifest(
214 {'metadata': metadata},
215 files,
216 release_build=release_build))
217 for expression, modifiers, value in pairs:
218 res = reduce(
219 lambda val, func: func(val),
220 modifiers,
221 manifest.findall(expression, namespaces=namespaces))
222 assert res == value
146 223
147 224
148 def test_move_files_to_extension(): 225 def test_move_files_to_extension():
149 files = packager.Files(set(), set()) 226 files = packager.Files(set(), set())
150 files['foo.xml'] = CHARS 227 files['foo.xml'] = CHARS
151 files['foo/bar.xml'] = CHARS 228 files['foo/bar.xml'] = CHARS
152 files['Extension/foo.xml'] = CHARS 229 files['Extension/foo.xml'] = CHARS
153 packagerEdge.move_files_to_extension(files) 230 packagerEdge.move_files_to_extension(files)
154 assert set(files.keys()) == { 231 assert set(files.keys()) == {
155 'Extension/foo.xml', 232 'Extension/foo.xml',
(...skipping 16 matching lines...) Expand all
172 assert 'devbuild-marker' not in appx.read('AppxManifest.xml') 249 assert 'devbuild-marker' not in appx.read('AppxManifest.xml')
173 assert appx.read('Assets/logo_44.png') == '44' 250 assert appx.read('Assets/logo_44.png') == '44'
174 assert appx.read('Extension/icons/abp-44.png') == '44' 251 assert appx.read('Extension/icons/abp-44.png') == '44'
175 252
176 253
177 def test_create_devbuild(tmpdir, srcdir): 254 def test_create_devbuild(tmpdir, srcdir):
178 out_file = str(tmpdir.join('abp.appx')) 255 out_file = str(tmpdir.join('abp.appx'))
179 packagerEdge.createBuild(str(srcdir), outFile=out_file, releaseBuild=False) 256 packagerEdge.createBuild(str(srcdir), outFile=out_file, releaseBuild=False)
180 appx = zipfile.ZipFile(out_file) 257 appx = zipfile.ZipFile(out_file)
181 assert 'devbuild-marker' in appx.read('AppxManifest.xml') 258 assert 'devbuild-marker' in appx.read('AppxManifest.xml')
OLDNEW
« no previous file with comments | « tests/metadata.edge ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld