Monday 15 September 2014

ios - Testing autolayout with XCTest -



ios - Testing autolayout with XCTest -

i'm trying figure out if there way test layout of ios view in unit tests when using autolayout. right seek initialize view controller, , check frames of views. however, frame on each view remains origin=(x=0, y=0) size=(width=0, height=0).

- (void)setup { [super setup]; _viewcontroller = [[addplayerviewcontroller alloc] init]; _viewcontroller.view.frame = cgrectmake(0, 0, 320, 460); [_viewcontroller view]; } - (void)testviewsareinsidewindow { [self checkifviewisinsidewindow:_viewcontroller.txtfnewplayer]; [self checkifviewisinsidewindow:_viewcontroller.btnnewplayer]; [self checkifviewisinsidewindow:_viewcontroller.tblplayers]; } - (void)checkifviewisinsidewindow:(uiview *)view { cgrect windowframe = _viewcontroller.view.frame; cgrect viewframe = view.frame; xctasserttrue(cgrectcontainsrect(windowframe, viewframe)); }

i've tried adding

[_viewcontroller.view needsupdateconstraints];

or

[_viewcontroller.view updateconstraints];

or

[_viewcontroller updateviewconstraints];

or

[_viewcontroller viewwillappear:yes];

but none of them have helped.

is @ possible autolayout run when using xctest?

have tried setneedslayout followed layoutifneeded?

you can layout run in tests, here, doesn't have view controller, views.

ios objective-c autolayout xctest

No comments:

Post a Comment