Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using KSScreenshotManager

Using KSScreenshotManager

Slides from my talk at Ottawa Cocoaheads on March 14, 2013.

Chuck Shnider

June 16, 2013
Tweet

More Decks by Chuck Shnider

Other Decks in Programming

Transcript

  1. KSScreenshotManager
    Chuck Shnider
    twi er: @cshnider

    View Slide

  2. It starts small
    enough…

    View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. We’re Gonna
    Need a
    Bigger
    Slide…

    View Slide

  8. View Slide

  9. Production Work

    View Slide

  10. Heaven forbid you
    have to update them
    later!

    View Slide

  11. KSScreenshotManager
    wri en by Kent Sutherland
    from Flexibits
    twi er: @KSuther

    View Slide

  12. @KSuther

    View Slide

  13. h ps://github.com/ksuther/KSScreenshotManager
    Open-Source

    View Slide

  14. KSScreenshotManager
    •Make your code generate the screenshots
    •Fully-Automated
    •Runnable from scripting environments
    •Sample Python Script included
    •Uses “WaxSim” to drive the iOS Simulator

    View Slide

  15. Like Test Automation
    •Not “For Free”
    •Cheaper to repeat over time
    •Effort scales more slowly than manual
    screenshots

    View Slide

  16. Modifying Your Code
    •WARNING Private API Usage!
    •Make sure none of this ships to the AppStore
    •Conditional Compile and perhaps use a new
    target

    View Slide

  17. Modifying Your Code
    •Add KSScreenshotManager and
    KSScreenshotAction.h / .m to your project.
    #de ne CREATING_SCREENSHOTS

    View Slide

  18. Modifying Your Code
    •Create a subclass of KSScreenshotManager
    •Override
    -(void)setupScreenshotActions;

    View Slide

  19. setupScreenshotActions
    •Create instances of KSScreenshotAction
    •block-based API with optional cleanup blocks
    •synch or async, status bar or no
    [self addScreenshotAction:newAction];

    View Slide

  20. KSScreenshotAction
    block
    •Get the app to the correct state
    •Cheat as necessary
    •Fake Data, Mock Objects, etc.
    •Private APIs, both app and OS

    View Slide

  21. AppDelegate Changes
    #if CREATING_SCREENSHOTS
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 *
    NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    MyScreenshotManager *screenshotManager = [[MyScreenshotManager alloc]
    init];
    [screenshotManager setTableViewController:viewController];
    [screenshotManager takeScreenshots];
    });
    #endif

    View Slide

  22. Demo

    View Slide