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: Test AppManifest for release and devbuilds using xml xpath expressions Created Dec. 21, 2016, 2 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
« no previous file with comments | « tests/AppManifest.xml.expect ('k') | tox.ini » ('j') | 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 from lxml import etree
10 import zipfile 11 import zipfile
11 12
12 import pytest 13 import pytest
13 14
14 from buildtools import packager, packagerEdge 15 from buildtools import packager, packagerEdge
15 16
16 TEST_DIR = os.path.dirname(__file__) 17 TEST_DIR = os.path.dirname(__file__)
17 TEST_METADATA = os.path.join(TEST_DIR, 'metadata.edge') 18 TEST_METADATA = os.path.join(TEST_DIR, 'metadata.edge')
18 CHARS = b''.join(chr(i % 200 + 30) for i in range(500)) 19 CHARS = b''.join(chr(i % 200 + 30) for i in range(500))
19 MESSAGES_EN_US = json.dumps({ 20 MESSAGES_EN_US = json.dumps({
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 'png': 'image/png', 124 'png': 'image/png',
124 'xml': 'application/xml' 125 'xml': 'application/xml'
125 } 126 }
126 assert ctm_dict['overrides'] == { 127 assert ctm_dict['overrides'] == {
127 '/AppxBlockMap.xml': 'application/vnd.ms-appx.blockmap+xml', 128 '/AppxBlockMap.xml': 'application/vnd.ms-appx.blockmap+xml',
128 '/AppxManifest.xml': 'application/vnd.ms-appx.manifest+xml' 129 '/AppxManifest.xml': 'application/vnd.ms-appx.manifest+xml'
129 } 130 }
130 131
131 132
132 def test_create_appx_manifest(metadata, files): 133 def test_create_appx_manifest(metadata, files):
133 manifest = packagerEdge.create_appx_manifest( 134 namespaces = {
134 {'metadata': metadata}, files, release_build=True, 135 'ns': 'http://schemas.microsoft.com/'
135 ) 136 'appx/manifest/foundation/windows10',
136 with open(os.path.join(TEST_DIR, 'AppManifest.xml.expect')) as fp: 137 'uap': 'http://schemas.microsoft.com/appx/manifest/uap/windows10',
137 manifest_expect = fp.read() 138 'uap3': 'http://schemas.microsoft.com/appx/manifest/uap/windows10/3',
138 assert manifest.strip() == manifest_expect.strip() 139 }
139 140
141 base = {
142 'count(//*)': 22.0,
143 'string(/ns:Package/ns:Identity/@Name)': 'EyeoGmbH.AdblockPlus',
144 'string(/ns:Package/ns:Identity/@Publisher)':
145 'CN=4F066043-8AFE-41C9-B762-6C15E77E3F88',
146 'string(/ns:Package/ns:Identity/@Version)': '1.2.3.0',
147 'string(/ns:Package/ns:Properties/ns:PublisherDisplayName)':
148 'Eyeo GmbH',
149 'string(/ns:Package/ns:Properties/ns:Logo)': 'Assets\\logo_50.png',
150 ('string(/ns:Package/ns:Dependencies/ns:TargetDeviceFamily/'
151 '@MinVersion)'): '10.0.14332.0',
152 ('string(/ns:Package/ns:Dependencies/ns:TargetDeviceFamily/'
153 '@MaxVersionTested)'): '12.0.0.0',
154 ('string(/ns:Package/ns:Applications/ns:Application/'
155 'uap:VisualElements/@Square150x150Logo)'): 'Assets\\logo_150.png',
156 ('string(/ns:Package/ns:Applications/ns:Application/'
157 'uap:VisualElements/@Square44x44Logo)'): 'Assets\\logo_44.png',
158 ('string(/ns:Package/ns:Applications/ns:Application/'
159 'uap:VisualElements/@Description)'):
160 'Adblock Plus is the most popular ad blocker ever, and also '
161 'supports websites by not blocking unobstrusive ads by '
162 'default (configurable).',
163 ('string(/ns:Package/ns:Applications/ns:Application/'
164 'uap:VisualElements/@BackgroundColor)'): 'red',
165 }
140 166
141 def test_create_devbuild_appx_manifest(metadata, files): 167 devbuild = base.copy()
142 manifest = packagerEdge.create_appx_manifest( 168 devbuild.update({
143 {'metadata': metadata}, files, release_build=False, 169 'string(/ns:Package/ns:Properties/ns:DisplayName)': 'devbuild-marker',
144 ) 170 'string(/ns:Package/ns:Applications/ns:Application/'
145 assert 'devbuild-marker' in manifest 171 'uap:VisualElements/@DisplayName)': 'devbuild-marker',
172 ('string(/ns:Package/ns:Applications/ns:Application/ns:Extensions/'
173 'uap3:Extension/uap3:AppExtension/@Id)'): 'EdgeExtension',
174 'string(/ns:Package/ns:Applications/'
175 'ns:Application/ns:Extensions/uap3:Extension/'
176 'uap3:AppExtension/@DisplayName)': 'devbuild-marker',
177 })
178
179 release = base.copy()
180 release.update({
181 'string(/ns:Package/ns:Properties/ns:DisplayName)': 'Adblock Plus',
182 ('string(/ns:Package/ns:Applications/ns:Application/'
183 'uap:VisualElements/@DisplayName)'): 'Adblock Plus',
184 ('string(/ns:Package/ns:Applications/ns:Application/ns:Extensions/'
185 'uap3:Extension/uap3:AppExtension/@Id)'): '1.0',
186 ('string(/ns:Package/ns:Applications/ns:Application/ns:Extensions/'
187 'uap3:Extension/uap3:AppExtension/@DisplayName)'): 'Adblock Plus',
188 })
189
190 for release_build, pairs in [[False, devbuild], [True, release]]:
Sebastian Noack 2016/12/21 15:54:15 Please use tuples for data that have structure (as
wspee 2017/01/02 14:16:19 Done.
191 manifest = etree.fromstring(packagerEdge.create_appx_manifest(
192 {'metadata': metadata}, files, release_build=release_build))
193 for expression, value in pairs.items():
194 assert manifest.xpath(expression, namespaces=namespaces) == value
146 195
147 196
148 def test_move_files_to_extension(): 197 def test_move_files_to_extension():
149 files = packager.Files(set(), set()) 198 files = packager.Files(set(), set())
150 files['foo.xml'] = CHARS 199 files['foo.xml'] = CHARS
151 files['foo/bar.xml'] = CHARS 200 files['foo/bar.xml'] = CHARS
152 files['Extension/foo.xml'] = CHARS 201 files['Extension/foo.xml'] = CHARS
153 packagerEdge.move_files_to_extension(files) 202 packagerEdge.move_files_to_extension(files)
154 assert set(files.keys()) == { 203 assert set(files.keys()) == {
155 'Extension/foo.xml', 204 'Extension/foo.xml',
(...skipping 15 matching lines...) Expand all
171 assert 'devbuild-marker' not in appx.read('AppxManifest.xml') 220 assert 'devbuild-marker' not in appx.read('AppxManifest.xml')
172 assert appx.read('Assets/logo_44.png') == '44' 221 assert appx.read('Assets/logo_44.png') == '44'
173 assert appx.read('Extension/icons/abp-44.png') == '44' 222 assert appx.read('Extension/icons/abp-44.png') == '44'
174 223
175 224
176 def test_create_devbuild(tmpdir, srcdir): 225 def test_create_devbuild(tmpdir, srcdir):
177 out_file = str(tmpdir.join('abp.appx')) 226 out_file = str(tmpdir.join('abp.appx'))
178 packagerEdge.createBuild(str(srcdir), outFile=out_file, releaseBuild=False) 227 packagerEdge.createBuild(str(srcdir), outFile=out_file, releaseBuild=False)
179 appx = zipfile.ZipFile(out_file) 228 appx = zipfile.ZipFile(out_file)
180 assert 'devbuild-marker' in appx.read('AppxManifest.xml') 229 assert 'devbuild-marker' in appx.read('AppxManifest.xml')
OLDNEW
« no previous file with comments | « tests/AppManifest.xml.expect ('k') | tox.ini » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld