royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject [royale-asjs] branch develop updated: KeyboardEventConverterTest
Date Sun, 12 Nov 2017 09:40:50 GMT
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 aa1d6c6  KeyboardEventConverterTest
aa1d6c6 is described below

commit aa1d6c653904a30e4ee7e4d41909b77ce4c89388
Author: Harbs <harbs@in-tools.com>
AuthorDate: Sun Nov 12 11:40:45 2017 +0200

    KeyboardEventConverterTest
---
 .../royale/events/utils/KeyboardEventConverter.as  |  2 +-
 .../src/test/royale/flexUnitTests/CoreTester.as    |  1 +
 .../flexUnitTests/KeyboardEventConverterTest.as    | 79 ++++++++++++++++++++++
 3 files changed, 81 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/events/utils/KeyboardEventConverter.as
b/frameworks/projects/Core/src/main/royale/org/apache/royale/events/utils/KeyboardEventConverter.as
index 9acc05f..9e7b0a5 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/events/utils/KeyboardEventConverter.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/events/utils/KeyboardEventConverter.as
@@ -76,7 +76,7 @@ package org.apache.royale.events.utils
 			if(key == null)
 				key = nativeEvent["keyIdentifier"];
 			
-			if (key == null)
+			if (!key)
 				key = KeyConverter.convertCharCode(nativeEvent['charCode']);
 			
 			var code:String = nativeEvent["code"];
diff --git a/frameworks/projects/Core/src/test/royale/flexUnitTests/CoreTester.as b/frameworks/projects/Core/src/test/royale/flexUnitTests/CoreTester.as
index a943723..2803ede 100644
--- a/frameworks/projects/Core/src/test/royale/flexUnitTests/CoreTester.as
+++ b/frameworks/projects/Core/src/test/royale/flexUnitTests/CoreTester.as
@@ -26,5 +26,6 @@ package flexUnitTests
 		public var binaryDataTesterTest:BinaryDataTesterTest;
 		public var dateUtilsTest:DateUtilsTest;
         public var keyConverterTest:KeyConverterTest;
+        public var keyboardEventConverterTest:KeyboardEventConverterTest;
     }
 }
diff --git a/frameworks/projects/Core/src/test/royale/flexUnitTests/KeyboardEventConverterTest.as
b/frameworks/projects/Core/src/test/royale/flexUnitTests/KeyboardEventConverterTest.as
new file mode 100644
index 0000000..5ba8d4e
--- /dev/null
+++ b/frameworks/projects/Core/src/test/royale/flexUnitTests/KeyboardEventConverterTest.as
@@ -0,0 +1,79 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.events.KeyboardEvent;
+
+    COMPILE::SWF
+    {
+        import flash.events.KeyboardEvent;
+    }
+
+    import org.apache.royale.events.utils.KeyboardEventConverter;
+    import org.apache.royale.test.asserts.*;
+    
+    public class KeyboardEventConverterTest
+    {		
+        [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 testConvert():void
+        {
+            COMPILE::SWF{
+                var oEv:flash.events.KeyboardEvent = new flash.events.KeyboardEvent("keyUp");
+                oEv.keyCode = 66;
+                oEv.charCode = 66;
+                var nEv:org.apache.royale.events.KeyboardEvent = KeyboardEventConverter.convert(oEv);
+                assertEquals("keyUp", nEv.type);
+                oEv = new flash.events.KeyboardEvent("keyDown");
+                oEv.keyCode = 66;
+                oEv.charCode = 66;
+                var nEv:org.apache.royale.events.KeyboardEvent = KeyboardEventConverter.convert(oEv);
+                assertEquals("keyDown", nEv.type);
+            }
+            COMPILE::JS{
+                var oEv:Object = {"type":"keyUp","keyCode":66,"charCode":66};
+                var nEv:org.apache.royale.events.KeyboardEvent = KeyboardEventConverter.convert(oEv);
+                assertEquals("keyUp", nEv.type);
+                oEv = {"type":"keyDown","keyCode":66,"charCode":66};
+                var nEv:org.apache.royale.events.KeyboardEvent = KeyboardEventConverter.convert(oEv);
+                assertEquals("keyDown", nEv.type);
+            }
+        }
+
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
['"commits@royale.apache.org" <commits@royale.apache.org>'].

Mime
View raw message