package guitests.guihandles;

import java.util.Arrays;

import guitests.GuiRobot;
import javafx.scene.input.KeyCode;
import javafx.stage.Stage;
import seedu.task.TestApp;

/**
 * Provides a handle to the main menu of the app.
 */
public class MainMenuHandle extends GuiHandle {
    public MainMenuHandle(GuiRobot guiRobot, Stage primaryStage) {
        super(guiRobot, primaryStage, TestApp.APP_TITLE);
    }

    public GuiHandle clickOn(String... menuText) {
        Arrays.stream(menuText).forEach((menuItem) -> guiRobot.clickOn(menuItem));
        return this;
    }

    public HelpWindowHandle openHelpWindowUsingMenu() {
        clickOn("Help", "F1");
        return new HelpWindowHandle(guiRobot, primaryStage);
    }

    public HelpWindowHandle openHelpWindowUsingAccelerator() {
        useF1Accelerator();
        return new HelpWindowHandle(guiRobot, primaryStage);
    }

    public HelpFormatWindowHandle openHelpFormatWindowUsingMenu() {
        clickOn("Summary", "F2");
        return new HelpFormatWindowHandle(guiRobot, primaryStage);
    }

    public HelpFormatWindowHandle openHelpFormatWindowUsingAccelerator() {
        useF2Accelerator();
        return new HelpFormatWindowHandle(guiRobot, primaryStage);
    }

    private void useF1Accelerator() {
        guiRobot.push(KeyCode.F1);
        guiRobot.sleep(500);
    }

    private void useF2Accelerator() {
        guiRobot.push(KeyCode.F2);
        guiRobot.sleep(500);
    }
}

@@ -963,16 +963,24 @@
 clickOn(
+%22Help%22, 
 %22Summary

fix test case again