<commit_before>package org.jpacman.test.framework.ui;

import static org.mockito.Mockito.verify;
import static org.junit.Assert.assertTrue;
import java.awt.event.KeyEvent;
import org.fest.swing.core.BasicRobot;
import org.fest.swing.core.Robot;
import org.jpacman.framework.factory.FactoryException;
import org.jpacman.framework.ui.ButtonPanel;
import org.jpacman.framework.ui.MainUI;
import org.jpacman.framework.ui.PacmanInteraction;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;

/**
 * Test if the MainUI keeps responding to keystrokes when a focus traversal key
 * has been pressed and thus didn't lose focus.
 * 
 * @author <NAME>, TU Delft, Mar 2, 2013
 */
@RunWith(MockitoJUnitRunner.class)
public class MainUIFocusTest {

	@Spy
	private PacmanInteraction pi;

	/**
	 * Perform a tab key press to check if the MainUI is handling focus
	 * traversal properly.
	 * 
	 * @throws FactoryException
	 *             If reading board fails.
	 */
	@Test
	public void testFocusHandling() throws FactoryException {

		MainUI ui = new MainUI();
		ButtonPanel bp = new ButtonPanel();
		ui.withModelInteractor(pi).withButtonPanel(bp);
		Robot robot = BasicRobot.robotWithCurrentAwtHierarchy();

		ui.main();
		bp.start();

		// perform tab key press and wait until it took place
		robot.pressAndReleaseKey(KeyEvent.VK_TAB);
		robot.waitForIdle();
<commit_msg>starting the game via the GUI instead of direct programmatically<commit_after>package org.jpacman.test.framework.ui;

import static org.mockito.Mockito.verify;
import static org.junit.Assert.assertTrue;
import java.awt.event.KeyEvent;
import org.fest.swing.core.BasicRobot;
import org.fest.swing.core.Robot;
import org.jpacman.framework.factory.FactoryException;
import org.jpacman.framework.ui.ButtonPanel;
import org.jpacman.framework.ui.MainUI;
import org.jpacman.framework.ui.PacmanInteraction;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;

/**
 * Test if the MainUI keeps responding to keystrokes when a focus traversal key
 * has been pressed and thus didn't lose focus.
 * 
 * @author <NAME>, TU Delft, Mar 2, 2013
 */
@RunWith(MockitoJUnitRunner.class)
public class MainUIFocusTest {

	@Spy
	private PacmanInteraction pi;

	/**
	 * Perform a tab key press to check if the MainUI is handling focus
	 * traversal properly.
	 * 
	 * @throws FactoryException
	 *             If reading board fails.
	 */
	@Test
	public void testFocusHandling() throws FactoryException {

		MainUI ui = new MainUI();
		ui.withModelInteractor(pi);
		Robot robot = BasicRobot.robotWithCurrentAwtHierarchy();

		ui.main();
		
		//hit start
	    robot.click(robot.finder().findByName(ButtonPanel.START_BUTTON_NAME));

		
		// perform tab key press and wait until it took place
		robot.pressAndReleaseKey(KeyEvent.VK_TAB);
		robot.waitForIdle();

{'fraction_non_alphanumeric': 0.09853890587835543, 'fraction_numerical': 0.0033978933061501867, 'mean_word_length': 4.372262773722627, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5395649', 'n_tokens_mistral': 1011, 'n_tokens_neox': 928, 'n_words': 245}