FLEX-18746 Added the same test, but without using opening animation. (This way the bug cannot be reproduced, which is a good clue.)
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/7a519a33 Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/7a519a33 Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/7a519a33 Branch: refs/heads/master Commit: 7a519a33e4e93d9657531b15e24d5684a0f80abc Parents: b175cd6 Author: Mihai Chira <mih...@apache.org> Authored: Tue Aug 15 12:19:14 2017 +0200 Committer: Mihai Chira <mih...@apache.org> Committed: Tue Aug 15 12:19:14 2017 +0200 ---------------------------------------------------------------------- .../tests/mx/controls/Tree_FLEX_18746_Tests.as | 39 +++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/7a519a33/frameworks/projects/mx/tests/mx/controls/Tree_FLEX_18746_Tests.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/mx/tests/mx/controls/Tree_FLEX_18746_Tests.as b/frameworks/projects/mx/tests/mx/controls/Tree_FLEX_18746_Tests.as index 26568d6..16a3cbc 100644 --- a/frameworks/projects/mx/tests/mx/controls/Tree_FLEX_18746_Tests.as +++ b/frameworks/projects/mx/tests/mx/controls/Tree_FLEX_18746_Tests.as @@ -18,8 +18,8 @@ package mx.controls { private static var _sut:Tree; private static var child:Object = {label: "Item"}; - private static var parent0:Object = {label: "Folder 0", children: new ArrayCollection()}; - private static var parent1:Object = {label: "Folder 1", children: new ArrayCollection([child])}; + private static var parent0:Object; + private static var parent1:Object; [Before] @@ -28,6 +28,10 @@ package mx.controls { _sut = new Tree(); _sut.width = 200; _sut.height = 200; + + parent0 = {label: "Folder 0", children: new ArrayCollection()}; + parent1 = {label: "Folder 1", children: new ArrayCollection([child])}; + UIImpersonator.addChild(_sut); } @@ -46,7 +50,24 @@ package mx.controls { //-------------------------------------------------------------------------- [Test(async, timeout=1000)] - public function test_closing_previously_opened_folder_with_0_children_does_not_throw_fatal():void + public function test_closing_previously_opened_folder_with_0_children_without_animation_does_not_throw_fatal():void + { + //given + const dataProvider:ArrayCollection = new ArrayCollection(); + dataProvider.addItem(parent0); + dataProvider.addItem(parent1); + + //when + _sut.dataProvider = dataProvider; + + //then wait a few frames + noEnterFramesToWait = 2; + UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame); + Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_expand_second_folder, 300, {useAnimation:false}); + } + + [Test(async, timeout=1000)] + public function test_closing_previously_opened_folder_with_0_children_using_animation_does_not_throw_fatal():void { //given const dataProvider:ArrayCollection = new ArrayCollection(); @@ -59,19 +80,19 @@ package mx.controls { //then wait a few frames noEnterFramesToWait = 2; UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame); - Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_expand_second_folder, 300); + Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_expand_second_folder, 300, {useAnimation:true}); } private function then_expand_second_folder(event:Event, passThroughData:Object):void { //when - _sut.expandItem(parent1, true, true, true); + _sut.expandItem(parent1, true, passThroughData.useAnimation, true); //then wait a bit noEnterFramesToWait = 5; UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame); - Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_move_child_to_first_parent_and_expand_it, 500); + Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_move_child_to_first_parent_and_expand_it, 500, passThroughData); } private function then_move_child_to_first_parent_and_expand_it(event:Event, passThroughData:Object):void @@ -81,19 +102,19 @@ package mx.controls { //when ArrayCollection(parent1.children).removeItemAt(0); - _sut.expandItem(parent0, true, true, true); + _sut.expandItem(parent0, true, passThroughData.useAnimation, true); ArrayCollection(parent0.children).addItem(child); //then wait a bit noEnterFramesToWait = 1; UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame); - Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_contract_second_folder, 200); + Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_contract_second_folder, 200, passThroughData); } private static function then_contract_second_folder(event:Event, passThroughData:Object):void { //when - _sut.expandItem(parent1, false, true, true); + _sut.expandItem(parent1, false, passThroughData.useAnimation, true); //then no error was thrown assertThat(true);