<commit_before>package org.uiautomation.ios.e2e.crash;

import junit.framework.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.RemoteWebElement;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.uiautomation.ios.IOSCapabilities;
import org.uiautomation.ios.SampleApps;
import org.uiautomation.ios.server.IOSServer;
import org.uiautomation.ios.server.IOSServerConfiguration;

import java.net.MalformedURLException;
import java.net.URL;

public class CrashHandling {

  private IOSServer server;
  private IOSServerConfiguration config;
  private RemoteWebDriver driver;

  @BeforeClass
  public void startServer() throws Exception {
    String[] args = {"-port", "4444", "-host", "localhost",
        "-app", SampleApps.getPPNQASampleApp(), "-simulators" };
    config = IOSServerConfiguration.create(args);

    server = new IOSServer(config);
    server.start();
  }

  @AfterClass
  public void stopServer() throws Exception {
    if (server != null) {
      server.stop();
      server = null;
    }
  }

  @AfterMethod
  public void closeDriver() {
    if (driver != null) {
      driver.quit();
      driver = null;
    }
  }

  private URL getRemoteURL() {
    try {
      URL remote = new URL("http://" + config.getHost() + ":" + config.getPort() + "/wd/hub");
      return remote;
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    }
  }

  @Test
  public void isAppCrashDetected() throws InterruptedException {
    IOSCapabilities cap = SampleApps.ppNQASampleAppCap();
    cap.setCapability(IOSCapabilities.SIMULATOR, true);

    RemoteWebDriver driver = new RemoteWebDriver(getRemoteURL(), cap);
    WebElement crashButton = driver.findElement(By.name("Crash me!"));
    crashButton.click();
    Thread.sleep(2000);
    Assert.assertTrue("App crash detected.", false);

  }

  @Test
  public void isSimulatorCrashDetected() throws InterruptedException {
    IOSCapabilities cap = SampleApps.ppNQASampleAppCap();
    cap.setCapability(IOSCapabilities.SIMULATOR, true);

    RemoteWebDriver driver = new RemoteWebDriver(getRemoteURL(), cap);

    // kill simulator

    Assert.assertTrue("Sim crash detected.", false);

  }

  @Test
  public void isInstrumentsCrashDetected() throws InterruptedException {
    IOSCapabilities cap = SampleApps.ppNQASampleAppCap();
    cap.setCapability(IOSCapabilities.SIMULATOR, true);

    RemoteWebDriver driver = new RemoteWebDriver(getRemoteURL(), cap);

    // kill instruments

    Assert.assertTrue("Instruments crash detected.", false);

  }

}<commit_msg>update to crash tests<commit_after>package org.uiautomation.ios.e2e.crash;

import junit.framework.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.uiautomation.ios.IOSCapabilities;
import org.uiautomation.ios.SampleApps;
import org.uiautomation.ios.server.IOSServer;
import org.uiautomation.ios.server.IOSServerConfiguration;
import org.uiautomation.ios.utils.ClassicCommands;

import java.net.MalformedURLException;
import java.net.URL;

public class CrashHandling {

  private IOSServer server;
  private IOSServerConfiguration config;
  private RemoteWebDriver driver;

  @BeforeClass
  public void startServer() throws Exception {
    String[] args = {"-port", "4444", "-host", "localhost",
        "-app", SampleApps.getPPNQASampleApp(), "-simulators" };
    config = IOSServerConfiguration.create(args);

    server = new IOSServer(config);
    server.start();
  }

  @AfterClass
  public void stopServer() throws Exception {
    if (server != null) {
      server.stop();
      server = null;
    }
  }

  @AfterMethod
  public void closeDriver() {
    if (driver != null) {
      driver.quit();
      driver = null;
    }
  }

  private URL getRemoteURL() {
    try {
      URL remote = new URL("http://" + config.getHost() + ":" + config.getPort() + "/wd/hub");
      return remote;
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    }
  }

  @Test
  public void isAppCrashDetected() throws InterruptedException {
    IOSCapabilities cap = SampleApps.ppNQASampleAppCap();
    cap.setCapability(IOSCapabilities.SIMULATOR, true);

    RemoteWebDriver driver = new RemoteWebDriver(getRemoteURL(), cap);
    WebElement crashButton = driver.findElement(By.name("Crash me!"));
    crashButton.click();
    Thread.sleep(2000);
    Assert.assertTrue("App crash detected.", false);

  }

  @Test
  public void isSimulatorCrashDetected() throws InterruptedException {
    IOSCapabilities cap = SampleApps.ppNQASampleAppCap();
    cap.setCapability(IOSCapabilities.SIMULATOR, true);

    RemoteWebDriver driver = new RemoteWebDriver(getRemoteURL(), cap);

    // kill simulator
    ClassicCommands.killall("iPhone Simulator");
    Thread.sleep(3000);

    Assert.assertTrue("Sim crash detected.", false);

  }

  @Test
  public void isInstrumentsCrashDetected() throws InterruptedException {
    IOSCapabilities cap = SampleApps.ppNQASampleAppCap();
    cap.setCapability(IOSCapabilities.SIMULATOR, true);

    RemoteWebDriver driver = new RemoteWebDriver(getRemoteURL(), cap);

    // kill instruments
    ClassicCommands.killall("instruments");
    Thread.sleep(3000);

    Assert.assertTrue("Instruments crash detected.", false);

  }

}
{'fraction_non_alphanumeric': 0.11333333333333333, 'fraction_numerical': 0.004561403508771929, 'mean_word_length': 4.131413141314131, 'pattern_counts': {'":': 2, '<': 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': '5137141', 'n_tokens_mistral': 1817, 'n_tokens_neox': 1738, 'n_words': 360}