From e1a6d09b6fd715589aaa74201afdd72f04be3791 Mon Sep 17 00:00:00 2001 From: Nick Stolbov Date: Thu, 13 Jan 2022 14:48:14 +0100 Subject: [PATCH] Added inRootMenu function to MenuManager. --- src/main/java/Application/MenuManager.java | 3 +++ src/test/java/Application/MenuManagerTest.java | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/Application/MenuManager.java b/src/main/java/Application/MenuManager.java index 54402cc..31979c8 100644 --- a/src/main/java/Application/MenuManager.java +++ b/src/main/java/Application/MenuManager.java @@ -18,5 +18,8 @@ public class MenuManager { return this.currentMenu; } + public boolean inRootMenu(){ + return this.currentMenu.equals(this.rootMenu); + } } diff --git a/src/test/java/Application/MenuManagerTest.java b/src/test/java/Application/MenuManagerTest.java index 4355748..87bd8e3 100644 --- a/src/test/java/Application/MenuManagerTest.java +++ b/src/test/java/Application/MenuManagerTest.java @@ -35,4 +35,11 @@ class MenuManagerTest { mm.select(0); assertEquals(mm.getCurrentMenu(), rootMenu.getMenu(0).getMenu(0)); } + + @Test + void testIsRootMenuFunction(){ + assertTrue(mm.inRootMenu()); + mm.select(0); + assertFalse(mm.inRootMenu()); + } } \ No newline at end of file