iterating over each tab in the tab bar?

12 views
Skip to first unread message

Perryn Fowler

unread,
Jan 4, 2010, 10:04:13 PM1/4/10
to uis...@googlegroups.com
Hi,

My application uses a TabViewController and I would like to write a
test that navigates to each tab page and does something on that page.

I'm probably being dense but I can't work out how to do it - does
anyone have any pointers?

cheers
Perryn

Brian

unread,
Jan 5, 2010, 7:36:44 PM1/5/10
to UISpec
To the click the tab you want to further test in you can do something
like the following:

[[app.tabBar.label.with text:@"My Tab Name"] touch];

Perryn Fowler

unread,
Jan 5, 2010, 10:49:41 PM1/5/10
to uis...@googlegroups.com
Hi Brian,

Thanks, but what I wanted was to be able to specify some checks that
would be run on *every* tab page, ideally without having to hardcode
the names of each tab.

I ended up monkey-patching UIQuery to add an 'each' method that
invokes a callback for each thing matched by the traversal, so I can
do something like

- (void)checkTabPage:(UIQuery *)tabLabel {
[[tabLabel parent] touch];
//do other stuff
}

[app.tabBar.label each:@selector(checkTabPage:) object:self];

happy to contribute back to the project if you are intersted

cheers
Perryn

> --
> You received this message because you are subscribed to the Google Groups "UISpec" group.
> To post to this group, send email to uis...@googlegroups.com.
> To unsubscribe from this group, send email to uispec+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/uispec?hl=en.
>
>
>
>

--
-----------------------
Perryn Fowler
ThoughtWorks

Brian Knorr

unread,
Jan 6, 2010, 1:16:01 AM1/6/10
to uis...@googlegroups.com
Oooooooo....I like it:) The closer we get to Ruby makes me happy. I
would really like to add "each:object:" to UIQuery, so either you can
just send me the code or if you would like to continue contributing I
can add you as a commiter...just let me know...thx!
Reply all
Reply to author
Forward
0 new messages