<commit_before>"use strict";

var setup = require("../../common/setup-base")
  , env = require('../../../helpers/env')
  , initSession = require('../../../helpers/session').initSession
  , _ = require("underscore")
  , desired = require('./desired');

describe('testapp - location -', function () {
  this.timeout(env.MOCHA_INIT_TIMEOUT);

  var driver;
  setup(this, desired).then(function (d) { driver = d; });

  it('should return the right x/y coordinates', function (done) {
    driver
      .elementByTagName('button').getLocation().then(function (location) {
        location.x.should.equal(94);
        location.y.should.be.above(120);
      })
      .nodeify(done);
  });

  it('should not error with valid lat/lon and no options', function (done) {
    var locationOpts = {
      latitude: -30
    , longitude: 30
    };
    driver.execute('mobile: setLocation', [locationOpts])
      .nodeify(done);
  });

  it('should not error with valid lat/lon and valid options', function (done) {
    var locationOpts = {
      latitude: -30
    , longitude: 30
    , altitude: 1000
    };
    driver.execute('mobile: setLocation', [locationOpts])
      .nodeify(done);
  });

  it('should error with invalid lat/lon and no options', function (done) {
    var locationOpts = {
      latitude: -150
    , longitude: 30
    };
    driver.execute('mobile: setLocation', [locationOpts])
      .should.be.rejected
      .nodeify(done);
  });
});

describe('testapp - location services -', function () {
  var driver;
  var newDesired = _.clone(desired);
  _.extend(newDesired, {
    locationServicesAuthorized: true,
    bundleId: 'io.appium.TestApp'
  });
  setup(this, newDesired, {'no-reset': true}).then(function (d) { driver = d; });

  it('should be able to be turned on', function (done) {
    driver
      .elementByName('locationStatus').getValue().then(function (checked) {
        checked.should.equal(1);
      })
      .nodeify(done);
  });<commit_msg>fix up geolocation tests to use new driver method<commit_after>"use strict";

var setup = require("../../common/setup-base")
  , env = require('../../../helpers/env')
  , initSession = require('../../../helpers/session').initSession
  , _ = require("underscore")
  , desired = require('./desired');

describe('testapp - location -', function () {
  this.timeout(env.MOCHA_INIT_TIMEOUT);

  var driver;
  setup(this, desired).then(function (d) { driver = d; });

  it('should return the right x/y coordinates', function (done) {
    driver
      .elementByTagName('button').getLocation().then(function (location) {
        location.x.should.equal(94);
        location.y.should.be.above(120);
      })
      .nodeify(done);
  });

  it('should not error with valid lat/lon and no options', function (done) {
    driver
      .setGeoLocation(-30, 30)
      .nodeify(done);
  });

  it('should error with invalid lat/lon and no options', function (done) {
    driver
      .setGeoLocation(-150, 30)
      .should.be.rejected
      .nodeify(done);
  });
});

describe('testapp - location services -', function () {
  var driver;
  var newDesired = _.clone(desired);
  _.extend(newDesired, {
    locationServicesAuthorized: true,
    bundleId: 'io.appium.TestApp'
  });
  setup(this, newDesired, {'no-reset': true}).then(function (d) { driver = d; });

  it('should be able to be turned on', function (done) {
    driver
      .elementByName('locationStatus').getValue().then(function (checked) {
        checked.should.equal(1);
      })
      .nodeify(done);
  });
{'fraction_non_alphanumeric': 0.16808631459398068, 'fraction_numerical': 0.010789324247586598, 'mean_word_length': 3.021689497716895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2692', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1088, 'n_words': 247}