<commit_before>package guitests;

import javafx.scene.input.KeyCode;
import org.junit.Test;
import ui.UI;
import ui.components.KeyboardShortcuts;
import util.events.ColumnClickedEventHandler;
import util.events.IssueSelectedEventHandler;
import util.events.testevents.UIComponentFocusEvent;
import util.events.testevents.UIComponentFocusEventHandler;
import util.events.testevents.WindowResizeEvent;
import util.events.testevents.WindowResizeEventHandler;

import static org.junit.Assert.assertEquals;
import static ui.components.KeyboardShortcuts.DOUBLE_PRESS;

public class KeyboardShortcutsTest extends UITest {

    private WindowResizeEvent.EventType windowResizeEventType;
    private UIComponentFocusEvent.EventType uiComponentFocusEventType;
    private int selectedIssueId;
    private int columnIndex;

    // TODO test that events have been triggered
    @Test
    public void keyboardShortcutsTest() {
        UI.events.registerEvent((WindowResizeEventHandler) e -> windowResizeEventType = e.eventType);
        UI.events.registerEvent((IssueSelectedEventHandler) e -> selectedIssueId = e.id);
        UI.events.registerEvent((UIComponentFocusEventHandler) e -> uiComponentFocusEventType = e.eventType);
        UI.events.registerEvent((ColumnClickedEventHandler) e -> columnIndex = e.columnIndex);
        clearEventType();
        clearSelectedIssueId();
        clearUiComponentFocusEventType();
        clearColumnIndex();

        // maximize
        press(KeyCode.CONTROL).press(KeyCode.X).release(KeyCode.X).release(KeyCode.CONTROL);
        assertEquals(WindowResizeEvent.EventType.MAXIMIZE_WINDOW, windowResizeEventType);
        clearEventType();

        // mid-sized window
        press(KeyCode.CONTROL).press(KeyCode.D).release(KeyCode.D).release(KeyCode.CONTROL);
        assertEquals(WindowResizeEvent.EventType.DEFAULT_SIZE_WINDOW, windowResizeEventType);
        clearEventType();

        // jump from filter box to first issue
        press(KeyCode.CONTROL).press(KeyCode.DOWN).release(KeyCode.DOWN).release(KeyCode.CONTROL);
        assertEquals(10, selectedIssueId);
        clearSelectedIssueId();

        // jump from issue list to filter box
        press(KeyCode.CONTROL).press(KeyCode.UP).release(KeyCode.UP).release(KeyCode.CONTROL);
        assertEquals(UIComponentFocusEvent.EventType.FILTER_BOX, uiComponentFocusEventType);
        clearUiComponentFocusEventType();

        // jump from filter box to first issue
        push(DOUBLE_PRESS).push(DOUBLE_PRESS);
        assertEquals(10, selectedIssueId);
        clearSelectedIssueId();

        // jump from issue list to filter box
        push(DOUBLE_PRESS).push(DOUBLE_PRESS);
        assertEquals(UIComponentFocusEvent.EventType.FILTER_BOX, uiComponentFocusEventType);
        clearUiComponentFocusEventType();

        push(DOUBLE_PRESS).push(DOUBLE_PRESS);

        // jump to last issue
        push(KeyCode.END);
        assertEquals(1, selectedIssueId);
        clearSelectedIssueId();

        // jump to first issue
        push(KeyCode.HOME);
        sleep(1000);
        assertEquals(10, selectedIssueId);
        clearSelectedIssueId();

        push(getKeyCode("DOWN_ISSUE"));
        assertEquals(9, selectedIssueId);
        clearSelectedIssueId();
        push(getKeyCode("DOWN_ISSUE"));
        assertEquals(8, selectedIssueId);
        clearSelectedIssueId();
        push(getKeyCode("UP_ISSUE"));
        assertEquals(9, selectedIssueId);
        clearSelectedIssueId();

        press(KeyCode.CONTROL).press(KeyCode.P).release(KeyCode.P).release(KeyCode.CONTROL);
        push(DOUBLE_PRESS).push(DOUBLE_PRESS);

        push(getKeyCode("RIGHT_PANEL"));
        assertEquals(0, columnIndex);
        clearColumnIndex();
        push(getKeyCode("LEFT_PANEL"));
        assertEquals(1, columnIndex);
        clearColumnIndex();
        push(getKeyCode("RIGHT_PANEL"));
        assertEquals(0, columnIndex);
        clearColumnIndex();
        push(getKeyCode("LEFT_PANEL"));
        assertEquals(1, columnIndex);
        clearColumnIndex();

        click("#dummy/dummy_col1_1");

        // mark as read/unread
        push(getKeyCode("MARK_AS_READ"));

        push(getKeyCode("MARK_AS_UNREAD"));

        // minimize window
        press(KeyCode.CONTROL).press(KeyCode.N).release(KeyCode.N).release(KeyCode.CONTROL); // run this last
        assertEquals(WindowResizeEvent.EventType.MINIMIZE_WINDOW, windowResizeEventType);<commit_msg>finished adding assertions to KeyboardShortcutsTest<commit_after>package guitests;

import javafx.scene.input.KeyCode;
import org.junit.Test;
import ui.UI;
import ui.components.KeyboardShortcuts;
import ui.issuepanel.IssuePanel;
import util.events.ColumnClickedEventHandler;
import util.events.IssueSelectedEventHandler;
import util.events.testevents.UIComponentFocusEvent;
import util.events.testevents.UIComponentFocusEventHandler;
import util.events.testevents.WindowResizeEvent;
import util.events.testevents.WindowResizeEventHandler;

import static org.junit.Assert.assertEquals;
import static ui.components.KeyboardShortcuts.DOUBLE_PRESS;

public class KeyboardShortcutsTest extends UITest {

    private WindowResizeEvent.EventType windowResizeEventType;
    private UIComponentFocusEvent.EventType uiComponentFocusEventType;
    private int selectedIssueId;
    private int columnIndex;

    @Test
    public void keyboardShortcutsTest() {
        UI.events.registerEvent((WindowResizeEventHandler) e -> windowResizeEventType = e.eventType);
        UI.events.registerEvent((IssueSelectedEventHandler) e -> selectedIssueId = e.id);
        UI.events.registerEvent((UIComponentFocusEventHandler) e -> uiComponentFocusEventType = e.eventType);
        UI.events.registerEvent((ColumnClickedEventHandler) e -> columnIndex = e.columnIndex);
        clearEventType();
        clearSelectedIssueId();
        clearUiComponentFocusEventType();
        clearColumnIndex();

        // maximize
        press(KeyCode.CONTROL).press(KeyCode.X).release(KeyCode.X).release(KeyCode.CONTROL);
        assertEquals(WindowResizeEvent.EventType.MAXIMIZE_WINDOW, windowResizeEventType);
        clearEventType();

        // mid-sized window
        press(KeyCode.CONTROL).press(KeyCode.D).release(KeyCode.D).release(KeyCode.CONTROL);
        assertEquals(WindowResizeEvent.EventType.DEFAULT_SIZE_WINDOW, windowResizeEventType);
        clearEventType();

        // jump from filter box to first issue
        press(KeyCode.CONTROL).press(KeyCode.DOWN).release(KeyCode.DOWN).release(KeyCode.CONTROL);
        assertEquals(10, selectedIssueId);
        clearSelectedIssueId();

        // jump from issue list to filter box
        press(KeyCode.CONTROL).press(KeyCode.UP).release(KeyCode.UP).release(KeyCode.CONTROL);
        assertEquals(UIComponentFocusEvent.EventType.FILTER_BOX, uiComponentFocusEventType);
        clearUiComponentFocusEventType();

        // jump from filter box to first issue
        push(DOUBLE_PRESS).push(DOUBLE_PRESS);
        assertEquals(10, selectedIssueId);
        clearSelectedIssueId();

        // jump from issue list to filter box
        push(DOUBLE_PRESS).push(DOUBLE_PRESS);
        assertEquals(UIComponentFocusEvent.EventType.FILTER_BOX, uiComponentFocusEventType);
        clearUiComponentFocusEventType();

        push(DOUBLE_PRESS).push(DOUBLE_PRESS);

        // jump to last issue
        push(KeyCode.END);
        assertEquals(1, selectedIssueId);
        clearSelectedIssueId();

        // jump to first issue
        push(KeyCode.HOME);
        sleep(1000);
        assertEquals(10, selectedIssueId);
        clearSelectedIssueId();

        push(getKeyCode("DOWN_ISSUE"));
        assertEquals(9, selectedIssueId);
        clearSelectedIssueId();
        push(getKeyCode("DOWN_ISSUE"));
        assertEquals(8, selectedIssueId);
        clearSelectedIssueId();
        push(getKeyCode("UP_ISSUE"));
        assertEquals(9, selectedIssueId);
        clearSelectedIssueId();

        press(KeyCode.CONTROL).press(KeyCode.P).release(KeyCode.P).release(KeyCode.CONTROL);
        push(DOUBLE_PRESS).push(DOUBLE_PRESS);

        push(getKeyCode("RIGHT_PANEL"));
        assertEquals(0, columnIndex);
        clearColumnIndex();
        push(getKeyCode("LEFT_PANEL"));
        assertEquals(1, columnIndex);
        clearColumnIndex();
        push(getKeyCode("RIGHT_PANEL"));
        assertEquals(0, columnIndex);
        clearColumnIndex();
        push(getKeyCode("LEFT_PANEL"));
        assertEquals(1, columnIndex);
        clearColumnIndex();

        click("#dummy/dummy_col1_1");

        // mark as read/unread
        IssuePanel issuePanel = find("#dummy/dummy_col1");
        push(getKeyCode("MARK_AS_READ"));
        assertEquals(true, issuePanel.getSelectedIssue().isCurrentlyRead());
        push(getKeyCode("MARK_AS_UNREAD"));
        assertEquals(false, issuePanel.getSelectedIssue().isCurrentlyRead());

        // minimize window
        press(KeyCode.CONTROL).press(KeyCode.N).release(KeyCode.N).release(KeyCode.CONTROL); // run this last
        assertEquals(WindowResizeEvent.EventType.MINIMIZE_WINDOW, windowResizeEventType);
{'fraction_non_alphanumeric': 0.10364452227208056, 'fraction_numerical': 0.004487249644303382, 'mean_word_length': 3.6268354430379746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3394890', 'n_tokens_mistral': 2481, 'n_tokens_neox': 2460, 'n_words': 391}