package guitests.guihandles;

import java.util.Arrays;

import guitests.GuiRobot;
import javafx.scene.input.KeyCode;
import javafx.stage.Stage;
import seedu.doit.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);
    }

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

@@ -508,16 +508,21 @@
 tem) -%3E 
+this.
 guiRobot
@@ -685,32 +685,37 @@
 elpWindowHandle(
+this.
 guiRobot, primar
@@ -700,32 +700,37 @@
 (this.guiRobot, 
+this.
 primaryStage);%0A 
@@ -862,16 +862,21 @@
 wHandle(
+this.
 guiRobot
@@ -869,32 +869,37 @@
 (this.guiRobot, 
+this.
 primaryStage);%0A 
@@ -942,32 +942,37 @@
 tor() %7B%0A        
+this.
 guiRobot.push(Ke
@@ -990,16 +990,21 @@
         
+this.
 guiRobot
@@ -1021,11 +1021,329 @@
 );%0A    %7D
+%0A%0A    // @@author A0138909R%0A    private void useCTRLZAccelerator() %7B%0A        this.guiRobot.push(KeyCode.CONTROL, KeyCode.Z);%0A        this.guiRobot.sleep(500);%0A    %7D%0A%0A    private void useCTRLYAccelerator() %7B%0A        this.guiRobot.push(KeyCode.CONTROL, KeyCode.Z);%0A        this.guiRobot.sleep(500);%0A    %7D%0A    // @@author
 %0A%7D%0A

add Control Z and Control Y acelerator