Updated Branches: refs/heads/master 84d14f893 -> a13d5f5e2
Added tests for windows phone Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/a13d5f5e Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/a13d5f5e Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/a13d5f5e Branch: refs/heads/master Commit: a13d5f5e2c7922f739e11dbbd07948ca8eb74d52 Parents: 84d14f8 Author: bennmapes <[email protected]> Authored: Thu Jul 4 15:00:17 2013 -0700 Committer: Benn Mapes <[email protected]> Committed: Thu Jul 4 15:16:05 2013 -0700 ---------------------------------------------------------------------- spec/platforms/wp7.spec.js | 128 ++++++++++++ spec/platforms/wp8.spec.js | 128 ++++++++++++ spec/plugins/DummyPlugin/plugin.xml | 25 +++ spec/plugins/DummyPlugin/src/wp7/DummyPlugin.cs | 19 ++ spec/plugins/DummyPlugin/src/wp8/DummyPlugin.cs | 19 ++ spec/plugins/FaultyPlugin/plugin.xml | 28 +++ .../FaultyPlugin/src/wp7/FaultyPlugin.cs | 19 ++ .../FaultyPlugin/src/wp8/FaultyPlugin.cs | 19 ++ spec/projects/wp7/CordovaAppProj.csproj | 105 ---------- spec/projects/wp7/Properties/WMAppManifest.xml | 28 +++ spec/projects/wp8/An_App.csproj | 201 +++++++++++++++++++ spec/projects/wp8/Properties/WMAppManifest.xml | 39 ++++ spec/util/csproj.spec.js | 80 +++++++- 13 files changed, 729 insertions(+), 109 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/platforms/wp7.spec.js ---------------------------------------------------------------------- diff --git a/spec/platforms/wp7.spec.js b/spec/platforms/wp7.spec.js new file mode 100644 index 0000000..dbbc8b2 --- /dev/null +++ b/spec/platforms/wp7.spec.js @@ -0,0 +1,128 @@ +var wp7 = require('../../src/platforms/wp7'), + common = require('../../src/platforms/common'), + install = require('../../src/install'), + path = require('path'), + fs = require('fs'), + shell = require('shelljs'), + et = require('elementtree'), + os = require('osenv'), + temp = path.join(os.tmpdir(), 'plugman'), + plugins_dir = path.join(temp, 'cordova', 'plugins'), + xml_helpers = require('../../src/util/xml-helpers'), + plugins_module = require('../../src/util/plugins'), + dummyplugin = path.join(__dirname, '..', 'plugins', 'DummyPlugin'), + faultyplugin = path.join(__dirname, '..', 'plugins', 'FaultyPlugin'), + wp7_project = path.join(__dirname, '..', 'projects', 'wp7'); + +var xml_path = path.join(dummyplugin, 'plugin.xml') + , xml_text = fs.readFileSync(xml_path, 'utf-8') + , plugin_et = new et.ElementTree(et.XML(xml_text)); + +var platformTag = plugin_et.find('./platform[@name="wp7"]'); +var dummy_id = plugin_et._root.attrib['id']; +var valid_source = platformTag.findall('./source-file'), + assets = plugin_et.findall('./asset'), + configChanges = platformTag.findall('./config-file'); +xml_path = path.join(faultyplugin, 'plugin.xml') +xml_text = fs.readFileSync(xml_path, 'utf-8') +plugin_et = new et.ElementTree(et.XML(xml_text)); + +platformTag = plugin_et.find('./platform[@name="wp7"]'); +var invalid_source = platformTag.findall('./source-file'); +var faulty_id = plugin_et._root.attrib['id']; + +shell.mkdir('-p', temp); +shell.cp('-rf', path.join(wp7_project, '*'), temp); +var proj_files = wp7.parseWP7ProjectFile(temp); +shell.rm('-rf', temp); + +function copyArray(arr) { + return Array.prototype.slice.call(arr, 0); +} + +describe('wp7 project handler', function() { + + beforeEach(function() { + shell.mkdir('-p', temp); + shell.mkdir('-p', plugins_dir); + }); + afterEach(function() { + shell.rm('-rf', temp); + }); + + describe('www_dir method', function() { + it('should return cordova-wp7 project www location using www_dir', function() { + expect(wp7.www_dir(path.sep)).toEqual(path.sep + 'www'); + }); + }); + describe('package_name method', function() { + it('should return a wp7 project\'s proper package name', function() { + expect(wp7.package_name(wp7_project)).toEqual("{5FC10D78-8779-4EDB-9B61-1D04F0A755D4}"); + }); + }); + + describe('parseWP7ProjectFile method', function() { + it('should throw if project is not an wp7 project', function() { + expect(function() { + wp7.parseWP7ProjectFile(temp); + }).toThrow('does not appear to be a Windows Phone project (no .csproj file)'); + }); + }); + + describe('installation', function() { + beforeEach(function() { + shell.mkdir('-p', temp); + }); + afterEach(function() { + shell.rm('-rf', temp); + }); + describe('of <source-file> elements', function() { + beforeEach(function() { + shell.cp('-rf', path.join(wp7_project, '*'), temp); + }); + it('should copy stuff from one location to another by calling common.copyFile', function() { + var source = copyArray(valid_source); + var s = spyOn(common, 'copyFile'); + wp7['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files); + expect(s).toHaveBeenCalledWith(dummyplugin, 'src/wp7/DummyPlugin.cs', temp, path.join('Plugins', 'com.phonegap.plugins.dummyplugin', 'DummyPlugin.cs')); + }); + it('should throw if source-file src cannot be found', function() { + var source = copyArray(invalid_source); + expect(function() { + wp7['source-file'].install(source[1], faultyplugin, temp, faulty_id, proj_files); + }).toThrow('"' + path.resolve(faultyplugin, 'src/wp7/NotHere.cs') + '" not found!'); + }); + it('should throw if source-file target already exists', function() { + var source = copyArray(valid_source); + var target = path.join(temp, 'Plugins', dummy_id, 'DummyPlugin.cs'); + shell.mkdir('-p', path.dirname(target)); + fs.writeFileSync(target, 'some bs', 'utf-8'); + expect(function() { + wp7['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files); + }).toThrow('"' + target + '" already exists!'); + }); + }); + }); + + describe('uninstallation', function() { + beforeEach(function() { + shell.mkdir('-p', temp); + shell.mkdir('-p', plugins_dir); + shell.cp('-rf', path.join(wp7_project, '*'), temp); + }); + afterEach(function() { + shell.rm('-rf', temp); + }); + describe('of <source-file> elements', function() { + it('should remove stuff by calling common.removeFile', function(done) { + var s = spyOn(common, 'removeFile'); + install('wp7', temp, dummyplugin, plugins_dir, {}, function() { + var source = copyArray(valid_source); + wp7['source-file'].uninstall(source[0], temp, dummy_id, proj_files); + expect(s).toHaveBeenCalledWith(temp, path.join('Plugins', 'com.phonegap.plugins.dummyplugin', 'DummyPlugin.cs')); + done(); + }); + }); + }); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/platforms/wp8.spec.js ---------------------------------------------------------------------- diff --git a/spec/platforms/wp8.spec.js b/spec/platforms/wp8.spec.js new file mode 100644 index 0000000..89e9562 --- /dev/null +++ b/spec/platforms/wp8.spec.js @@ -0,0 +1,128 @@ +var wp8 = require('../../src/platforms/wp8'), + common = require('../../src/platforms/common'), + install = require('../../src/install'), + path = require('path'), + fs = require('fs'), + shell = require('shelljs'), + et = require('elementtree'), + os = require('osenv'), + temp = path.join(os.tmpdir(), 'plugman'), + plugins_dir = path.join(temp, 'cordova', 'plugins'), + xml_helpers = require('../../src/util/xml-helpers'), + plugins_module = require('../../src/util/plugins'), + dummyplugin = path.join(__dirname, '..', 'plugins', 'DummyPlugin'), + faultyplugin = path.join(__dirname, '..', 'plugins', 'FaultyPlugin'), + wp8_project = path.join(__dirname, '..', 'projects', 'wp8'); + +var xml_path = path.join(dummyplugin, 'plugin.xml') + , xml_text = fs.readFileSync(xml_path, 'utf-8') + , plugin_et = new et.ElementTree(et.XML(xml_text)); + +var platformTag = plugin_et.find('./platform[@name="wp8"]'); +var dummy_id = plugin_et._root.attrib['id']; +var valid_source = platformTag.findall('./source-file'), + assets = plugin_et.findall('./asset'), + configChanges = platformTag.findall('./config-file'); +xml_path = path.join(faultyplugin, 'plugin.xml') +xml_text = fs.readFileSync(xml_path, 'utf-8') +plugin_et = new et.ElementTree(et.XML(xml_text)); + +platformTag = plugin_et.find('./platform[@name="wp8"]'); +var invalid_source = platformTag.findall('./source-file'); +var faulty_id = plugin_et._root.attrib['id']; + +shell.mkdir('-p', temp); +shell.cp('-rf', path.join(wp8_project, '*'), temp); +var proj_files = wp8.parseWP8ProjectFile(temp); +shell.rm('-rf', temp); + +function copyArray(arr) { + return Array.prototype.slice.call(arr, 0); +} + +describe('wp8 project handler', function() { + + beforeEach(function() { + shell.mkdir('-p', temp); + shell.mkdir('-p', plugins_dir); + }); + afterEach(function() { + shell.rm('-rf', temp); + }); + + describe('www_dir method', function() { + it('should return cordova-wp8 project www location using www_dir', function() { + expect(wp8.www_dir(path.sep)).toEqual(path.sep + 'www'); + }); + }); + describe('package_name method', function() { + it('should return a wp8 project\'s proper package name', function() { + expect(wp8.package_name(wp8_project)).toEqual("{F3A8197B-6B16-456D-B5F4-DD4F04AC0BEC}"); + }); + }); + + describe('parsewp8ProjectFile method', function() { + it('should throw if project is not an wp8 project', function() { + expect(function() { + wp8.parseWP8ProjectFile(temp); + }).toThrow('does not appear to be a Windows Phone project (no .csproj file)'); + }); + }); + + describe('installation', function() { + beforeEach(function() { + shell.mkdir('-p', temp); + }); + afterEach(function() { + shell.rm('-rf', temp); + }); + describe('of <source-file> elements', function() { + beforeEach(function() { + shell.cp('-rf', path.join(wp8_project, '*'), temp); + }); + it('should copy stuff from one location to another by calling common.copyFile', function() { + var source = copyArray(valid_source); + var s = spyOn(common, 'copyFile'); + wp8['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files); + expect(s).toHaveBeenCalledWith(dummyplugin, 'src/wp8/DummyPlugin.cs', temp, path.join('Plugins', 'com.phonegap.plugins.dummyplugin', 'DummyPlugin.cs')); + }); + it('should throw if source-file src cannot be found', function() { + var source = copyArray(invalid_source); + expect(function() { + wp8['source-file'].install(source[1], faultyplugin, temp, faulty_id, proj_files); + }).toThrow('"' + path.resolve(faultyplugin, 'src/wp8/NotHere.cs') + '" not found!'); + }); + it('should throw if source-file target already exists', function() { + var source = copyArray(valid_source); + var target = path.join(temp, 'Plugins', dummy_id, 'DummyPlugin.cs'); + shell.mkdir('-p', path.dirname(target)); + fs.writeFileSync(target, 'some bs', 'utf-8'); + expect(function() { + wp8['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files); + }).toThrow('"' + target + '" already exists!'); + }); + }); + }); + + describe('uninstallation', function() { + beforeEach(function() { + shell.mkdir('-p', temp); + shell.mkdir('-p', plugins_dir); + shell.cp('-rf', path.join(wp8_project, '*'), temp); + }); + afterEach(function() { + shell.rm('-rf', temp); + }); + describe('of <source-file> elements', function() { + it('should remove stuff by calling common.removeFile', function(done) { + var s = spyOn(common, 'removeFile'); + install('wp8', temp, dummyplugin, plugins_dir, {}, function() { + var source = copyArray(valid_source); + wp8['source-file'].uninstall(source[0], temp, dummy_id, proj_files); + expect(s).toHaveBeenCalledWith(temp, path.join('Plugins', 'com.phonegap.plugins.dummyplugin', 'DummyPlugin.cs')); + done(); + }); + }); + }); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/plugins/DummyPlugin/plugin.xml ---------------------------------------------------------------------- diff --git a/spec/plugins/DummyPlugin/plugin.xml b/spec/plugins/DummyPlugin/plugin.xml index 87935ba..deba345 100644 --- a/spec/plugins/DummyPlugin/plugin.xml +++ b/spec/plugins/DummyPlugin/plugin.xml @@ -98,4 +98,29 @@ <framework src="src/ios/libsqlite3.dylib" /> <framework src="src/ios/libsqlite3.dylib" weak="true" /> </platform> + + <!-- wp7 --> + <platform name="wp7"> + <config-file target="config.xml" parent="/*"> + <feature id="dummyPlugin" required="true" version="1.0.0.0"/> + </config-file> + + <source-file src="src/wp7/DummyPlugin.cs"/> + <js-module src="www/dummyplugin.js" name="Dummy"> + <clobbers target="dummy" /> + </js-module> + </platform> + + <!-- wp8 --> + <platform name="wp8"> + <config-file target="config.xml" parent="/*"> + <feature id="dummyPlugin" required="true" version="1.0.0.0"/> + </config-file> + + <source-file src="src/wp8/DummyPlugin.cs"/> + <js-module src="www/dummyplugin.js" name="Dummy"> + <clobbers target="dummy" /> + </js-module> + </platform> + </plugin> http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/plugins/DummyPlugin/src/wp7/DummyPlugin.cs ---------------------------------------------------------------------- diff --git a/spec/plugins/DummyPlugin/src/wp7/DummyPlugin.cs b/spec/plugins/DummyPlugin/src/wp7/DummyPlugin.cs new file mode 100644 index 0000000..273dc3b --- /dev/null +++ b/spec/plugins/DummyPlugin/src/wp7/DummyPlugin.cs @@ -0,0 +1,19 @@ +/* + * + * Copyright 2013 Benn Mapes + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/plugins/DummyPlugin/src/wp8/DummyPlugin.cs ---------------------------------------------------------------------- diff --git a/spec/plugins/DummyPlugin/src/wp8/DummyPlugin.cs b/spec/plugins/DummyPlugin/src/wp8/DummyPlugin.cs new file mode 100644 index 0000000..273dc3b --- /dev/null +++ b/spec/plugins/DummyPlugin/src/wp8/DummyPlugin.cs @@ -0,0 +1,19 @@ +/* + * + * Copyright 2013 Benn Mapes + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/plugins/FaultyPlugin/plugin.xml ---------------------------------------------------------------------- diff --git a/spec/plugins/FaultyPlugin/plugin.xml b/spec/plugins/FaultyPlugin/plugin.xml index b705b48..29ab0c6 100644 --- a/spec/plugins/FaultyPlugin/plugin.xml +++ b/spec/plugins/FaultyPlugin/plugin.xml @@ -88,4 +88,32 @@ <lib-file src="src/blackberry10/device/echoJnext.so" target-dir="ext-qnx/cordova.echo/device" /> <lib-file src="src/blackberry10/simulator/echoJnext.so" target-dir="ext-qnx/cordova.echo/simulator" /> </platform> + + <!-- wp7 --> + <platform name="wp7"> + <config-file target="config.xml" parent="/*"> + <feature name="FaultyPlugin"> + <param name="wp-package" value="FaultyPlugin"/> + </feature> + </config-file> + + <source-file src="src/wp7/FaultyPlugin.cs" /> + + <!-- this desn't exist --> + <source-file src="src/wp7/NotHere.cs" /> + </platform> + + <!-- wp8 --> + <platform name="wp8"> + <config-file target="config.xml" parent="/*"> + <feature name="FaultyPlugin"> + <param name="wp-package" value="FaultyPlugin"/> + </feature> + </config-file> + + <source-file src="src/wp8/FaultyPlugin.cs" /> + + <!-- this desn't exist --> + <source-file src="src/wp8/NotHere.cs" /> + </platform> </plugin> http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/plugins/FaultyPlugin/src/wp7/FaultyPlugin.cs ---------------------------------------------------------------------- diff --git a/spec/plugins/FaultyPlugin/src/wp7/FaultyPlugin.cs b/spec/plugins/FaultyPlugin/src/wp7/FaultyPlugin.cs new file mode 100644 index 0000000..5263b0c --- /dev/null +++ b/spec/plugins/FaultyPlugin/src/wp7/FaultyPlugin.cs @@ -0,0 +1,19 @@ +/* + * + * Copyright 2013 Anis Kadri + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/plugins/FaultyPlugin/src/wp8/FaultyPlugin.cs ---------------------------------------------------------------------- diff --git a/spec/plugins/FaultyPlugin/src/wp8/FaultyPlugin.cs b/spec/plugins/FaultyPlugin/src/wp8/FaultyPlugin.cs new file mode 100644 index 0000000..5263b0c --- /dev/null +++ b/spec/plugins/FaultyPlugin/src/wp8/FaultyPlugin.cs @@ -0,0 +1,19 @@ +/* + * + * Copyright 2013 Anis Kadri + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/projects/wp7/CordovaAppProj.csproj ---------------------------------------------------------------------- diff --git a/spec/projects/wp7/CordovaAppProj.csproj b/spec/projects/wp7/CordovaAppProj.csproj index 560c1d7..879bd1e 100644 --- a/spec/projects/wp7/CordovaAppProj.csproj +++ b/spec/projects/wp7/CordovaAppProj.csproj @@ -80,111 +80,6 @@ <Reference Include="System.Xml" /> <Reference Include="System.Xml.Linq" /> </ItemGroup> - <ItemGroup> - <Compile Include="App.xaml.cs"> - <DependentUpon>App.xaml</DependentUpon> - </Compile> - <Compile Include="cordovalib\BrowserMouseHelper.cs" /> - <Compile Include="cordovalib\CommandFactory.cs" /> - <Compile Include="cordovalib\Commands\BaseCommand.cs" /> - <Compile Include="cordovalib\ConfigHandler.cs" /> - <Compile Include="cordovalib\CordovaCommandCall.cs" /> - <Compile Include="cordovalib\CordovaView.xaml.cs"> - <DependentUpon>CordovaView.xaml</DependentUpon> - </Compile> - <Compile Include="cordovalib\DOMStorageHelper.cs" /> - <Compile Include="cordovalib\JSON\JsonHelper.cs" /> - <Compile Include="cordovalib\NativeExecution.cs" /> - <Compile Include="cordovalib\OrientationHelper.cs" /> - <Compile Include="cordovalib\PluginResult.cs" /> - <Compile Include="cordovalib\ScriptCallback.cs" /> - <Compile Include="MainPage.xaml.cs"> - <DependentUpon>MainPage.xaml</DependentUpon> - </Compile> - <Compile Include="Properties\AssemblyInfo.cs" /> - </ItemGroup> - <ItemGroup> - <ApplicationDefinition Include="App.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </ApplicationDefinition> - <Page Include="cordovalib\CordovaView.xaml"> - <Generator>MSBuild:Compile</Generator> - <SubType>Designer</SubType> - </Page> - <Page Include="MainPage.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> - <Page Include="Plugins\UI\AudioRecorder.xaml"> - <Generator>MSBuild:Compile</Generator> - <SubType>Designer</SubType> - </Page> - <Page Include="Plugins\UI\ImageCapture.xaml"> - <Generator>MSBuild:Compile</Generator> - <SubType>Designer</SubType> - </Page> - <Page Include="Plugins\UI\NotificationBox.xaml"> - <Generator>MSBuild:Compile</Generator> - <SubType>Designer</SubType> - </Page> - <Page Include="Plugins\UI\VideoRecorder.xaml"> - <Generator>MSBuild:Compile</Generator> - <SubType>Designer</SubType> - </Page> - </ItemGroup> - <ItemGroup> - <None Include="cordova\lib\build.js" /> - <None Include="cordova\lib\clean.js" /> - <None Include="cordova\lib\deploy.js" /> - <None Include="cordova\lib\log.js" /> - <None Include="cordova\lib\target-list.js" /> - <Content Include="www\**" /> - <Content Include="config.xml" /> - <Content Include="Images\**" /> - <Content Include="resources\notification-beep.wav" /> - <None Include="cordova\build.bat" /> - <None Include="cordova\clean.bat" /> - <None Include="cordova\lib\install-device.bat" /> - <None Include="cordova\lib\install-emulator.bat" /> - <None Include="cordova\lib\list-devices.bat" /> - <None Include="cordova\lib\list-emulator-images.bat" /> - <None Include="cordova\lib\list-started-emulators.bat" /> - <None Include="cordova\lib\start-emulator.bat" /> - <None Include="cordova\log.bat" /> - <None Include="cordova\run.bat" /> - <None Include="cordova\version.bat" /> - <None Include="VERSION" /> - <Content Include="CordovaSourceDictionary.xml"> - <SubType>Designer</SubType> - </Content> - <None Include="BuildManifestProcessor.js" /> - <None Include="Properties\AppManifest.xml"> - <SubType>Designer</SubType> - </None> - <None Include="Properties\WMAppManifest.xml"> - <SubType>Designer</SubType> - </None> - </ItemGroup> - <ItemGroup> - <Content Include="ApplicationIcon.png"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="Background.png"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="SplashScreenImage.jpg" /> - </ItemGroup> - <ItemGroup> - <WCFMetadata Include="Service References\" /> - </ItemGroup> - <ItemGroup> - <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Plugins\*" /> - <Compile Include="Plugins\UI\*.cs" /> - </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" /> <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/projects/wp7/Properties/WMAppManifest.xml ---------------------------------------------------------------------- diff --git a/spec/projects/wp7/Properties/WMAppManifest.xml b/spec/projects/wp7/Properties/WMAppManifest.xml new file mode 100644 index 0000000..b218fcb --- /dev/null +++ b/spec/projects/wp7/Properties/WMAppManifest.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.1"> + <App xmlns="" ProductID="{5FC10D78-8779-4EDB-9B61-1D04F0A755D4}" Title="An App" + RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" + Author="An App author" + BitsPerPixel="32" + Description="Apache Cordova for Windows Phone 7" + Publisher="An App"> + + <IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath> + <Capabilities> + <Capability Name="ID_CAP_WEBBROWSERCOMPONENT" /> + </Capabilities> + + <Tasks> + <DefaultTask Name="_default" NavigationPage="MainPage.xaml" /> + </Tasks> + <Tokens> + <PrimaryToken TokenID="An AppToken" TaskName="_default"> + <TemplateType5> + <BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI> + <Count>0</Count> + <Title>An App</Title> + </TemplateType5> + </PrimaryToken> + </Tokens> + </App> +</Deployment> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/projects/wp8/An_App.csproj ---------------------------------------------------------------------- diff --git a/spec/projects/wp8/An_App.csproj b/spec/projects/wp8/An_App.csproj new file mode 100644 index 0000000..7be41c9 --- /dev/null +++ b/spec/projects/wp8/An_App.csproj @@ -0,0 +1,201 @@ +<?xml version='1.0' encoding='utf-8'?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>10.0.20506</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}</ProjectGuid> + <ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>my.test.project</RootNamespace> + <AssemblyName>my.test.project</AssemblyName> + <TargetFrameworkVersion>v8.0</TargetFrameworkVersion> + <SilverlightVersion> + </SilverlightVersion> + <TargetFrameworkProfile> + </TargetFrameworkProfile> + <TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier> + <SilverlightApplication>true</SilverlightApplication> + <SupportedCultures>en-US</SupportedCultures> + <XapOutputs>true</XapOutputs> + <GenerateSilverlightManifest>true</GenerateSilverlightManifest> + <XapFilename>CordovaAppProj_$(Configuration)_$(Platform).xap</XapFilename> + <SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate> + <SilverlightAppEntry>my.test.project.App</SilverlightAppEntry> + <ValidateXaml>true</ValidateXaml> + <ThrowErrorsInValidation>true</ThrowErrorsInValidation> + <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion> + <BackgroundAgentType /> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>Bin\Debug</OutputPath> + <DefineConstants>TRACE;DEBUG;SILVERLIGHT;WINDOWS_PHONE;WP8</DefineConstants> + <NoStdLib>true</NoStdLib> + <NoConfig>true</NoConfig> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <Prefer32Bit>false</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>Bin\Release</OutputPath> + <DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE;WP8</DefineConstants> + <NoStdLib>true</NoStdLib> + <NoConfig>true</NoConfig> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <Prefer32Bit>false</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>Bin\x86\Debug</OutputPath> + <DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants> + <NoStdLib>true</NoStdLib> + <DebugType>full</DebugType> + <PlatformTarget> + </PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet> + <Optimize>false</Optimize> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> + <OutputPath>Bin\x86\Release</OutputPath> + <DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants> + <Optimize>true</Optimize> + <NoStdLib>true</NoStdLib> + <DebugType>pdbonly</DebugType> + <PlatformTarget> + </PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet> + <Prefer32Bit>false</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>Bin\ARM\Debug</OutputPath> + <DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants> + <NoStdLib>true</NoStdLib> + <DebugType>full</DebugType> + <PlatformTarget> + </PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet> + <Prefer32Bit>false</Prefer32Bit> + <Optimize>false</Optimize> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'"> + <OutputPath>Bin\ARM\Release</OutputPath> + <DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants> + <Optimize>true</Optimize> + <NoStdLib>true</NoStdLib> + <DebugType>pdbonly</DebugType> + <PlatformTarget> + </PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet> + <Prefer32Bit>false</Prefer32Bit> + </PropertyGroup> + <ItemGroup> + <Compile Include="App.xaml.cs"> + <DependentUpon>App.xaml</DependentUpon> + </Compile> + <Compile Include="cordovalib\BrowserMouseHelper.cs" /> + <Compile Include="cordovalib\CommandFactory.cs" /> + <Compile Include="cordovalib\Commands\BaseCommand.cs" /> + <Compile Include="cordovalib\ConfigHandler.cs" /> + <Compile Include="cordovalib\CordovaCommandCall.cs" /> + <Compile Include="cordovalib\CordovaView.xaml.cs"> + <DependentUpon>CordovaView.xaml</DependentUpon> + </Compile> + <Compile Include="cordovalib\IBrowserDecorator.cs" /> + <Compile Include="cordovalib\ImageExifHelper.cs" /> + <Compile Include="cordovalib\JSON\JsonHelper.cs" /> + <Compile Include="cordovalib\NativeExecution.cs" /> + <Compile Include="cordovalib\OrientationHelper.cs" /> + <Compile Include="cordovalib\PluginResult.cs" /> + <Compile Include="cordovalib\ScriptCallback.cs" /> + <Compile Include="cordovalib\XHRHelper.cs" /> + <Compile Include="cordovalib\MimeTypeMapper.cs" /> + <Compile Include="Plugins\DebugConsole.cs" /> + <Compile Include="MainPage.xaml.cs"> + <DependentUpon>MainPage.xaml</DependentUpon> + </Compile> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ApplicationDefinition Include="App.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </ApplicationDefinition> + <Page Include="cordovalib\CordovaView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="MainPage.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + </ItemGroup> + <ItemGroup> + <Content Include="www\**" /> + <None Include="cordova\lib\build.js" /> + <None Include="cordova\lib\clean.js" /> + <None Include="cordova\lib\deploy.js" /> + <None Include="cordova\lib\log.js" /> + <None Include="cordova\lib\target-list.js" /> + <Content Include="config.xml" /> + <Content Include="Images\**" /> + <Content Include="resources\notification-beep.wav" /> + <None Include="cordova\build.bat" /> + <None Include="cordova\clean.bat" /> + <None Include="cordova\lib\install-device.bat" /> + <None Include="cordova\lib\install-emulator.bat" /> + <None Include="cordova\lib\list-devices.bat" /> + <None Include="cordova\lib\list-emulator-images.bat" /> + <None Include="cordova\lib\list-started-emulators.bat" /> + <None Include="cordova\lib\start-emulator.bat" /> + <None Include="cordova\log.bat" /> + <None Include="cordova\run.bat" /> + <None Include="cordova\version.bat" /> + <None Include="VERSION" /> + <None Include="Properties\AppManifest.xml"> + <SubType>Designer</SubType> + </None> + <None Include="Properties\WMAppManifest.xml"> + <SubType>Designer</SubType> + </None> + </ItemGroup> + <ItemGroup> + <Content Include="ApplicationIcon.png"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="Background.png"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="SplashScreenImage.jpg" /> + </ItemGroup> + <ItemGroup> + <WCFMetadata Include="Service References\" /> + </ItemGroup> + <ItemGroup> + <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> + </ItemGroup> + <Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" /> + <Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" /> + <ProjectExtensions /> + <PropertyGroup> + </PropertyGroup> + <PropertyGroup> + <PostBuildEvent> + </PostBuildEvent> + </PropertyGroup> + <ItemGroup> + <Compile Include="Plugins\org.apache.cordova.core.InAppBrowser\InAppBrowser.cs" /> + </ItemGroup> +</Project> http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/projects/wp8/Properties/WMAppManifest.xml ---------------------------------------------------------------------- diff --git a/spec/projects/wp8/Properties/WMAppManifest.xml b/spec/projects/wp8/Properties/WMAppManifest.xml new file mode 100644 index 0000000..5b37a95 --- /dev/null +++ b/spec/projects/wp8/Properties/WMAppManifest.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0"> + <DefaultLanguage xmlns="" code="en-US" /> + <Languages xmlns=""> + <Language code="en-US" /> + </Languages> + <App xmlns="" ProductID="{F3A8197B-6B16-456D-B5F4-DD4F04AC0BEC}" Title="An App" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="An App author" BitsPerPixel="32" Description="Apache Cordova for Windows Phone" Publisher="An App" PublisherID="{db093ed5-53b1-45f7-af72-751e8f36ab80}"> + <IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath> + <Capabilities> + <Capability Name="ID_CAP_WEBBROWSERCOMPONENT" /> + </Capabilities> + <Tasks> + <DefaultTask Name="_default" NavigationPage="MainPage.xaml" /> + </Tasks> + <Tokens> + <PrimaryToken TokenID="An AppToken" TaskName="_default"> + <TemplateFlip> + <SmallImageURI IsResource="false" IsRelative="true">Background.png</SmallImageURI> + <Count>0</Count> + <BackgroundImageURI IsResource="false" IsRelative="true">Background.png</BackgroundImageURI> + <Title>An App</Title> + <BackContent></BackContent> + <BackBackgroundImageURI></BackBackgroundImageURI> + <BackTitle></BackTitle> + <LargeBackgroundImageURI></LargeBackgroundImageURI> + <LargeBackContent></LargeBackContent> + <LargeBackBackgroundImageURI></LargeBackBackgroundImageURI> + <DeviceLockImageURI></DeviceLockImageURI> + <HasLarge>false</HasLarge> + </TemplateFlip> + </PrimaryToken> + </Tokens> + <ScreenResolutions> + <ScreenResolution Name="ID_RESOLUTION_WVGA" /> + <ScreenResolution Name="ID_RESOLUTION_WXGA" /> + <ScreenResolution Name="ID_RESOLUTION_HD720P" /> + </ScreenResolutions> + </App> +</Deployment> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a13d5f5e/spec/util/csproj.spec.js ---------------------------------------------------------------------- diff --git a/spec/util/csproj.spec.js b/spec/util/csproj.spec.js index b1bdcb2..fb66f6c 100644 --- a/spec/util/csproj.spec.js +++ b/spec/util/csproj.spec.js @@ -1,8 +1,14 @@ -var csproj = require('../../src/util/csproj'), - path = require('path'); +var csproj = require('../../src/util/csproj'), + path = require('path'), + os = require('osenv'), + et = require('elementtree'), + fs = require('fs'), + xml_helpers = require('../../src/util/xml-helpers'); -var wp7_project = path.join(__dirname, '..', 'projects', 'wp7'), - example_csproj = path.join(wp7_project, 'CordovaAppProj.csproj'); +var wp7_project = path.join(__dirname, '..', 'projects', 'wp7'), + temp = path.join(os.tmpdir(), 'plugman'), + example_csproj = path.join(wp7_project, 'CordovaAppProj.csproj'), + wpcsproj = path.join(__dirname, '..', 'plugins', 'WPcsproj'); describe('csproj', function() { it('should throw if passed in an invalid xml file path ref', function() { @@ -21,4 +27,70 @@ describe('csproj', function() { describe('write method', function() { }); + + describe('source file', function() { + var test_csproj = new csproj(example_csproj); + var page_test = path.join('src', 'UI', 'PageTest.xaml'); + var page_test_cs = path.join('src', 'UI', 'PageTest.xaml.cs'); + var lib_test = path.join('lib', 'LibraryTest.dll'); + var file_test = path.join('src', 'FileTest.cs'); + + describe('add method', function() { + + it('should properly add .xaml files', function() { + test_csproj.addSourceFile(page_test); + console.log(test_csproj.xml.getroot().findall('.//Page')); + expect(test_csproj.xml.getroot().find('.//Page[@Include="src\\UI\\PageTest.xaml"]')).toBeTruthy(); + expect(test_csproj.xml.getroot().find('.//Page[@Include="src\\UI\\PageTest.xaml"]/Generator').text).toEqual('MSBuild:Compile'); + expect(test_csproj.xml.getroot().find('.//Page[@Include="src\\UI\\PageTest.xaml"]/SubType').text).toEqual('Designer'); + }); + it('should properly add .xaml.cs files', function() { + test_csproj.addSourceFile(page_test_cs); + expect(test_csproj.xml.getroot().find('.//Compile[@Include="src\\UI\\PageTest.xaml.cs"]')).toBeTruthy(); + expect(test_csproj.xml.getroot().find('.//Compile[@Include="src\\UI\\PageTest.xaml.cs"]/DependentUpon').text).toEqual('PageTest.xaml'); + }); + it('should properly add .dll references', function() { + test_csproj.addSourceFile(lib_test); + expect(test_csproj.xml.getroot().find('.//Reference[@Include="LibraryTest"]')).toBeTruthy(); + expect(test_csproj.xml.getroot().find('.//Reference[@Include="LibraryTest"]/HintPath').text).toEqual('lib\\LibraryTest.dll'); + }); + it('should properly add .cs files', function() { + test_csproj.addSourceFile(file_test); + expect(test_csproj.xml.getroot().find('.//Compile[@Include="src\\FileTest.cs"]')).toBeTruthy(); + }); + + }); + + describe('remove method', function() { + + it('should properly remove .xaml pages', function() { + test_csproj.removeSourceFile(page_test); + expect(test_csproj.xml.getroot().find('.//Page[@Include="src\\UI\\PageTest.xaml"]')).toBeFalsy(); + }); + it('should properly remove .xaml.cs files', function() { + test_csproj.removeSourceFile(page_test_cs); + expect(test_csproj.xml.getroot().find('.//Compile[@Include="src\\UI\\PageTest.xaml.cs"]')).toBeFalsy(); + }); + it('should properly remove .dll references', function() { + test_csproj.removeSourceFile(lib_test); + expect(test_csproj.xml.getroot().find('.//Reference[@Include="LibraryTest"]')).toBeFalsy(); + }); + it('should properly remove .cs files', function() { + test_csproj.removeSourceFile(file_test); + expect(test_csproj.xml.getroot().find('.//Compile[@Include="src\\FileTest.cs"]')).toBeFalsy(); + }); + it('should remove all empty ItemGroup\'s', function() { + test_csproj.removeSourceFile(page_test); + test_csproj.removeSourceFile(page_test_cs); + test_csproj.removeSourceFile(lib_test); + test_csproj.removeSourceFile(file_test); + var item_groups = test_csproj.xml.findall('ItemGroup'); + for (var i = 0, l = item_groups.length; i < l; i++) { + var group = item_groups[i]; + expect(group._children.length).toBeGreaterThan(0); + } + }) + + }); + }); });
