Github user vladimir-kotikov commented on a diff in the pull request: https://github.com/apache/cordova-windows/pull/159#discussion_r56635687 --- Diff: spec/unit/Prepare.Win10.spec.js --- @@ -380,3 +383,79 @@ describe('A Windows 10 project should apply the uap: namespace prefix to certain expect(testResults.location).toBe('DeviceCapability'); }); }); + +describe('copyIcons method', function () { + var copyImages = prepare.__get__('copyImages'); + + var PROJECT = '/some/path'; + + function createMockConfig(images) { + var result = jasmine.createSpyObj('config', ['getIcons', 'getSplashScreens']); + result.getIcons.andReturn(images); + result.getSplashScreens.andReturn([]); + + return result; + } + + beforeEach(function () { + spyOn(shell, 'cp'); + }); + + it('should guess target filename based on icon size', function () { + var images = [ + {src: 'res/Windows/Square44x44Logo_100.png', width: '44', height: '44' }, + {src: 'res/Windows/Square44x44Logo_240.png', width: '106', height: '106' } + ]; + + var config = createMockConfig(images); + + copyImages(config, PROJECT); + + expect(shell.cp).toHaveBeenCalledWith('-f', path.normalize('res/Windows/Square44x44Logo_100.png'), path.join(PROJECT, 'images/Square44x44Logo.scale-100.png')); + expect(shell.cp).toHaveBeenCalledWith('-f', path.normalize('res/Windows/Square44x44Logo_240.png'), path.join(PROJECT, 'images/Square44x44Logo.scale-240.png')); + }); + + it('should ignore unknown icon sizes and emit a warning', function () { + var config = createMockConfig([ + {src: 'res/Windows/UnknownImage.png', width: '999', height: '999' }, + ]); + + var warnSpy = jasmine.createSpy('warn'); + events.on('warn', warnSpy); + copyImages(config, PROJECT); + expect(shell.cp).not.toHaveBeenCalled(); + expect(warnSpy.calls[0].args[0]).toMatch('image is skipped'); + }); + + describe('when "target" attribute is specified for the image', function () { + it('should copy all images with the same base name and extension to destination dir', function () { + var matchingFiles = [ + 'res/Windows/Square44x44.scale-100.png', + 'res/Windows/Square44x44.targetsize-16.png', + 'res/Windows/Square44x44.scale-150_targetsize-16.png', + 'res/Windows/Square44x44.targetsize-16_scale-200.png', --- End diff -- From [doc](https://msdn.microsoft.com/en-us/library/windows/apps/hh965372.aspx) the syntax is: > The dotted segment in the file just before the file extension is considered a token that indicates qualifiers. Multiple qualifiers are separated by an underscore, and qualifiers are traditionally specified with their name and value It's not very clear what happens if the last segment doesn't match any qualifier or has some incorrect qualifier name/value, so i preferred not to perform any validation here. Also i've just checked and it seems that MSBuild already does some basic validation and emits a warning in this case ``` e:\PROJECTS\Temp\foo λ cordova build windows Building project: e:\PROJECTS\Temp\foo\platforms\windows\CordovaApp.Windows.jsproj Configuration : debug Platform : anycpu MakePRI : warning 0xdef00520: Invalid qualifier: DIMENSION-240 [e:\PROJECTS\Temp\foo\platforms\windows\CordovaApp.Windows.jsproj] MakePRI : warning 0xdef00520: Invalid qualifier: SCALE-FOO [e:\PROJECTS\Temp\foo\platforms\windows\CordovaApp.Windows.jsproj] MakePRI : warning 0xdef00520: Invalid qualifier: SCALE-240_DIMENSION-FOO [e:\PROJECTS\Temp\foo\platforms\windows\CordovaApp.Windows.jsproj] ``` the build succeeds though, and the resultant package contains improperly named files, so i think we could rely on MSBuild here.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org