-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exclude clientsettings.xml from "last save" search in MekHQ
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
MekHQ/unittests/mekhq/gui/panels/StartupScreenPanelTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package mekhq.gui.panels; | ||
|
||
import megamek.common.preference.PreferenceManager; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import static org.mockito.Mockito.*; | ||
|
||
import java.io.File; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class StartupScreenPanelTest { | ||
File dir; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
dir = mock(File.class); | ||
} | ||
|
||
@Test | ||
void testSaveFilterAllowsValidCampaignSaves(){ | ||
String fileName = "MySave.xml"; | ||
assertTrue(StartupScreenPanel.saveFilter.accept(dir, fileName)); | ||
fileName = "MySave.CPNX"; | ||
assertTrue(StartupScreenPanel.saveFilter.accept(dir, fileName)); | ||
fileName = "20240306T2344 Save Campaign No 666.cpnx.gz"; | ||
assertTrue(StartupScreenPanel.saveFilter.accept(dir, fileName)); | ||
} | ||
|
||
@Test | ||
void testSaveFilterNotAllowClientSettingsXML(){ | ||
String fileName = PreferenceManager.DEFAULT_CFG_FILE_NAME.toLowerCase(); | ||
boolean allowed = StartupScreenPanel.saveFilter.accept(dir, fileName); | ||
assertFalse(allowed); | ||
} | ||
} |