You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2021/12/20 14:16:45 UTC

[royale-asjs] branch develop updated: Add ExternsJS to general ant build

This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new dc4e099  Add ExternsJS to general ant build
dc4e099 is described below

commit dc4e0999de6fe9e1949372c537c2294365cf4874
Author: Harbs <ha...@in-tools.com>
AuthorDate: Mon Dec 20 16:16:36 2021 +0200

    Add ExternsJS to general ant build
---
 frameworks/build.xml                               |  11 ++
 .../royale/FlexUnitRoyaleApplication-config.xml    | 109 +++++++++++++++++++
 .../src/test/royale/FlexUnitRoyaleApplication.mxml | 114 ++++++++++++++++++++
 .../projects/ExternsJS/src/test/royale/build.xml   | 116 +++++++++++++++++++++
 .../test/royale/flexUnitTests/ExternsJSTester.as   |  33 ++++++
 .../test/royale/flexUnitTests/StringUtilsTest.as   |  57 ++++++++++
 6 files changed, 440 insertions(+)

diff --git a/frameworks/build.xml b/frameworks/build.xml
index e1852e3..2d627f2 100644
--- a/frameworks/build.xml
+++ b/frameworks/build.xml
@@ -156,6 +156,7 @@
         <antcall target="Jewel"/>
         <antcall target="JewelTheme"/>
 		<antcall target="Icons"/>
+		<antcall target="ExternsJS"/>
     </target>
 
     <target name="test" description="Tests all SWCs">
@@ -197,6 +198,7 @@
         <antcall target="CruxTest"/>
         <antcall target="JewelTest"/>
         <antcall target="IconsTest"/>
+        <antcall target="ExternsJSTest"/>
     </target>
 
     <target name="fonts">
@@ -258,6 +260,7 @@
         <ant dir="${basedir}/projects/Crux" target="clean"/>
         <ant dir="${basedir}/projects/Jewel" target="clean"/>
 		<ant dir="${basedir}/projects/Icons" target="clean"/>
+		<ant dir="${basedir}/projects/ExternsJS" target="clean"/>
         <ant dir="${basedir}/themes/JewelTheme" target="clean"/>
         <ant dir="${basedir}/fontsrc" target="clean"/>
 
@@ -562,10 +565,18 @@
         <ant dir="${basedir}/projects/Icons"/>
     </target>
 
+    <target name="ExternsJS" description="Clean build of ExternsJS.swc">
+        <ant dir="${basedir}/projects/ExternsJS"/>
+    </target>
+
     <target name="IconsTest" description="Test of Icons.swc">
         <ant dir="${basedir}/projects/Icons" target="test"/>
     </target>
 
+    <target name="ExternsJSTest" description="Test of ExternsJS.swc">
+        <ant dir="${basedir}/projects/ExternsJS" target="test"/>
+    </target>
+
     <target name="Jewel" description="Clean build of Jewel.swc">
         <ant dir="${basedir}/projects/Jewel"/>
     </target>
