<commit_before>import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import 'mochawait';
import { AndroidDriver } from '../../..';
import sampleApps from 'sample-apps';
//import ADB from 'appium-adb';

let apiDemos = sampleApps('ApiDemos-debug');

chai.should();
chai.use(chaiAsPromised);

describe('createSession', function () {
  let driver;
  this.timeout(20000);
  before(() => {
    driver = new AndroidDriver();
  });
  it('should start android session focusing on default pkg and act ', async () => {
    let caps = {
      app: apiDemos,
      deviceName: 'Android',
      platformName: 'Android'
    };
    await driver.createSession(caps);
    let {appPackage, appActivity} = await driver.adb.getFocusedPackageAndActivity();
    appPackage.should.equal('io.appium.android.apis');
    appActivity.should.equal('.ApiDemos');
  });
  it('should start android session focusing on custom pkg and act ', async () => {
    let pkg = 'io.appium.android.apis';
    let act = '.view.SplitTouchView';
    let caps = {
      app: apiDemos,
      deviceName: 'Android',
      platformName: 'Android',
      appPackage: pkg,
      appActivity: act
    };
    await driver.createSession(caps);
    let {appPackage, appActivity} = await driver.adb.getFocusedPackageAndActivity();
    appPackage.should.equal(pkg);
    appActivity.should.equal(act);
  });
  afterEach(async () => {
    await driver.deleteSession();
  });
});
<commit_msg>Adding negative tests for create session<commit_after>import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import 'mochawait';
import { AndroidDriver } from '../../..';
import sampleApps from 'sample-apps';
//import ADB from 'appium-adb';

let apiDemos = sampleApps('ApiDemos-debug');

chai.should();
chai.use(chaiAsPromised);

describe('createSession', function () {
  let driver;
  this.timeout(20000);
  before(() => {
    driver = new AndroidDriver();
  });
  it('should start android session focusing on default pkg and act ', async () => {
    let caps = {
      app: apiDemos,
      deviceName: 'Android',
      platformName: 'Android'
    };
    await driver.createSession(caps);
    let {appPackage, appActivity} = await driver.adb.getFocusedPackageAndActivity();
    appPackage.should.equal('io.appium.android.apis');
    appActivity.should.equal('.ApiDemos');
  });
  it('should start android session focusing on custom pkg and act ', async () => {
    let pkg = 'io.appium.android.apis';
    let act = '.view.SplitTouchView';
    let caps = {
      app: apiDemos,
      deviceName: 'Android',
      platformName: 'Android',
      appPackage: pkg,
      appActivity: act
    };
    await driver.createSession(caps);
    let {appPackage, appActivity} = await driver.adb.getFocusedPackageAndActivity();
    appPackage.should.equal(pkg);
    appActivity.should.equal(act);
  });
  it('should error out for not apk extention', async () => {
    let pkg = 'io.appium.android.apis';
    let act = '.view.SplitTouchView';
    let caps = {
      app: "foo",
      deviceName: 'Android',
      platformName: 'Android',
      appPackage: pkg,
      appActivity: act
    };
    await driver.createSession(caps).should.eventually.be.rejectedWith(/apk/);
  });
  it('should error out for invalid app path', async () => {
    let pkg = 'io.appium.android.apis';
    let act = '.view.SplitTouchView';
    let caps = {
      app: "foo.apk",
      deviceName: 'Android',
      platformName: 'Android',
      appPackage: pkg,
      appActivity: act
    };
    await driver.createSession(caps).should.eventually.be.rejectedWith(/Could not find app/);
  });
  afterEach(async () => {
    await driver.deleteSession();
  });
});

{'fraction_non_alphanumeric': 0.14673176023867643, 'fraction_numerical': 0.0027122321670735015, 'mean_word_length': 3.349056603773585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '5377939', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1144, 'n_words': 272}