flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bigosma...@apache.org
Subject [19/48] git commit: [flex-sdk] [refs/heads/iso7skins] - FLEX-34543 Added a unit test which reproduces the bug and thus prevents it from recurring.
Date Sat, 22 Nov 2014 01:01:02 GMT
FLEX-34543 Added a unit test which reproduces the bug and thus prevents it from recurring.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/332ec430
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/332ec430
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/332ec430

Branch: refs/heads/iso7skins
Commit: 332ec4305cc649724b7d48bcd438ab579780500f
Parents: f47b67f
Author: Mihai Chira <mihaic@apache.org>
Authored: Thu Oct 23 17:20:13 2014 +0100
Committer: Mihai Chira <mihaic@apache.org>
Committed: Thu Oct 23 17:21:27 2014 +0100

----------------------------------------------------------------------
 .../DataGridEditor_FLEX_34543_Test.as           | 85 ++++++++++++++++++++
 1 file changed, 85 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/332ec430/frameworks/tests/unitTests/spark/components/gridClasses/DataGridEditor_FLEX_34543_Test.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/spark/components/gridClasses/DataGridEditor_FLEX_34543_Test.as
b/frameworks/tests/unitTests/spark/components/gridClasses/DataGridEditor_FLEX_34543_Test.as
new file mode 100644
index 0000000..6572d40
--- /dev/null
+++ b/frameworks/tests/unitTests/spark/components/gridClasses/DataGridEditor_FLEX_34543_Test.as
@@ -0,0 +1,85 @@
+package spark.components.gridClasses {
+    import mx.collections.ArrayCollection;
+    import mx.collections.ArrayList;
+    import mx.core.ClassFactory;
+    import mx.core.mx_internal;
+    import mx.managers.FocusManager;
+
+    import org.flexunit.asserts.assertEquals;
+    import org.flexunit.asserts.assertNotNull;
+    import org.fluint.uiImpersonation.UIImpersonator;
+
+    import spark.components.DataGrid;
+    import spark.events.GridItemEditorEvent;
+
+    public class DataGridEditor_FLEX_34543_Test
+    {
+        private var _dp:ArrayCollection;
+        private var _dg:DataGrid;
+        private var _sut:DataGridEditor;
+        private var _saveEvent:GridItemEditorEvent;
+
+        [Before]
+        public function setUp():void
+        {
+            _dp = new ArrayCollection([new FLEX_34543_DataNode("First"), new FLEX_34543_DataNode("Second")]);
+
+            _dg = new DataGrid();
+            _dg.editable = true;
+            _dg.dataProvider = _dp;
+
+            var nameColumn:GridColumn = new GridColumn();
+            nameColumn.dataField = "name";
+            nameColumn.itemEditor = new ClassFactory(DefaultGridItemEditor);
+            nameColumn.editable = true;
+            _dg.columns = new ArrayList([nameColumn]);
+
+            UIImpersonator.addChild(_dg);
+            _dg.focusManager = new FocusManager(_dg, false);
+
+            _sut = _dg.mx_internal::editor;
+        }
+
+        [After]
+        public function tearDown():void
+        {
+            _dg.removeEventListener(GridItemEditorEvent.GRID_ITEM_EDITOR_SESSION_SAVE, onGridEditorSave);
+            UIImpersonator.removeAllChildren();
+            _dg = null;
+            _dp = null;
+            _saveEvent = null;
+            _sut = null;
+        }
+
+        [Test]
+        public function testEndItemEditorSessionEventContainsCorrectIndex():void
+        {
+            //given
+            _dg.addEventListener(GridItemEditorEvent.GRID_ITEM_EDITOR_SESSION_SAVE, onGridEditorSave);
+            _dg.startItemEditorSession(1,0);
+
+            //when
+            _dp.removeItemAt(0);
+            _dg.endItemEditorSession();
+
+            //then
+            assertNotNull(_saveEvent);
+            assertEquals(0, _saveEvent.rowIndex);
+        }
+
+        private function onGridEditorSave(event:GridItemEditorEvent):void
+        {
+            _saveEvent = event;
+        }
+    }
+}
+
+class FLEX_34543_DataNode
+{
+    public var name:String;
+
+    public function FLEX_34543_DataNode(name:String)
+    {
+        this.name = name;
+    }
+}
\ No newline at end of file


Mime
View raw message