mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Don't use FileUtils.getBriarDirectory() in tests.
This commit is contained in:
@@ -47,6 +47,14 @@ public class TestUtils {
|
||||
throw new RuntimeException("Could not find build directory");
|
||||
}
|
||||
|
||||
public static File getFontDirectory() {
|
||||
File f = new File("i18n");
|
||||
if(f.exists() && f.isDirectory()) return f;
|
||||
f = new File("../i18n");
|
||||
if(f.exists() && f.isDirectory()) return f;
|
||||
throw new RuntimeException("Could not find font directory");
|
||||
}
|
||||
|
||||
public static byte[] getRandomId() {
|
||||
byte[] b = new byte[UniqueId.LENGTH];
|
||||
random.nextBytes(b);
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
package net.sf.briar.i18n;
|
||||
import java.awt.Font;
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.briar.TestUtils;
|
||||
import net.sf.briar.api.i18n.FontManager;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class FontManagerTest extends TestCase {
|
||||
|
||||
private final File fontDir = TestUtils.getFontDirectory();
|
||||
|
||||
@Test
|
||||
public void testBundledFontsAreLoaded() {
|
||||
FontManager fontManager = new FontManagerImpl();
|
||||
fontManager.initialize(Locale.UK);
|
||||
fontManager.initialize(Locale.UK, fontDir);
|
||||
|
||||
Font font = fontManager.getFontForLanguage("en"); // English
|
||||
assertEquals(12, font.getSize());
|
||||
@@ -29,7 +33,7 @@ public class FontManagerTest extends TestCase {
|
||||
@Test
|
||||
public void testInternationalCharactersCanBeDisplayed() {
|
||||
FontManager fontManager = new FontManagerImpl();
|
||||
fontManager.initialize(Locale.UK);
|
||||
fontManager.initialize(Locale.UK, fontDir);
|
||||
|
||||
Font font = fontManager.getFontForLanguage("en"); // English
|
||||
assertTrue(font.canDisplay('a'));
|
||||
@@ -53,7 +57,7 @@ public class FontManagerTest extends TestCase {
|
||||
@Test
|
||||
public void testSetAndGetUiFont() {
|
||||
FontManager fontManager = new FontManagerImpl();
|
||||
fontManager.initialize(Locale.UK);
|
||||
fontManager.initialize(Locale.UK, fontDir);
|
||||
Font font = fontManager.getUiFont();
|
||||
assertEquals(12, font.getSize());
|
||||
|
||||
|
||||
@@ -18,25 +18,21 @@ import org.junit.Test;
|
||||
|
||||
public class I18nTest extends TestCase {
|
||||
|
||||
final File base =
|
||||
private final File base =
|
||||
new File(TestUtils.getBuildDirectory(), "i18n.properties");
|
||||
final File french =
|
||||
private final File french =
|
||||
new File(TestUtils.getBuildDirectory(), "i18n_fr.properties");
|
||||
final File testDir = TestUtils.getTestDirectory();
|
||||
private final File testDir = TestUtils.getTestDirectory();
|
||||
|
||||
FontManager fontManager = null;
|
||||
I18n i18n = null;
|
||||
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
TestUtils.createFile(base,
|
||||
"FOO=foo\r\n" +
|
||||
"BAR=bar\r\n");
|
||||
TestUtils.createFile(french,
|
||||
"FOO=le foo\r\n" +
|
||||
"BAR=la bar\r\n");
|
||||
TestUtils.createFile(base, "FOO=foo\r\nBAR=bar\r\n");
|
||||
TestUtils.createFile(french, "FOO=le foo\r\nBAR=la bar\r\n");
|
||||
fontManager = new FontManagerImpl();
|
||||
fontManager.initialize(Locale.UK);
|
||||
fontManager.initialize(Locale.UK, TestUtils.getFontDirectory());
|
||||
i18n = new I18nImpl(fontManager);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user