X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fjalview%2Fio%2FFileLoaderTest.java;h=e6d7c4b3de277f2a9e6ab3b266cb853a17260498;hb=3f4b01ff53be81b3a04a9893f9bd2a93dbee0a6f;hp=968901f00c2b877f1d754a5e20b7a17fafdc0ca1;hpb=136c0793b90b72b928c4d77dc109dd5c644e00d3;p=jalview.git diff --git a/test/jalview/io/FileLoaderTest.java b/test/jalview/io/FileLoaderTest.java index 968901f..e6d7c4b 100644 --- a/test/jalview/io/FileLoaderTest.java +++ b/test/jalview/io/FileLoaderTest.java @@ -1,5 +1,29 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.io; +import static org.testng.Assert.assertEquals; + +import jalview.bin.Cache; + import org.junit.Assert; import org.testng.annotations.Test; @@ -19,4 +43,34 @@ public class FileLoaderTest // Data source type expected to be DataSourceType.URL Assert.assertEquals(DataSourceType.URL, fileLoader.protocol); } + + @Test(groups = "Functional") + public void testUpdateRecentlyOpened() + { + // ensure properties file is read-only + Cache.loadProperties("test/jalview/io/testProps.jvprops"); + + String recent = "RECENT_FILE"; + Cache.removeProperty(recent); + + String prop = FileLoader.updateRecentlyOpened("a/b/c", + DataSourceType.FILE); + assertEquals(prop, "a/b/c"); + + prop = FileLoader.updateRecentlyOpened("d/e/f", DataSourceType.FILE); + assertEquals(prop, "d/e/f\ta/b/c"); + + // revisiting a file moves it to the top of the list + prop = FileLoader.updateRecentlyOpened("a/b/c", DataSourceType.FILE); + assertEquals(prop, "a/b/c\td/e/f"); + + // history list is limited to the most recent 11 items + for (int i = 0; i < 20; i++) + { + prop = FileLoader.updateRecentlyOpened(String.format("%d.fa", i), + DataSourceType.FILE); + } + assertEquals(prop, + "19.fa\t18.fa\t17.fa\t16.fa\t15.fa\t14.fa\t13.fa\t12.fa\t11.fa\t10.fa\t9.fa"); + } }