diff --git a/frameworks/projects/ExternsJS/src/test/royale/FlexUnitRoyaleApplication-config.xml b/frameworks/projects/ExternsJS/src/test/royale/FlexUnitRoyaleApplication-config.xml
new file mode 100644
index 0000000..075ee3f
--- /dev/null
+++ b/frameworks/projects/ExternsJS/src/test/royale/FlexUnitRoyaleApplication-config.xml
@@ -0,0 +1,109 @@
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+
+-->
+<royale-config>
+
+    <compiler>
+        <accessible>false</accessible>
+        
+        <targets>
+            <target>SWF</target>
+        </targets>
+        <strict-xml>true</strict-xml>
+
+        <external-library-path>
+            <path-element>{playerglobalHome}/{targetPlayerMajorVersion}.{targetPlayerMinorVersion}/playerglobal.swc</path-element>
+        </external-library-path>
+        
+        <js-external-library-path>
+            <path-element>../../../../../../js/libs/js.swc</path-element>
+            <path-element>../../../../../../js/libs/gcl.swc</path-element>
+        </js-external-library-path>
+        
+        <library-path>
+            <path-element>../../../../../libs/Basic.swc</path-element>
+            <path-element>../../../../../libs/Binding.swc</path-element>
+            <path-element>../../../../../libs/Core.swc</path-element>
+            <path-element>../../../../../libs/Graphics.swc</path-element>
+            <path-element>../../../../../libs/Collections.swc</path-element>
+            <path-element>../../../../../libs/Language.swc</path-element>
+            <path-element>../../../../../libs/ExternsJS.swc</path-element>
+            <path-element>../../../../../libs/RoyaleUnit.swc</path-element>
+        </library-path>
+        
+        <js-library-path>
+            <path-element>../../../../../js/libs/BasicJS.swc</path-element>
+            <path-element>../../../../../js/libs/BindingJS.swc</path-element>
+            <path-element>../../../../../js/libs/CoreJS.swc</path-element>
+            <path-element>../../../../../js/libs/GraphicsJS.swc</path-element>
+            <path-element>../../../../../js/libs/CollectionsJS.swc</path-element>
+            <path-element>../../../../../js/libs/LanguageJS.swc</path-element>
+            <path-element>../../../../../js/libs/ExternsJSJS.swc</path-element>
+            <path-element>../../../../../js/libs/RoyaleUnitJS.swc</path-element>
+        </js-library-path>
+
+        <allow-subclass-overrides>true</allow-subclass-overrides>
+
+        <mxml>
+            <children-as-data>true</children-as-data>
+        </mxml>
+        <binding-value-change-event>org.apache.royale.events.ValueChangeEvent</binding-value-change-event>
+        <binding-value-change-event-kind>org.apache.royale.events.ValueChangeEvent</binding-value-change-event-kind>
+        <binding-value-change-event-type>valueChange</binding-value-change-event-type>
+        <fxg-base-class>flash.display.Sprite</fxg-base-class>
+
+        <keep-as3-metadata>
+          <name>Bindable</name>
+          <name>Managed</name>
+          <name>ChangeEvent</name>
+          <name>NonCommittingChangeEvent</name>
+          <name>Transient</name>
+          <name>SWFOverride</name>
+
+          <!-- RoyaleUnit -->
+          <name>Test</name>
+          <name>Before</name>
+          <name>After</name>
+          <name>BeforeClass</name>
+          <name>AfterClass</name>
+          <name>Ignore</name>
+          <name>Suite</name>
+          <name>RunWith</name>
+        </keep-as3-metadata>
+    
+        <locale/>
+        
+        <library-path/>
+
+        <namespaces>
+            <namespace>
+                <uri>http://ns.adobe.com/mxml/2009</uri>
+                <manifest>../../../../../mxml-2009-manifest.xml</manifest>
+            </namespace>
+            <namespace>
+                <uri>library://ns.apache.org/royale/basic</uri>
+                <manifest>../../main/resources/basic-manifest.xml</manifest>
+            </namespace>
+        </namespaces>
+        
+        <warn-no-constructor>false</warn-no-constructor>
+    </compiler>
+    
+    <target-player>${playerglobal.version}</target-player>
+
+</royale-config>
diff --git a/frameworks/projects/ExternsJS/src/test/royale/FlexUnitRoyaleApplication.mxml b/frameworks/projects/ExternsJS/src/test/royale/FlexUnitRoyaleApplication.mxml
new file mode 100644
index 0000000..b902823
--- /dev/null
+++ b/frameworks/projects/ExternsJS/src/test/royale/FlexUnitRoyaleApplication.mxml
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+
+-->
+
+<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+                   xmlns:js="library://ns.apache.org/royale/basic" 
+                   xmlns:test="org.apache.royale.test.*" 
+                   applicationComplete="runTests()"
+                   >
+    <fx:Declarations>
+        <test:RoyaleUnitCore id="core"/>
+    </fx:Declarations>
+    <fx:Script>
+        <![CDATA[
+            COMPILE::SWF
+            {
+                import flash.system.fscommand;
+            }
+
+            import flexUnitTests.ExternsJSTester;
+            
+            import org.apache.royale.events.Event;
+            import org.apache.royale.test.listeners.CIListener;
+            import org.apache.royale.test.listeners.BrowserConsoleListener;
+            import org.apache.royale.test.Runtime;
+
+
+            private static var _instance:FlexUnitRoyaleApplication;
+            public static function getInstance():FlexUnitRoyaleApplication{
+                return _instance;
+            }
+
+            public function get eventsTestParent():Group{
+                return eventBubblingParent;
+            }
+
+            //account for swf version variance in some test results due to fixed player bugs etc
+            public function getSwfVersion():uint{
+                COMPILE::SWF{
+                    return this.stage.loaderInfo.bytes[3];
+
+                }
+                return 0;
+            }
+
+            public function runLocal():Boolean{
+                var ret:Boolean = false;
+                COMPILE::JS{
+                    ret = window.location.search.indexOf('local')!= -1;
+                    if (!ret) {
+                        console.log('For javascript you can run this locally with console output for debugging purposes, using "?local" appended to the url.\nIt may not work for all browsers with file:// protocol (works with Chrome), in which case you need a local http server')
+                    }
+                }
+                return ret
+            }
+
+            public function getPlayerVersion():String{
+                COMPILE::SWF{
+                    import flash.system.Capabilities;
+                    return Capabilities.version;
+                }
+                return '';
+            }
+
+            public function runTests():void
+            {
+                Runtime.swfVersion = getSwfVersion();
+                _instance = this;
+                if (runLocal()) {
+                    core.addListener(new BrowserConsoleListener());
+                } else{
+                    core.addListener(new CIListener());
+                }
+                core.addEventListener(Event.COMPLETE, core_completeHandler);
+                core.runClasses(ExternsJSTester);
+            }
+
+            private function core_completeHandler(event:Event):void
+            {
+                COMPILE::SWF
+                {
+                    fscommand("quit");
+                }
+            }
+            
+        ]]>
+    </fx:Script>
+    <js:valuesImpl>
+        <!-- for such a simple app, we just set values to an empty array so it thinks it doesn't have any values -->
+        <js:SimpleValuesImpl values="[]"/>
+    </js:valuesImpl>
+    <js:initialView>
+        <js:View>
+            <js:Group id="eventBubblingParent" />
+        </js:View>
+    </js:initialView>
+
+</js:Application>
diff --git a/frameworks/projects/ExternsJS/src/test/royale/build.xml b/frameworks/projects/ExternsJS/src/test/royale/build.xml
new file mode 100644
index 0000000..d128b87
--- /dev/null
+++ b/frameworks/projects/ExternsJS/src/test/royale/build.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+
+-->
+
+
+<project name="ExternsJS.test" default="main" basedir=".">
+    <property name="ROYALE_HOME" location="../../../../../.."/>
+    
+    <property file="${ROYALE_HOME}/env.properties"/>
+    <property environment="env"/>
+    <property file="${ROYALE_HOME}/local.properties"/>
+    <property file="${ROYALE_HOME}/build.properties"/>
+    <property name="ROYALE_HOME" value="${env.ROYALE_HOME}"/>
+    <property name="ROYALE_SWF_COMPILER_HOME" value="${env.ROYALE_SWF_COMPILER_HOME}"/>
+    <property name="target.name" value="Core-${release.version}.swc" />
+
+    <property name="report.dir" value="${basedir}/out" />
+
+    <target name="main" depends="clean,compile,test" description="Clean test of ${target.name}">
+    </target>
+    
+    <target name="clean">
+        <delete failonerror="false">
+            <fileset dir="${basedir}">
+                <include name="FlexUnitRoyaleApplication.swf"/>
+            </fileset>
+        </delete>
+        <delete failonerror="false" includeemptydirs="true">
+            <fileset dir="${report.dir}">
+                <include name="**/**"/>
+            </fileset>
+        </delete>
+    </target>
+    
+    <path id="lib.path">
+      <fileset dir="${ROYALE_COMPILER_HOME}/lib" includes="compiler-royaleTasks.jar"/>
+      <fileset dir="${ROYALE_COMPILER_HOME}/lib" includes="royaleUnitTasks.jar"/>
+    </path>
+
+    <target name="compile" description="Compiles FlexUnitRoyaleApplication.swf">
+        <echo message="Compiling FlexUnitRoyaleApplication.swf"/>
+        <echo message="ROYALE_HOME: ${ROYALE_HOME}"/>
+        <echo message="ROYALE_SWF_COMPILER_HOME: ${ROYALE_SWF_COMPILER_HOME}"/>
+        <echo message="playerglobal.version: ${playerglobal.version}"/>
+
+        <!-- Load the <compc> task. We can't do this at the <project> level -->
+        <!-- because targets that run before flexTasks.jar gets built would fail. -->
+        <taskdef resource="flexTasks.tasks" classpathref="lib.path"/>
+        <!--
+            Link in the classes (and their dependencies) for the MXML tags
+            listed in this project's manifest.xml.
+            Also link the additional classes (and their dependencies)
+            listed in RoyaleUIClasses.as,
+            because these aren't referenced by the manifest classes.
+            Keep the standard metadata when compiling.
+            Include the appropriate CSS files and assets in the SWC.
+            Don't include any resources in the SWC.
+            Write a bundle list of referenced resource bundles
+            into the file bundles.properties in this directory.
+        -->
+        <mxmlc fork="true"
+            file="${basedir}/FlexUnitRoyaleApplication.mxml"
+            output="${basedir}/FlexUnitRoyaleApplication.swf">
+            <jvmarg line="${mxmlc.jvm.args}"/>
+            <!--
+            <jvmarg value="-Xdebug" />
+            <jvmarg value="-Xnoagent" />
+            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=8763,server=y,suspend=y" />
+             -->
+            <arg value="-debug" />
+            <arg value="-compiler.targets=SWF" />
+            <arg value="+playerglobal.version=${playerglobal.version}" />
+            <arg value="+env.PLAYERGLOBAL_HOME=${PLAYERGLOBAL_HOME}" />
+        </mxmlc>
+    </target>
+
+    <target name="test">
+        <!-- Load the <royaleunit> task. We can't do this at the <project> level -->
+        <!-- because targets that run before royaleUnitTasks.jar gets built would fail. -->
+        <taskdef resource="royaleUnitTasks.tasks" classpathref="lib.path"/>
+		<mkdir dir="${report.dir}" />
+		<royaleunit
+            swf="${basedir}/FlexUnitRoyaleApplication.swf"
+		    workingDir="${basedir}"
+		    toDir="${report.dir}"
+			haltonfailure="true"
+			verbose="true"
+			localTrusted="true"
+			timeout="90000" />
+        
+		<!-- Generate readable JUnit-style reports -->
+		<junitreport todir="${report.dir}">
+			<fileset dir="${report.dir}">
+				<include name="TEST-*.xml" />
+			</fileset>
+			<report format="frames" todir="${report.dir}/html" />
+		</junitreport>
+        
+    </target>
+</project>
diff --git a/frameworks/projects/ExternsJS/src/test/royale/flexUnitTests/ExternsJSTester.as b/frameworks/projects/ExternsJS/src/test/royale/flexUnitTests/ExternsJSTester.as
new file mode 100644
index 0000000..8ab258e
--- /dev/null
+++ b/frameworks/projects/ExternsJS/src/test/royale/flexUnitTests/ExternsJSTester.as
@@ -0,0 +1,33 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests
+{
+    import flexUnitTests.language.*
+    
+    [Suite]
+    [RunWith("org.apache.royale.test.runners.SuiteRunner")]
+    public class ExternsJSTester
+    {
+        // add tests here...        
+        
+        //tests
+        public var componentTest:ComponentTest;
+
+    }
+}
diff --git a/frameworks/projects/ExternsJS/src/test/royale/flexUnitTests/StringUtilsTest.as b/frameworks/projects/ExternsJS/src/test/royale/flexUnitTests/StringUtilsTest.as
new file mode 100644
index 0000000..1a24a8f
--- /dev/null
+++ b/frameworks/projects/ExternsJS/src/test/royale/flexUnitTests/StringUtilsTest.as
@@ -0,0 +1,57 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests
+{
+    import org.apache.royale.utils.string.*;
+    import org.apache.royale.test.asserts.*;
+    import org.apache.royale.test.asserts.assertEquals;
+    
+    public class ComponentTest
+    {		
+        [Before]
+        public function setUp():void
+        {
+        }
+        
+        [After]
+        public function tearDown():void
+        {
+        }
+        
+        [BeforeClass]
+        public static function setUpBeforeClass():void
+        {
+        }
+        
+        [AfterClass]
+        public static function tearDownAfterClass():void
+        {
+        }
+        
+
+        [Test]
+        public function testSomething():void
+        {
+            assertTrue("something" == "somthing","Should be something");
+            assertEquals("something","somthing","Should be something");
+        }
+
+
+    }
+}