Sha256: 951f0515e518d3c97e18dca77ccbae4c05ddb60a6b83020d7c3359a52c4a6fce

Contents?: true

Size: 1.94 KB

Versions: 17

Compression:

Stored size: 1.94 KB

Contents

function wait_for_loading_indicator_to_be_finished()
{
  try {
    re = UIATarget.localTarget().frontMostApp().statusBar().elements()[2].rect()
    re2 = UIATarget.localTarget().frontMostApp().statusBar().elements()[3].rect()
    while ((re['size']['width'] == 10 && re['size']['height'] == 20) ||
           (re2['size']['width'] == 10 && re2['size']['height'] == 20))
     {
      UIALogger.logMessage("Loading indicator is visible... waiting")
      UIATarget.localTarget().delay(1)
      re = UIATarget.localTarget().frontMostApp().statusBar().elements()[2].rect()
      re2 = UIATarget.localTarget().frontMostApp().statusBar().elements()[3].rect()
    }
  } catch (e) {}
}

function captureLocalizedScreenshot(name) {
  wait_for_loading_indicator_to_be_finished();

  var target = UIATarget.localTarget();
  var model = target.model();
  var rect = target.rect();
  var deviceOrientation = target.deviceOrientation();
  
  var theSize = (rect.size.width > rect.size.height) ? rect.size.width.toFixed() : rect.size.height.toFixed();

  if (model.match(/iPhone/)) 
  {
    if (theSize > 667) {
      model = "iPhone6Plus";
    } else if (theSize == 667) {
      model = "iPhone6";
    } else if (theSize == 568){
      model = "iPhone5";
    } else {
    model = "iPhone4";
    }
  } 
  else 
  {
    model = "iOS-iPad";
  }

  var orientation = "portrait";
  if (deviceOrientation == UIA_DEVICE_ORIENTATION_LANDSCAPELEFT) {
    orientation = "landscapeleft";
  } else if (deviceOrientation == UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT) {
    orientation = "landscaperight";
  } else if (deviceOrientation == UIA_DEVICE_ORIENTATION_PORTRAIT_UPSIDEDOWN) {
    orientation = "portrait_upsidedown";
  }

  var result = target.host().performTaskWithPathArgumentsTimeout("/usr/bin/printenv" , ["SNAPSHOT_LANGUAGE"], 5);
  var language = result.stdout.substring(0, result.stdout.length - 1);

  var parts = [language, model, name, orientation];
  target.captureScreenWithName(parts.join("-"));
}

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
snapshot-0.8.0 lib/assets/SnapshotHelper.js
snapshot-0.7.1 lib/assets/SnapshotHelper.js
snapshot-0.7.0 lib/assets/SnapshotHelper.js
snapshot-0.6.1 lib/assets/SnapshotHelper.js
snapshot-0.6.0 lib/assets/SnapshotHelper.js
snapshot-0.5.0 lib/assets/SnapshotHelper.js
snapshot-0.4.13 lib/assets/SnapshotHelper.js
snapshot-0.4.12 lib/assets/SnapshotHelper.js
snapshot-0.4.11 lib/assets/SnapshotHelper.js
snapshot-0.4.10 lib/assets/SnapshotHelper.js
snapshot-0.4.9 lib/assets/SnapshotHelper.js
snapshot-0.4.8 lib/assets/SnapshotHelper.js
snapshot-0.4.7 lib/assets/SnapshotHelper.js
snapshot-0.4.6 lib/assets/SnapshotHelper.js
snapshot-0.4.5 lib/assets/SnapshotHelper.js
snapshot-0.4.4 lib/assets/SnapshotHelper.js
snapshot-0.4.3 lib/assets/SnapshotHelper.js