Esempio n. 1
0
def unmaskView(viewOrLayer):
    window = fb.evaluateExpression(
        '(UIWindow *)[[UIApplication sharedApplication] keyWindow]')
    mask = fb.evaluateExpression('(UIView *)[%s viewWithTag:(NSInteger)%s]' %
                                 (window, viewOrLayer))
    fb.evaluateEffect('[%s removeFromSuperview]' % mask)
    flushCoreAnimationTransaction()
def forceStartAccessibilityServer():
  #We try to start accessibility server only if we don't have needed method active
  if not fb.evaluateBooleanExpression('[UIView instancesRespondToSelector:@selector(_accessibilityElementsInContainer:)]'):
    #Starting accessibility server is different for simulator and device
    if isRunningInSimulator():
      fb.evaluateEffect('[[UIApplication sharedApplication] accessibilityActivate]')
    else:
      fb.evaluateEffect('[[[UIApplication sharedApplication] _accessibilityBundlePrincipalClass] _accessibilityStartServer]')
Esempio n. 3
0
def forceStartAccessibilityServer():
  #We try to start accessibility server only if we don't have needed method active
  if not fb.evaluateBooleanExpression('[UIView instancesRespondToSelector:@selector(_accessibilityElementsInContainer:)]'):
    #Starting accessibility server is different for simulator and device
    if isRunningInSimulator():
      fb.evaluateEffect('[[UIApplication sharedApplication] accessibilityActivate]')
    else:
      fb.evaluateEffect('[[[UIApplication sharedApplication] _accessibilityBundlePrincipalClass] _accessibilityStartServer]')
Esempio n. 4
0
    def run(self, arguments, options):
        upwards = 'NO'
        if options.upwards:
            upwards = 'YES'

        fb.evaluateEffect(
            '[CKComponentDebugController reflowComponentsForView:(UIView *)' +
            arguments[0] + ' searchUpwards:' + upwards + ']')
Esempio n. 5
0
 def run(self, arguments, options):
     if options.set:
         fb.evaluateEffect('[CKComponentDebugController setDebugMode:YES]')
         print('Debug mode for ComponentKit has been set.')
     elif options.unset:
         fb.evaluateEffect('[CKComponentDebugController setDebugMode:NO]')
         print('Debug mode for ComponentKit has been unset.')
     else:
         print('No option for ComponentKit Debug mode specified.')
Esempio n. 6
0
 def run(self, arguments, options):
   if options.set:
     fb.evaluateEffect('[CKComponentDebugController setDebugMode:YES]')
     print 'Debug mode for ComponentKit has been set.'
   elif options.unset:
     fb.evaluateEffect('[CKComponentDebugController setDebugMode:NO]')
     print 'Debug mode for ComponentKit has been unset.'
   else:
     print 'No option for ComponentKit Debug mode specified.'
def presentViewController(viewController):
  vc = '(%s)' % (viewController)
  
  if fb.evaluateBooleanExpression('%s != nil && ((BOOL)[(id)%s isKindOfClass:(Class)[UIViewController class]])' % (vc, vc)):
    notPresented = fb.evaluateBooleanExpression('[%s presentingViewController] == nil' % vc)
    
    if notPresented:
      fb.evaluateEffect('[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:%s animated:YES completion:nil]' % vc)
    else:
      raise Exception('Argument is already presented')
  else:
    raise Exception('Argument must be a UIViewController')
def dismissViewController(viewController):
  vc = '(%s)' % (viewController)
  
  if fb.evaluateBooleanExpression('%s != nil && ((BOOL)[(id)%s isKindOfClass:(Class)[UIViewController class]])' % (vc, vc)):
    isPresented = fb.evaluateBooleanExpression('[%s presentingViewController] != nil' % vc)
    
    if isPresented:
      fb.evaluateEffect('[(UIViewController *)%s dismissViewControllerAnimated:YES completion:nil]' % vc)
    else:
      raise Exception('Argument must be presented')
  else:
    raise Exception('Argument must be a UIViewController')
Esempio n. 9
0
def _showColor(color):
    color = '(' + color + ')'

    colorToUse = color
    isCF = _colorIsCGColorRef(color)
    if isCF:
        colorToUse = '[[UIColor alloc] initWithCGColor:(CGColorRef){}]'.format(
            color)
    else:
        isCI = objectHelpers.isKindOfClass(color, 'CIColor')
        if isCI:
            colorToUse = '[UIColor colorWithCIColor:(CIColor *){}]'.format(
                color)

    imageSize = 58
    fb.evaluateEffect(
        'UIGraphicsBeginImageContextWithOptions((CGSize)CGSizeMake({imageSize}, {imageSize}), NO, 0.0)'
        .format(imageSize=imageSize))
    fb.evaluateEffect('[(id){} setFill]'.format(colorToUse))
    fb.evaluateEffect(
        'UIRectFill((CGRect)CGRectMake(0.0, 0.0, {imageSize}, {imageSize}))'.
        format(imageSize=imageSize))

    result = fb.evaluateExpressionValue(
        '(UIImage *)UIGraphicsGetImageFromCurrentImageContext()')
    if result.GetError() is not None and str(result.GetError()) != 'success':
        print("got error {}".format(result))
        print(result.GetError())
    else:
        image = result.GetValue()
        _showImage(image)

    fb.evaluateEffect('UIGraphicsEndImageContext()')
Esempio n. 10
0
def _showColor(color):
    color = '(' + color + ')'

    colorToUse = color
    isCF = _colorIsCGColorRef(color)
    if isCF:
      colorToUse = '[[UIColor alloc] initWithCGColor:(CGColorRef){}]'.format(color)
    else:
      isCI = objectHelpers.isKindOfClass(color, 'CIColor')
      if isCI:
        colorToUse = '[UIColor colorWithCIColor:(CIColor *){}]'.format(color)

    imageSize = 58
    fb.evaluateEffect('UIGraphicsBeginImageContextWithOptions((CGSize)CGSizeMake({imageSize}, {imageSize}), NO, 0.0)'.format(imageSize=imageSize))
    fb.evaluateEffect('[(id){} setFill]'.format(colorToUse))
    fb.evaluateEffect('UIRectFill((CGRect)CGRectMake(0.0, 0.0, {imageSize}, {imageSize}))'.format(imageSize=imageSize))

    frame = lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
    result = frame.EvaluateExpression('(UIImage *)UIGraphicsGetImageFromCurrentImageContext()')
    if result.GetError() is not None and str(result.GetError()) != 'success':
      print "got error {}".format(result)
      print result.GetError()
    else:
      image = result.GetValue()
      _showImage(image)

    fb.evaluateEffect('UIGraphicsEndImageContext()')
Esempio n. 11
0
def setBorderOnAmbiguousViewRecursive(view, width, color):
  if not fb.evaluateBooleanExpression('[(id)%s isKindOfClass:(Class)[UIView class]]' % view):
    return

  isAmbiguous = fb.evaluateBooleanExpression('(BOOL)[%s hasAmbiguousLayout]' % view)
  if isAmbiguous:
    layer = viewHelpers.convertToLayer(view)
    fb.evaluateEffect('[%s setBorderWidth:(CGFloat)%s]' % (layer, width))
    fb.evaluateEffect('[%s setBorderColor:(CGColorRef)[(id)[UIColor %sColor] CGColor]]' % (layer, color))

  subviews = fb.evaluateExpression('(id)[%s subviews]' % view)
  subviewsCount = int(fb.evaluateExpression('(int)[(id)%s count]' % subviews))
  if subviewsCount > 0:
    for i in range(0, subviewsCount):
      subview = fb.evaluateExpression('(id)[%s objectAtIndex:%i]' % (subviews, i))
      setBorderOnAmbiguousViewRecursive(subview, width, color)
Esempio n. 12
0
def setBorderOnAmbiguousViewRecursive(view, width, color):
  if not fb.evaluateBooleanExpression('[(id)%s isKindOfClass:(Class)[UIView class]]' % view):
    return

  isAmbiguous = fb.evaluateBooleanExpression('(BOOL)[%s hasAmbiguousLayout]' % view)
  if isAmbiguous:
    layer = viewHelpers.convertToLayer(view)
    fb.evaluateEffect('[%s setBorderWidth:(CGFloat)%s]' % (layer, width))
    fb.evaluateEffect('[%s setBorderColor:(CGColorRef)[(id)[UIColor %sColor] CGColor]]' % (layer, color))

  subviews = fb.evaluateExpression('(id)[%s subviews]' % view)
  subviewsCount = int(fb.evaluateExpression('(int)[(id)%s count]' % subviews))
  if subviewsCount > 0:
    for i in range(0, subviewsCount):
      subview = fb.evaluateExpression('(id)[%s objectAtIndex:%i]' % (subviews, i))
      setBorderOnAmbiguousViewRecursive(subview, width, color)
Esempio n. 13
0
def dismissViewController(viewController):
    vc = "(%s)" % (viewController)

    if fb.evaluateBooleanExpression(
            "%s != nil && ((BOOL)[(id)%s isKindOfClass:(Class)[UIViewController class]])"
            % (vc, vc)):
        isPresented = fb.evaluateBooleanExpression(
            "[%s presentingViewController] != nil" % vc)

        if isPresented:
            fb.evaluateEffect(
                "[(UIViewController *)%s dismissViewControllerAnimated:YES completion:nil]"  # noqa B950
                % vc)
        else:
            raise Exception("Argument must be presented")
    else:
        raise Exception("Argument must be a UIViewController")
Esempio n. 14
0
def _showLayer(layer):
    layer = "(" + layer + ")"
    size = "((CGRect)[(id)" + layer + " bounds]).size"

    width = float(fb.evaluateExpression("(CGFloat)(" + size + ".width)"))
    height = float(fb.evaluateExpression("(CGFloat)(" + size + ".height)"))
    if width == 0.0 or height == 0.0:
        print("Nothing to see here - the size of this element is {} x {}.".
              format(width, height))
        return

    fb.evaluateEffect("UIGraphicsBeginImageContextWithOptions(" + size +
                      ", NO, 0.0)")
    fb.evaluateEffect(
        "[(id)" + layer +
        " renderInContext:(void *)UIGraphicsGetCurrentContext()]")

    result = fb.evaluateExpressionValue(
        "(UIImage *)UIGraphicsGetImageFromCurrentImageContext()")
    if result.GetError() is not None and str(result.GetError()) != "success":
        print(result.GetError())
    else:
        image = result.GetValue()
        _showImage(image)

    fb.evaluateEffect("UIGraphicsEndImageContext()")
Esempio n. 15
0
def _showLayer(layer):
    layer = '(' + layer + ')'
    size = '((CGRect)[(id)' + layer + ' bounds]).size'

    width = float(fb.evaluateExpression('(CGFloat)(' + size + '.width)'))
    height = float(fb.evaluateExpression('(CGFloat)(' + size + '.height)'))
    if width == 0.0 or height == 0.0:
        print('Nothing to see here - the size of this element is {} x {}.'.
              format(width, height))
        return

    fb.evaluateEffect('UIGraphicsBeginImageContextWithOptions(' + size +
                      ', NO, 0.0)')
    fb.evaluateEffect(
        '[(id)' + layer +
        ' renderInContext:(void *)UIGraphicsGetCurrentContext()]')

    result = fb.evaluateExpressionValue(
        '(UIImage *)UIGraphicsGetImageFromCurrentImageContext()')
    if result.GetError() is not None and str(result.GetError()) != 'success':
        print(result.GetError())
    else:
        image = result.GetValue()
        _showImage(image)

    fb.evaluateEffect('UIGraphicsEndImageContext()')
Esempio n. 16
0
def maskView(viewOrLayer, color, alpha):
  unmaskView(viewOrLayer)
  window = fb.evaluateExpression('(UIWindow *)[[UIApplication sharedApplication] keyWindow]')
  origin = convertPoint(0, 0, viewOrLayer, window)
  size = fb.evaluateExpressionValue('(CGSize)((CGRect)[(id)%s frame]).size' % viewOrLayer)

  rectExpr = '(CGRect){{%s, %s}, {%s, %s}}' % (origin.GetChildMemberWithName('x').GetValue(),
                                               origin.GetChildMemberWithName('y').GetValue(),
                                               size.GetChildMemberWithName('width').GetValue(),
                                               size.GetChildMemberWithName('height').GetValue())
  mask = fb.evaluateExpression('(id)[[UIView alloc] initWithFrame:%s]' % rectExpr)

  fb.evaluateEffect('[%s setTag:(NSInteger)%s]' % (mask, viewOrLayer))
  fb.evaluateEffect('[%s setBackgroundColor:[UIColor %sColor]]' % (mask, color))
  fb.evaluateEffect('[%s setAlpha:(CGFloat)%s]' % (mask, alpha))
  fb.evaluateEffect('[%s addSubview:%s]' % (window, mask))
  flushCoreAnimationTransaction()
Esempio n. 17
0
def maskView(viewOrLayer, color, alpha):
    unmaskView(viewOrLayer)
    window = fb.evaluateExpression(
        '(UIWindow *)[[UIApplication sharedApplication] keyWindow]')
    origin = convertPoint(0, 0, viewOrLayer, window)
    size = fb.evaluateExpressionValue('(CGSize)((CGRect)[(id)%s frame]).size' %
                                      viewOrLayer)

    rectExpr = '(CGRect){{%s, %s}, {%s, %s}}' % (
        origin.GetChildMemberWithName('x').GetValue(),
        origin.GetChildMemberWithName('y').GetValue(),
        size.GetChildMemberWithName('width').GetValue(),
        size.GetChildMemberWithName('height').GetValue())
    mask = fb.evaluateExpression('(id)[[UIView alloc] initWithFrame:%s]' %
                                 rectExpr)

    fb.evaluateEffect('[%s setTag:(NSInteger)%s]' % (mask, viewOrLayer))
    fb.evaluateEffect('[%s setBackgroundColor:[UIColor %sColor]]' %
                      (mask, color))
    fb.evaluateEffect('[%s setAlpha:(CGFloat)%s]' % (mask, alpha))
    fb.evaluateEffect('[%s addSubview:%s]' % (window, mask))
    flushCoreAnimationTransaction()
Esempio n. 18
0
def _showLayer(layer):
  layer = '(' + layer + ')'
  size = '((CGRect)[(id)' + layer + ' bounds]).size'

  width = float(fb.evaluateExpression(size + '.width'))
  height = float(fb.evaluateExpression(size + '.height'))
  if width == 0.0 or height == 0.0:
    print 'Nothing to see here - the size of this element is {} x {}.'.format(width, height)
    return

  fb.evaluateEffect('UIGraphicsBeginImageContextWithOptions(' + size + ', NO, 0.0)')
  fb.evaluateEffect('[(id)' + layer + ' renderInContext:(void *)UIGraphicsGetCurrentContext()]')

  frame = lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
  result = frame.EvaluateExpression('(UIImage *)UIGraphicsGetImageFromCurrentImageContext()')
  if result.GetError() is not None and str(result.GetError()) != 'success':
    print result.GetError()
  else:
    image = result.GetValue()
    _showImage(image)

  fb.evaluateEffect('UIGraphicsEndImageContext()')
Esempio n. 19
0
def flushCoreAnimationTransaction():
    fb.evaluateEffect('[CATransaction flush]')
Esempio n. 20
0
 def run(self, arguments, options):
   fb.evaluateEffect('[[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)]')
Esempio n. 21
0
 def setBorder(layer, width, color, colorClass):
   fb.evaluateEffect('[%s setBorderWidth:(CGFloat)%s]' % (layer, width))
   fb.evaluateEffect('[%s setBorderColor:(CGColorRef)[(id)[%s %sColor] CGColor]]' % (layer, colorClass, color))
Esempio n. 22
0
 def setUnborder(layer):
     fb.evaluateEffect('[%s setBorderWidth:(CGFloat)%s]' % (layer, 0))
Esempio n. 23
0
def slowAnimation(speed=1):
    fb.evaluateEffect(
        '[[[UIApplication sharedApplication] windows] setValue:@(%s) forKeyPath:@"layer.speed"]'
        % speed)
Esempio n. 24
0
def setViewHidden(object, hidden):
  fb.evaluateEffect('[{} setHidden:{}]'.format(object, int(hidden)))
  flushCoreAnimationTransaction()
Esempio n. 25
0
def unmaskView(viewOrLayer):
  window = fb.evaluateExpression('(UIWindow *)[[UIApplication sharedApplication] keyWindow]')
  mask = fb.evaluateExpression('(UIView *)[%s viewWithTag:(NSInteger)%s]' % (window, viewOrLayer))
  fb.evaluateEffect('[%s removeFromSuperview]' % mask)
  flushCoreAnimationTransaction()
Esempio n. 26
0
 def run(self, arguments, options):
     fb.evaluateEffect('[CKComponentDebugController reflowComponents]')
Esempio n. 27
0
 def run(self, arguments, options):
   fb.evaluateEffect('[CKComponentDebugController reflowComponents]')
Esempio n. 28
0
def flushCoreAnimationTransaction():
  fb.evaluateEffect('[CATransaction flush]')
Esempio n. 29
0
 def setUnborder(layer):
     fb.evaluateEffect('[%s setBorderWidth:(CGFloat)%s]' % (layer, 0))
Esempio n. 30
0
 def setBorder(layer, width, color, colorClass):
     fb.evaluateEffect('[%s setBorderWidth:(CGFloat)%s]' %
                       (layer, width))
     fb.evaluateEffect(
         '[%s setBorderColor:(CGColorRef)[(id)[%s %sColor] CGColor]]' %
         (layer, colorClass, color))
Esempio n. 31
0
def setViewHidden(object, hidden):
    fb.evaluateEffect('[{} setHidden:{}]'.format(object, int(hidden)))
    flushCoreAnimationTransaction()
Esempio n. 32
0
def slowAnimation(speed=1):
  fb.evaluateEffect('[[[UIApplication sharedApplication] windows] setValue:@(%s) forKeyPath:@"layer.speed"]' % speed)
Esempio n. 33
0
  def run(self, arguments, options):
    upwards = 'NO'
    if options.upwards:
      upwards = 'YES'

    fb.evaluateEffect('[CKComponentDebugController reflowComponentsForView:(UIView *)' + arguments[0] + ' searchUpwards:' + upwards + ']')