Trouble getting reference to list item renderers after adding Flex List component to TestCase.testEnvironment

35 views
Skip to first unread message

LT

unread,
Oct 11, 2009, 4:07:57 AM10/11/09
to Fluint Discussions
Hi, all.

I'm a little puzzled by some behavior I get using Fluint with lists
and list item renderers.

Here's what my test case class does:

1) In its setUp() method it
(a) creates a flex List component.
(b) adds the list to testEnvironment using addChild()
(c) adds an event listener to the list for the event
CREATION_COMPLETE, using an asycHandler that's passed
pendUntilComplete and a timeout of 2000
(d) sets the list's dataProvider to an array of 3 items.
2) In one of its test methods, it tries to get a reference to the
list's second item renderer using list.indexToItemRenderer(1).

What's puzzling is that when the test case runs, the renderer in (2)
is always null and the list's listItems property is always an array of
0 length.

BUT... when I set up a non-test non-fluint Flex application and create
and add a list, I can always get a reference to the item renderer when
inside a method that executes in response to the list's
CREATION_COMPLETE event.

It doesn't seem to me that there should be difference in list
rendering whether it's occurring in a test case's testEnvironment
container or not.

Are there any weird undocumented limitations of using testEnvironment
for testing UI components?

Thanks much!

LT

Michael Labriola

unread,
Oct 11, 2009, 9:11:26 PM10/11/09
to Fluint Discussions

LT,

The test environment really doesn't do much other than allow you to
add an item to a container behind the scenes, so there isn't anything
there that would be causing you an issue. So, only possible
undocumented issue would be if you are using multiple application/
security domains, but that doesn't sound like an issue here.

One thing to note is that creationComplete really means that the
component itself is rendered and ready to be drawn on the screen. I
don't have the code in front of me, but I am not sure that there is
any guarantee in the list classes that the renderers have been created
and the dataProvider processed by creationComplete.

One more thin is that the creationComplete of an item directly inside
of an Application class is actually slightly different than another
container added after the application has started. To more precisely
mimick the test environment, I would add a Canvas to your Application.
Then, on creationComplete of the App, I would dynamically add your
list to the Canvas. On its creation complete, I would check the params
you mentioned. That is a little closer to the actualy test procedure.

HTH,
Mike

LT

unread,
Oct 13, 2009, 1:13:11 AM10/13/09
to Fluint Discussions
Mike,

Thanks so much for taking the time to respond to my post.
I discovered the cause of the discrepancy in behavior. When I was
adding the List instance to testEnvironment, I wasn't giving the List
instance a height and width!! :(
And it seems a List will only generate renderers for the part of its
display area that is visible, which makes sense.
Thanks again!

LT
Reply all
Reply to author
Forward
0 new messages