uipangesturerecognizer - iOS OCMock: How to test panning -


i new ocmock , needed getting started. have uiscrollview upon panning triggers event handler stuff. i'd test this. here's how make object

id gesturemock = [ocmockobject partialmockforobject:[uipangesturerecognizer new]]; 
  1. now how set panning specifications?

  2. after initializing panning, how "invoke" pan?

if testing code responds uipangesturerecognizer, write test around target method of gesture recognizer.

// if have this... uipangesturerecognizer *pgr = [[uipangesturerecognizer alloc] initwithtarget:self action:@selector(didpan:)]; [self.scrollview addgesturerecognizer:pgr];  // this... - (void)didpan:(uipangesturerecognizer *)pgr {     switch (pgr.state):     {         case uigesturerecognizerstateended:             [self dosomething];             break;         default:     } }  // id gesturemock = [ocmockobject mockforclass:[uipangesturerecognizer class]]; [[[gesturemock stub] andreturn:uipangesturerecognizerstateended] state]; id objectundertest = [ocmockobject partialmockforobject:[myclass new]]; [[objectundertest expect] dosomething]; // make call [objectundertest didpan:gesturemock]; [objectundertest verify]; 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -