You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2020/10/13 04:14:55 UTC
[royale-asjs] 01/02: Fix for renderers no longer automatically
updating after test result is determined. Refactor Results display into
separate component.
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 027c1e9294a2773565dfe54072b5bf9050faf92a
Author: greg-dove <gr...@gmail.com>
AuthorDate: Tue Oct 13 17:12:10 2020 +1300
Fix for renderers no longer automatically updating after test result is determined.
Refactor Results display into separate component.
---
.../royale/html/test/TestResultsDisplay.mxml | 109 +++++++++++++++++++++
.../apache/royale/html/test/UITestItemRenderer.as | 14 +++
.../org/apache/royale/html/test/UITestRunner.mxml | 66 ++-----------
.../org/apache/royale/html/test/models/UITestVO.as | 17 +++-
4 files changed, 147 insertions(+), 59 deletions(-)
diff --git a/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/TestResultsDisplay.mxml b/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/TestResultsDisplay.mxml
new file mode 100644
index 0000000..38bd042
--- /dev/null
+++ b/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/TestResultsDisplay.mxml
@@ -0,0 +1,109 @@
+<?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:Panel xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:js="library://ns.apache.org/royale/basic"
+ xmlns:models="org.apache.royale.html.test.models.*">
+ <js:beads>
+ <js:ContainerDataBinding/>
+ </js:beads>
+ <fx:Style>
+ .result-stack {
+ font-size: 12px;
+ font-family: monospace;
+ }
+ </fx:Style>
+
+
+ <fx:Script>
+ <![CDATA[
+ import org.apache.royale.collections.ArrayListView;
+ import org.apache.royale.events.Event;
+ import org.apache.royale.test.runners.notification.Failure;
+ import org.apache.royale.test.runners.notification.Result;
+ import org.apache.royale.html.test.models.UITestVO;
+ import org.apache.royale.test.AssertionError;
+
+ [Bindable]
+ public var displayResult:UITestVO;
+
+ private function getResultType(item:UITestVO):String
+ {
+ if(item.active)
+ {
+ return "Active";
+ }
+ if(item.ignored)
+ {
+ return "Ignored";
+ }
+ if(item.failure)
+ {
+ if(item.failure.exception is AssertionError)
+ {
+ return "Assertion Failed";
+ }
+ return "Exception";
+ }
+ return "Passed";
+ }
+
+ private function getFailureDetails(item:UITestVO):String
+ {
+ if(item.failure)
+ {
+ return item.failure.stackTrace;
+ }
+ return "";
+ }
+
+
+ ]]>
+ </fx:Script>
+
+ <js:VGroup percentWidth="100" percentHeight="100" visible="{!displayResult}">
+ <js:Label text="No test selected" />
+ </js:VGroup>
+ <js:VGroup percentWidth="100" percentHeight="100" visible="{displayResult}">
+
+ <js:Label text="Function:"/>
+ <js:Label text="{displayResult.functionName}"/>
+
+ <js:Spacer height="10"/>
+
+ <js:Label text="Test Case:"/>
+ <js:Label text="{displayResult.testCaseName}"/>
+
+ <js:Spacer height="10"/>
+
+ <js:Label text="Result:"/>
+ <js:Label text="{getResultType(displayResult)}"/>
+
+ <js:Spacer height="10"/>
+
+ <js:VGroup visible="{displayResult.failure}">
+ <js:Label text="Stack Trace:"/>
+ <js:MultilineLabel text="{getFailureDetails(displayResult)}"
+ className="result-stack"
+ percentWidth="100" style="white-space:pre;overflow-x:auto"/>
+ </js:VGroup>
+ </js:VGroup>
+
+</js:Panel>
\ No newline at end of file
diff --git a/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/UITestItemRenderer.as b/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/UITestItemRenderer.as
index 1c7f733..d1c86c2 100644
--- a/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/UITestItemRenderer.as
+++ b/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/UITestItemRenderer.as
@@ -24,6 +24,8 @@ package org.apache.royale.html.test
import org.apache.royale.html.beads.layouts.HorizontalLayoutWithPaddingAndGap;
import org.apache.royale.html.supportClasses.DataItemRenderer;
import org.apache.royale.html.test.models.UITestVO;
+ import org.apache.royale.events.Event;
+
[ExcludeClass]
/**
@@ -65,8 +67,13 @@ package org.apache.royale.html.test
container.addElement(label);
}
+ private var _awaitingResult:Boolean;
override public function set data(value:Object):void
{
+ if (_awaitingResult) {
+ UITestVO(data).removeEventListener('ready', onResult);
+ _awaitingResult = false;
+ }
super.data = value;
var item:UITestVO = UITestVO(value);
@@ -81,6 +88,8 @@ package org.apache.royale.html.test
else if(item.active)
{
icon.text = "🟡"
+ _awaitingResult = true;
+ item.addEventListener('ready', onResult);
}
else
{
@@ -88,5 +97,10 @@ package org.apache.royale.html.test
}
label.text = item.description;
}
+
+ private function onResult(event:Event):void{
+ var item:UITestVO = UITestVO(event.target);
+ this.data = item;
+ }
}
}
diff --git a/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/UITestRunner.mxml b/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/UITestRunner.mxml
index 7969358..f16f2be 100644
--- a/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/UITestRunner.mxml
+++ b/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/UITestRunner.mxml
@@ -21,6 +21,7 @@
<js:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:js="library://ns.apache.org/royale/basic"
xmlns:models="org.apache.royale.html.test.models.*"
+ xmlns:testview="org.apache.royale.html.test.*"
implements="org.apache.royale.test.runners.notification.IRunListener"
percentWidth="100" percentHeight="100"
initComplete="resultTypesList.selectedIndex = 0;">
@@ -58,41 +59,10 @@
</js:DynamicList>
</js:Panel>
- <js:Panel title="Test Details" percentWidth="100" percentHeight="50"
- visible="{!testsModel.selectedResult}">
- <js:beads>
- <js:VerticalLayout/>
- </js:beads>
- <js:Label text="No test selected"/>
- </js:Panel>
-
- <js:Panel title="Test Details" percentWidth="100" percentHeight="50"
- visible="{testsModel.selectedResult}">
- <js:beads>
- <js:VerticalLayout/>
- </js:beads>
-
- <js:Label text="Function:"/>
- <js:Label text="{testsModel.selectedResult.functionName}"/>
-
- <js:Spacer height="10"/>
-
- <js:Label text="Test Case:"/>
- <js:Label text="{testsModel.selectedResult.testCaseName}"/>
-
- <js:Spacer height="10"/>
-
- <js:Label text="Result:"/>
- <js:Label text="{getResultType(testsModel.selectedResult)}"/>
-
- <js:Spacer height="10"/>
-
- <js:VGroup visible="{testsModel.selectedResult.failure}">
- <js:Label text="Stack Trace:"/>
- <js:MultilineLabel text="{testsModel.selectedResult.failure.stackTrace}"
- percentWidth="100" style="white-space:pre;overflow-x:scroll"/>
- </js:VGroup>
- </js:Panel>
+ <testview:TestResultsDisplay title="Test Details"
+ percentWidth="100" percentHeight="50"
+ displayResult="{testsModel.selectedResult}"
+ />
<fx:Script>
<![CDATA[
@@ -111,7 +81,9 @@
public function testStarted(description:String):void
{
var testResults:ArrayListView = testsModel.results;
- testResults.addItem(new UITestVO(description));
+ var item:UITestVO = new UITestVO(description);
+ item.active = true;
+ testResults.addItem(item);
}
public function testFinished(description:String):void
@@ -127,7 +99,6 @@
var testResults:ArrayListView = testsModel.results;
var item:UITestVO = testResults.getItemAt(testResults.length - 1) as UITestVO;
item.failure = failure;
- testResults.itemUpdated(item);
}
public function testIgnored(description:String):void
@@ -143,27 +114,6 @@
{
}
- private function getResultType(item:UITestVO):String
- {
- if(item.active)
- {
- return "Active";
- }
- if(item.ignored)
- {
- return "Ignored";
- }
- if(item.failure)
- {
- if(item.failure.exception is AssertionError)
- {
- return "Assertion Failed";
- }
- return "Exception";
- }
- return "Passed";
- }
-
private function resultsList_changeHandler(event:Event):void
{
testsModel.selectedResultIndex = resultsList.selectedIndex;
diff --git a/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/models/UITestVO.as b/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/models/UITestVO.as
index 362262b..93453aa 100644
--- a/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/models/UITestVO.as
+++ b/frameworks/projects/RoyaleUnitUI/src/main/royale/org/apache/royale/html/test/models/UITestVO.as
@@ -19,9 +19,11 @@
package org.apache.royale.html.test.models
{
import org.apache.royale.test.runners.notification.Failure;
+ import org.apache.royale.events.Event;
[ExcludeClass]
[Bindable]
+ [Event(name='ready')]
/**
* @private
*/
@@ -41,8 +43,21 @@ package org.apache.royale.html.test.models
public var functionName:String;
public var testCaseName:String;
- public var active:Boolean = true;
public var ignored:Boolean = false;
public var failure:Failure;
+
+
+ private var _active:Boolean = false;
+ public function get active():Boolean {
+ return _active;
+ }
+
+ public function set active(value:Boolean):void {
+ var finalized:Boolean = _active && !value;
+ _active = value;
+ if (finalized) {
+ this.dispatchEvent(new Event('ready'));
+ }
+ }
}
}
\ No newline at end of file