You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2013/07/30 01:36:24 UTC
[04/12] git commit: fixing tests
fixing tests
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/c8c4bc1e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/c8c4bc1e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/c8c4bc1e
Branch: refs/heads/master
Commit: c8c4bc1e841687fc6071af1589dd49e04bea37cf
Parents: 138877a
Author: purplecabbage <pu...@gmail.com>
Authored: Wed Jul 24 16:37:34 2013 -0700
Committer: purplecabbage <pu...@gmail.com>
Committed: Mon Jul 29 16:23:34 2013 -0700
----------------------------------------------------------------------
spec/platforms/windows8.spec.js | 134 +
spec/plugins/DummyPlugin/plugin.xml | 12 +
spec/plugins/DummyPlugin/src/windows8/dummer.js | 0
spec/plugins/FaultyPlugin/plugin.xml | 14 +
.../FaultyPlugin/src/windows8/faultyPlugin.js | 0
.../windows8/CordovaApp_TemporaryKey.pfx | Bin 0 -> 2504 bytes
spec/projects/windows8/TestApp.jsproj | 81 +
spec/projects/windows8/TestApp.sln | 46 +
spec/projects/windows8/package.appxmanifest | 27 +
spec/projects/windows8/www/cordova-2.6.0.js | 8075 ++++++++++++++++++
spec/projects/windows8/www/css/index.css | 115 +
spec/projects/windows8/www/img/logo.png | Bin 0 -> 11600 bytes
spec/projects/windows8/www/img/smalllogo.png | Bin 0 -> 2831 bytes
spec/projects/windows8/www/img/splashscreen.png | Bin 0 -> 24855 bytes
spec/projects/windows8/www/img/storelogo.png | Bin 0 -> 4052 bytes
spec/projects/windows8/www/index.html | 42 +
spec/projects/windows8/www/js/index.js | 49 +
src/platforms.js | 3 +-
src/platforms/windows8.js | 12 +-
src/util/w8jsproj.js | 3 +-
20 files changed, 8606 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c8c4bc1e/spec/platforms/windows8.spec.js
----------------------------------------------------------------------
diff --git a/spec/platforms/windows8.spec.js b/spec/platforms/windows8.spec.js
new file mode 100644
index 0000000..8a61570
--- /dev/null
+++ b/spec/platforms/windows8.spec.js
@@ -0,0 +1,134 @@
+var windows8 = require('../../src/platforms/windows8'),
+ 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'),
+ windows8_project = path.join(__dirname, '..', 'projects', 'windows8');
+
+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="windows8"]');
+var dummy_id = plugin_et._root.attrib['id'];
+
+var valid_source = platformTag.findall('./source-file');
+var assets = plugin_et.findall('./asset');
+
+var 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="windows8"]');
+
+var invalid_source = platformTag.findall('./source-file');
+
+var faulty_id = plugin_et._root.attrib['id'];
+
+shell.mkdir('-p', temp);
+shell.cp('-rf', path.join(windows8_project, '*'), temp);
+var proj_files = windows8.parseProjectFile(temp);
+shell.rm('-rf', temp);
+
+function copyArray(arr) {
+ return Array.prototype.slice.call(arr, 0);
+}
+
+describe('windows8 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-windows8 project www location using www_dir', function() {
+ expect(windows8.www_dir(path.sep)).toEqual(path.sep + 'www');
+ });
+ });
+ describe('package_name method', function() {
+ it('should return a windows8 project\'s proper package name', function() {
+ expect(windows8.package_name(windows8_project)).toEqual("CordovaApp");
+ });
+ });
+
+ describe('parseProjectFile method', function() {
+ it('should throw if project is not an windows8 project', function() {
+ expect(function() {
+ windows8.parseProjectFile(temp);
+ }).toThrow(windows8.InvalidProjectPathError);
+ });
+ });
+
+ 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(windows8_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');
+ windows8['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(s).toHaveBeenCalledWith(dummyplugin, 'src/windows8/dummer.js', temp, path.join('Plugins', 'com.phonegap.plugins.dummyplugin', 'dummer.js'));
+ });
+ it('should throw if source-file src cannot be found', function() {
+ var source = copyArray(invalid_source);
+ expect(function() {
+ windows8['source-file'].install(source[1], faultyplugin, temp, faulty_id, proj_files);
+ }).toThrow('"' + path.resolve(faultyplugin, 'src/windows8/NotHere.js') + '" 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, 'dummer.js');
+ shell.mkdir('-p', path.dirname(target));
+ fs.writeFileSync(target, 'some bs', 'utf-8');
+ expect(function() {
+ windows8['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(windows8_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('windows8', temp, dummyplugin, plugins_dir, {}, function() {
+ var source = copyArray(valid_source);
+ windows8['source-file'].uninstall(source[0], temp, dummy_id, proj_files);
+ expect(s).toHaveBeenCalledWith(temp, path.join('Plugins', 'com.phonegap.plugins.dummyplugin', 'dummer.js'));
+ done();
+ });
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c8c4bc1e/spec/plugins/DummyPlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/DummyPlugin/plugin.xml b/spec/plugins/DummyPlugin/plugin.xml
index 162044a..61e4e52 100644
--- a/spec/plugins/DummyPlugin/plugin.xml
+++ b/spec/plugins/DummyPlugin/plugin.xml
@@ -130,4 +130,16 @@
</js-module>
</platform>
+ <!-- windows8 -->
+ <platform name="windows8">
+ <config-file target="config.xml" parent="/*">
+ <feature id="dummyPlugin" required="true" version="1.0.0.0"/>
+ </config-file>
+
+ <source-file src="src/windows8/dummer.js"/>
+ <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/c8c4bc1e/spec/plugins/DummyPlugin/src/windows8/dummer.js
----------------------------------------------------------------------
diff --git a/spec/plugins/DummyPlugin/src/windows8/dummer.js b/spec/plugins/DummyPlugin/src/windows8/dummer.js
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c8c4bc1e/spec/plugins/FaultyPlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/FaultyPlugin/plugin.xml b/spec/plugins/FaultyPlugin/plugin.xml
index 29ab0c6..30af6e7 100644
--- a/spec/plugins/FaultyPlugin/plugin.xml
+++ b/spec/plugins/FaultyPlugin/plugin.xml
@@ -116,4 +116,18 @@
<!-- this desn't exist -->
<source-file src="src/wp8/NotHere.cs" />
</platform>
+
+ <!-- wp8 -->
+ <platform name="windows8">
+ <config-file target="config.xml" parent="/*">
+ <feature name="FaultyPlugin">
+ <param name="windows8-package" value="FaultyPlugin"/>
+ </feature>
+ </config-file>
+
+ <source-file src="src/windows8/faultyPlugin.js" />
+
+ <!-- does not exist -->
+ <source-file src="src/windows8/NotHere.js" />
+ </platform>
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c8c4bc1e/spec/plugins/FaultyPlugin/src/windows8/faultyPlugin.js
----------------------------------------------------------------------
diff --git a/spec/plugins/FaultyPlugin/src/windows8/faultyPlugin.js b/spec/plugins/FaultyPlugin/src/windows8/faultyPlugin.js
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c8c4bc1e/spec/projects/windows8/CordovaApp_TemporaryKey.pfx
----------------------------------------------------------------------
diff --git a/spec/projects/windows8/CordovaApp_TemporaryKey.pfx b/spec/projects/windows8/CordovaApp_TemporaryKey.pfx
new file mode 100644
index 0000000..4df1e37
Binary files /dev/null and b/spec/projects/windows8/CordovaApp_TemporaryKey.pfx differ
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c8c4bc1e/spec/projects/windows8/TestApp.jsproj
----------------------------------------------------------------------
diff --git a/spec/projects/windows8/TestApp.jsproj b/spec/projects/windows8/TestApp.jsproj
new file mode 100644
index 0000000..d508c3f
--- /dev/null
+++ b/spec/projects/windows8/TestApp.jsproj
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|AnyCPU">
+ <Configuration>Debug</Configuration>
+ <Platform>AnyCPU</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x86">
+ <Configuration>Debug</Configuration>
+ <Platform>x86</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|AnyCPU">
+ <Configuration>Release</Configuration>
+ <Platform>AnyCPU</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x86">
+ <Configuration>Release</Configuration>
+ <Platform>x86</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>efffab2f-bfc5-4eda-b545-45ef4995f55a</ProjectGuid>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '11.0'">
+ <VisualStudioVersion>11.0</VisualStudioVersion>
+ </PropertyGroup>
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).Default.props" />
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).props" />
+ <PropertyGroup>
+ <TargetPlatformIdentifier>Windows</TargetPlatformIdentifier>
+ <TargetPlatformVersion>8.0</TargetPlatformVersion>
+ <DefaultLanguage>en-US</DefaultLanguage>
+ <PackageCertificateKeyFile>CordovaApp_TemporaryKey.pfx</PackageCertificateKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <AppxManifest Include="package.appxmanifest">
+ <SubType>Designer</SubType>
+ </AppxManifest>
+ <Content Include="www\cordova-2.6.0.js" />
+ <Content Include="www\css\index.css" />
+ <Content Include="www\img\logo.png" />
+ <Content Include="www\img\smalllogo.png" />
+ <Content Include="www\img\splashscreen.png" />
+ <Content Include="www\img\storelogo.png" />
+ <Content Include="www\index.html" />
+ <Content Include="www\js\index.js" />
+ <None Include="CordovaApp_TemporaryKey.pfx" />
+ </ItemGroup>
+ <ItemGroup>
+ <SDKReference Include="Microsoft.WinJS.1.0, Version=1.0" />
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).targets" />
+ <!-- To modify your build process, add your task inside one of the targets below then uncomment
+ that target and the DisableFastUpToDateCheck PropertyGroup.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ <PropertyGroup>
+ <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
+ </PropertyGroup>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c8c4bc1e/spec/projects/windows8/TestApp.sln
----------------------------------------------------------------------
diff --git a/spec/projects/windows8/TestApp.sln b/spec/projects/windows8/TestApp.sln
new file mode 100644
index 0000000..6c1ea33
--- /dev/null
+++ b/spec/projects/windows8/TestApp.sln
@@ -0,0 +1,46 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "TestApp", "TestApp.jsproj", "{EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|ARM = Debug|ARM
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|ARM = Release|ARM
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Debug|ARM.ActiveCfg = Debug|ARM
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Debug|ARM.Build.0 = Debug|ARM
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Debug|ARM.Deploy.0 = Debug|ARM
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Debug|x64.ActiveCfg = Debug|x64
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Debug|x64.Build.0 = Debug|x64
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Debug|x64.Deploy.0 = Debug|x64
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Debug|x86.ActiveCfg = Debug|x86
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Debug|x86.Build.0 = Debug|x86
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Debug|x86.Deploy.0 = Debug|x86
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Release|Any CPU.Deploy.0 = Release|Any CPU
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Release|ARM.ActiveCfg = Release|ARM
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Release|ARM.Build.0 = Release|ARM
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Release|ARM.Deploy.0 = Release|ARM
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Release|x64.ActiveCfg = Release|x64
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Release|x64.Build.0 = Release|x64
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Release|x64.Deploy.0 = Release|x64
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Release|x86.ActiveCfg = Release|x86
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Release|x86.Build.0 = Release|x86
+ {EFFFAB2F-BFC5-4EDA-B545-45EF4995F55A}.Release|x86.Deploy.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c8c4bc1e/spec/projects/windows8/package.appxmanifest
----------------------------------------------------------------------
diff --git a/spec/projects/windows8/package.appxmanifest b/spec/projects/windows8/package.appxmanifest
new file mode 100644
index 0000000..62c8f28
--- /dev/null
+++ b/spec/projects/windows8/package.appxmanifest
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
+ <Identity Name="efffab2f-bfc5-4eda-b545-45ef4995f55a" Version="1.0.0.0" Publisher="CN=Jesse" />
+ <Properties>
+ <DisplayName>CordovaApp</DisplayName>
+ <PublisherDisplayName>Jesse</PublisherDisplayName>
+ <Logo>images\storelogo.png</Logo>
+ </Properties>
+ <Prerequisites>
+ <OSMinVersion>6.2.1</OSMinVersion>
+ <OSMaxVersionTested>6.2.1</OSMaxVersionTested>
+ </Prerequisites>
+ <Resources>
+ <Resource Language="x-generate" />
+ </Resources>
+ <Applications>
+ <Application Id="App" StartPage="www/index.html">
+ <VisualElements DisplayName="CordovaApp" Logo="www\img\logo.png" SmallLogo="www\img\smalllogo.png" Description="CordovaApp" ForegroundText="light" BackgroundColor="#464646">
+ <DefaultTile ShowName="allLogos" />
+ <SplashScreen Image="www\img\splashscreen.png" />
+ </VisualElements>
+ </Application>
+ </Applications>
+ <Capabilities>
+ <Capability Name="internetClient" />
+ </Capabilities>
+</Package>
\ No newline at end of file