From 71b1bd3fab593ff9fcbd678ac527ce921e4b2122 Mon Sep 17 00:00:00 2001 From: retgal Date: Wed, 28 Feb 2024 23:35:14 +0100 Subject: [PATCH] Add keyboard dialog, closes #110 --- .../mpo/dayon/assistant/gui/Assistant.java | 4 +-- .../dayon/assistant/gui/AssistantFrame.java | 7 ++++- .../network/NetworkAssistantEngine.java | 10 +++---- .../NetworkAssistantEngineListener.java | 2 +- .../dayon/common/network/NetworkSender.java | 4 ++- .../network/message/NetworkHelloMessage.java | 26 ++++++++++++++----- src/main/resources/Babylon.properties | 4 +++ src/main/resources/Babylon_de.properties | 6 ++++- src/main/resources/Babylon_es.properties | 6 ++++- src/main/resources/Babylon_fr.properties | 6 ++++- src/main/resources/Babylon_it.properties | 6 ++++- src/main/resources/Babylon_ru.properties | 6 ++++- src/main/resources/Babylon_sv.properties | 6 ++++- src/main/resources/Babylon_tr.properties | 6 ++++- src/main/resources/Babylon_zh.properties | 6 ++++- .../common/network/NetworkSenderTest.java | 16 ++++-------- .../message/NetworkHelloMessageTest.java | 11 +++++--- 17 files changed, 93 insertions(+), 39 deletions(-) diff --git a/src/main/java/mpo/dayon/assistant/gui/Assistant.java b/src/main/java/mpo/dayon/assistant/gui/Assistant.java index 5f8cb9c7..1bd4ba27 100644 --- a/src/main/java/mpo/dayon/assistant/gui/Assistant.java +++ b/src/main/java/mpo/dayon/assistant/gui/Assistant.java @@ -837,11 +837,11 @@ public boolean onAccepted(Socket connection) { * Should not block as called from the network receiving thread (!) */ @Override - public void onConnected(Socket connection, char osId) { + public void onConnected(Socket connection, char osId, String inputLocale) { sendCaptureConfiguration(captureEngineConfiguration); sendCompressorConfiguration(compressorEngineConfiguration); frame.resetCanvas(); - frame.onSessionStarted(osId); + frame.onSessionStarted(osId, inputLocale); } @Override diff --git a/src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java b/src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java index cd7cd9dd..7d39407c 100644 --- a/src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java +++ b/src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java @@ -13,6 +13,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; +import java.awt.im.InputContext; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.Socket; @@ -474,7 +475,7 @@ void onClipboardReceived() { enableTransferControls(); } - void onSessionStarted(char osId) { + void onSessionStarted(char osId, String inputLocale) { this.osId = osId; if (osId == 'm') { windowsKeyToggleButton.setIcon(getOrCreateIcon(ImageNames.CMD)); @@ -483,6 +484,10 @@ void onSessionStarted(char osId) { windowsKeyToggleButton.setIcon(getOrCreateIcon(ImageNames.WIN)); windowsKeyToggleButton.setToolTipText(translate("send.winKey")); } + if (!inputLocale.isEmpty() && !inputLocale.equals(InputContext.getInstance().getLocale().toString())) { + String infoMessage = format("%s\n%s\n%s", translate("keyboardlayout.msg1", inputLocale), translate("keyboardlayout.msg2"), translate("keyboardlayout.msg3")); + JOptionPane.showMessageDialog(this, infoMessage, "", JOptionPane.INFORMATION_MESSAGE); + } long sessionStartTime = Instant.now().getEpochSecond(); sessionTimer = new Timer(1000, e -> { final long seconds = Instant.now().getEpochSecond() - sessionStartTime; diff --git a/src/main/java/mpo/dayon/assistant/network/NetworkAssistantEngine.java b/src/main/java/mpo/dayon/assistant/network/NetworkAssistantEngine.java index 6bcd6c64..53a4e997 100644 --- a/src/main/java/mpo/dayon/assistant/network/NetworkAssistantEngine.java +++ b/src/main/java/mpo/dayon/assistant/network/NetworkAssistantEngine.java @@ -253,7 +253,7 @@ private boolean processIntroduced(NetworkMessageType type, ObjectInputStream in) } } - private boolean processUnIntroduced(NetworkMessageType type, ObjectInputStream in) throws IOException { + private boolean processUnIntroduced(NetworkMessageType type, ObjectInputStream in) throws IOException, ClassNotFoundException { switch (type) { case HELLO: fireOnConnected(connection, introduce(in)); @@ -275,14 +275,14 @@ private boolean processUnIntroduced(NetworkMessageType type, ObjectInputStream i } } - private char introduce(ObjectInputStream in) throws IOException { + private NetworkHelloMessage introduce(ObjectInputStream in) throws IOException, ClassNotFoundException { final NetworkHelloMessage hello = NetworkHelloMessage.unmarshall(in); fireOnByteReceived(1 + hello.getWireSize()); // +1 : magic number (byte) if (!isCompatibleVersion(hello.getMajor(), hello.getMinor(), Version.get())) { Log.error(format("Incompatible assisted version: %d.%d", hello.getMajor(), hello.getMinor())); throw new IOException("version.wrong"); } - return hello.getOsId(); + return hello; } /** @@ -351,8 +351,8 @@ private boolean fireOnAccepted(Socket connection) { return listeners.getListeners().stream().allMatch(listener -> listener.onAccepted(connection)); } - private void fireOnConnected(Socket connection, char osId) { - listeners.getListeners().forEach(listener -> listener.onConnected(connection, osId)); + private void fireOnConnected(Socket connection, NetworkHelloMessage hello) { + listeners.getListeners().forEach(listener -> listener.onConnected(connection, hello.getOsId(), hello.getInputLocale())); } private void fireOnByteReceived(int count) { diff --git a/src/main/java/mpo/dayon/assistant/network/NetworkAssistantEngineListener.java b/src/main/java/mpo/dayon/assistant/network/NetworkAssistantEngineListener.java index b641b23b..f131aedd 100644 --- a/src/main/java/mpo/dayon/assistant/network/NetworkAssistantEngineListener.java +++ b/src/main/java/mpo/dayon/assistant/network/NetworkAssistantEngineListener.java @@ -21,7 +21,7 @@ public interface NetworkAssistantEngineListener extends Listener { /** * Should not block as called from the network receiving thread (!) */ - void onConnected(Socket connection, char osId); + void onConnected(Socket connection, char osId, String inputLocale); /** * Should not block as called from the network receiving thread (!) diff --git a/src/main/java/mpo/dayon/common/network/NetworkSender.java b/src/main/java/mpo/dayon/common/network/NetworkSender.java index 9b7fc6de..86609ca1 100644 --- a/src/main/java/mpo/dayon/common/network/NetworkSender.java +++ b/src/main/java/mpo/dayon/common/network/NetworkSender.java @@ -1,6 +1,7 @@ package mpo.dayon.common.network; import java.awt.Point; +import java.awt.im.InputContext; import java.io.File; import java.io.IOException; import java.io.ObjectOutputStream; @@ -61,7 +62,8 @@ public void cancel() { */ public void sendHello(char osId) { final Version version = Version.get(); - send(true, new NetworkHelloMessage(version.getMajor(), version.getMinor(), osId)); + final String inputLocale = InputContext.getInstance().getLocale().toString(); + send(true, new NetworkHelloMessage(version.getMajor(), version.getMinor(), osId, inputLocale)); } /** diff --git a/src/main/java/mpo/dayon/common/network/message/NetworkHelloMessage.java b/src/main/java/mpo/dayon/common/network/message/NetworkHelloMessage.java index 5e70b9c8..965dbbc9 100644 --- a/src/main/java/mpo/dayon/common/network/message/NetworkHelloMessage.java +++ b/src/main/java/mpo/dayon/common/network/message/NetworkHelloMessage.java @@ -9,11 +9,14 @@ public class NetworkHelloMessage extends NetworkMessage { private final char osId; - public NetworkHelloMessage(int major, int minor, char osId) { + private final String inputLocale; + + public NetworkHelloMessage(int major, int minor, char osId, String inputLocale) { this.major = major; this.minor = minor; this.osId = osId; - } + this.inputLocale = inputLocale; + } @Override public NetworkMessageType getType() { @@ -32,13 +35,17 @@ public char getOsId() { return osId; } + public String getInputLocale() { + return inputLocale; + } + /** * Take into account some extra-info sent over the network with the actual * payload ... */ @Override public int getWireSize() { - return 11; // type (byte) + major (int) + minor (int) + osId (char) + return 11 + inputLocale.length(); // (type (byte) + major (int) + minor (int) + osId (char)) + localeId (String } @Override @@ -47,16 +54,21 @@ public void marshall(ObjectOutputStream out) throws IOException { out.writeInt(major); out.writeInt(minor); out.writeChar(osId); + out.writeUTF(inputLocale); } - public static NetworkHelloMessage unmarshall(ObjectInputStream in) throws IOException { + public static NetworkHelloMessage unmarshall(ObjectInputStream in) throws IOException, ClassNotFoundException { final int major = in.readInt(); final int minor = in.readInt(); - char osId = major > 13 || (major == 13 && minor > 0) || major == 0 ? in.readChar() : 'x'; - return new NetworkHelloMessage(major, minor, osId); + if (major > 13 || (major == 13 && minor > 0) || major == 0 ) { + char osId = in.readChar(); + String localeId = in.readUTF(); + return new NetworkHelloMessage(major, minor, osId, localeId); + } + return new NetworkHelloMessage(major, minor, 'x', ""); } public String toString() { - return String.format("[major:%d] [minor:%s] [osId:%c]", major, minor, osId); + return String.format("[major:%d] [minor:%d] [osId:%c] [inputLocale:%s]", major, minor, osId, inputLocale); } } \ No newline at end of file diff --git a/src/main/resources/Babylon.properties b/src/main/resources/Babylon.properties index 17342b40..eb89f421 100644 --- a/src/main/resources/Babylon.properties +++ b/src/main/resources/Babylon.properties @@ -190,3 +190,7 @@ compatibility.mode.info = Please consider updating Assisted to the latest versio changeLanguage = Change language startChat = Start a chat + +keyboardlayout.msg1 = The assisted currently uses a different keyboard layout: %s +keyboardlayout.msg2 = This can lead to problems, especially when entering special characters. +keyboardlayout.msg3 = If you experience problems, please ensure you are using the same on both computers. \ No newline at end of file diff --git a/src/main/resources/Babylon_de.properties b/src/main/resources/Babylon_de.properties index cfcee933..eb0920b4 100644 --- a/src/main/resources/Babylon_de.properties +++ b/src/main/resources/Babylon_de.properties @@ -189,4 +189,8 @@ compatibility.mode.active = Kompatibilit\u00E4tsmodus aktiv compatibility.mode.info = Um Sicherheitsrisiken zu minimieren, aktualisieren Sie doch bitte den Assistierten auf die neuste Version. changeLanguage = Sprache \u00E4ndern -startChat = Chat starten \ No newline at end of file +startChat = Chat starten + +keyboardlayout.msg1 = Der Assistent verwendet derzeit eine andere Tastaturbelegung: %s +keyboardlayout.msg2 = Dies kann insbesondere bei der Eingabe von Sonderzeichen zu Problemen f\u00FChren. +keyboardlayout.msg3 = Sollten Probleme auftreten, stellen Sie bitte sicher,\ndass Sie auf beiden Computern die gleiche Tastaturbelegung verwenden. \ No newline at end of file diff --git a/src/main/resources/Babylon_es.properties b/src/main/resources/Babylon_es.properties index 125903d5..bac26454 100644 --- a/src/main/resources/Babylon_es.properties +++ b/src/main/resources/Babylon_es.properties @@ -189,4 +189,8 @@ compatibility.mode.active = Modo de compatibilidad activo compatibility.mode.info = Por favor, considere actualizar Assisted a la \u00FAltima versi\u00F3n para minimizar los riesgos. changeLanguage = Cambiar el idioma -startChat = Iniciar un chat \ No newline at end of file +startChat = Iniciar un chat + +keyboardlayout.msg1 = Actualmente, el asistido utiliza una distribuci\u00F3n de teclado diferente: %s +keyboardlayout.msg2 = Esto puede ocasionar problemas, especialmente al introducir caracteres especiales. +keyboardlayout.msg3 = Si se producen problemas, aseg\u00FArese de que utiliza la misma distribuci\u00F3n de teclado en ambos ordenadores. \ No newline at end of file diff --git a/src/main/resources/Babylon_fr.properties b/src/main/resources/Babylon_fr.properties index 01ec002c..4bed7134 100644 --- a/src/main/resources/Babylon_fr.properties +++ b/src/main/resources/Babylon_fr.properties @@ -189,4 +189,8 @@ compatibility.mode.active = Mode de compatibilit\u00E9 actif compatibility.mode.info = Veuillez consid\u00E9rer la mise \u00E0 jour de l'assist\u00E9 vers la derni\u00E8re version afin de minimiser les risques. changeLanguage = Changer la langue -startChat = Commencer un chat \ No newline at end of file +startChat = Commencer un chat + +keyboardlayout.msg1 = L'assist\u00E9 utilise actuellement une autre disposition de clavier : %s +keyboardlayout.msg2 = Cela peut entra\u00EEner des probl\u00E8mes, notamment lors de la saisie de caract\u00E8res sp\u00E9ciaux. +keyboardlayout.msg3 = En cas de probl\u00E8me, assurez-vous que vous utilisez la m\u00EAme disposition de clavier sur les deux ordinateurs. \ No newline at end of file diff --git a/src/main/resources/Babylon_it.properties b/src/main/resources/Babylon_it.properties index 7e2797e0..c7d057b7 100644 --- a/src/main/resources/Babylon_it.properties +++ b/src/main/resources/Babylon_it.properties @@ -189,4 +189,8 @@ compatibility.mode.active = Modalit\u00E0 di compatibilit\u00E0 attiva compatibility.mode.info = Si consiglia di aggiornare assistito alla versione pi\u00F9 recente per ridurre al minimo i rischi. changeLanguage = Cambiare la lingua -startChat = Iniziare una chat \ No newline at end of file +startChat = Iniziare una chat + +keyboardlayout.msg1 = L'assistito utilizza attualmente un layout di tastiera diverso: %s +keyboardlayout.msg2 = Questo pu\u00F2 causare problemi, soprattutto nell'inserimento di caratteri speciali. +keyboardlayout.msg3 = In caso di problemi, accertarsi di utilizzare lo stesso layout di tastiera su entrambi i computer. \ No newline at end of file diff --git a/src/main/resources/Babylon_ru.properties b/src/main/resources/Babylon_ru.properties index 7bb17f7b..8349cc92 100644 --- a/src/main/resources/Babylon_ru.properties +++ b/src/main/resources/Babylon_ru.properties @@ -189,4 +189,8 @@ compatibility.mode.active = \u0420\u0435\u0436\u0438\u043C \u0441\u043E\u0432\u0 compatibility.mode.info = \u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u043E\u0431\u043D\u043E\u0432\u0438\u0442\u0435 \u041F\u043E\u043C\u043E\u0433\u0430\u043B \u0434\u043E \u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438, \u0447\u0442\u043E\u0431\u044B \u043C\u0438\u043D\u0438\u043C\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0440\u0438\u0441\u043A\u0438. changeLanguage = \u0438\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u044F\u0437\u044B\u043A -startChat = \u043D\u0430\u0447\u0430\u0442\u044C \u0447\u0430\u0442 \ No newline at end of file +startChat = \u043D\u0430\u0447\u0430\u0442\u044C \u0447\u0430\u0442 + +keyboardlayout.msg1 = \u0412 \u043D\u0430\u0441\u0442\u043E\u044F\u0449\u0435\u0435 \u0432\u0440\u0435\u043C\u044F \u041F\u043E\u043C\u043E\u0433\u0430\u043B \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u0442 \u0434\u0440\u0443\u0433\u0443\u044E \u0440\u0430\u0441\u043A\u043B\u0430\u0434\u043A\u0443 \u043A\u043B\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044B: %s +keyboardlayout.msg2 = \u042D\u0442\u043E \u043C\u043E\u0436\u0435\u0442 \u043F\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043A \u043F\u0440\u043E\u0431\u043B\u0435\u043C\u0430\u043C, \u043E\u0441\u043E\u0431\u0435\u043D\u043D\u043E \u043F\u0440\u0438 \u0432\u0432\u043E\u0434\u0435 \u0441\u043F\u0435\u0446\u0438\u0430\u043B\u044C\u043D\u044B\u0445 \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432. +keyboardlayout.msg3 = \u0415\u0441\u043B\u0438 \u0432\u043E\u0437\u043D\u0438\u043A\u043B\u0438 \u043F\u0440\u043E\u0431\u043B\u0435\u043C\u044B, \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044C, \u0447\u0442\u043E \u043D\u0430 \u043E\u0431\u043E\u0438\u0445 \u043A\u043E\u043C\u043F\u044C\u044E\u0442\u0435\u0440\u0430\u0445 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u0442\u0441\u044F \u043E\u0434\u0438\u043D\u0430\u043A\u043E\u0432\u0430\u044F \u0440\u0430\u0441\u043A\u043B\u0430\u0434\u043A\u0430 \u043A\u043B\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044B. \ No newline at end of file diff --git a/src/main/resources/Babylon_sv.properties b/src/main/resources/Babylon_sv.properties index 9af42ce4..215e65d9 100644 --- a/src/main/resources/Babylon_sv.properties +++ b/src/main/resources/Babylon_sv.properties @@ -189,4 +189,8 @@ compatibility.mode.active = Kompatibiltetsl\u00E4ge aktiverat compatibility.mode.info = V\u00E4nligen uppdatera Hj\u00E4lptagare till den senaste versionen f\u00F6r att minimera risker. changeLanguage = V\u00E4xla spr\u00E5kl\u00E4ge -startChat = Starta en chatt \ No newline at end of file +startChat = Starta en chatt + +keyboardlayout.msg1 = Hj\u00E4lptagare anv\u00E4nder f\u00F6r n\u00E4rvarande en annan tangentbordslayout: %s +keyboardlayout.msg2 = Detta kan leda till problem, s\u00E4rskilt vid inmatning av specialtecken. +keyboardlayout.msg3 = Om du upplever problem, kontrollera att du anv\u00E4nder samma tangentbord p\u00E5 b\u00E5da datorerna. \ No newline at end of file diff --git a/src/main/resources/Babylon_tr.properties b/src/main/resources/Babylon_tr.properties index 3a4fe5f0..dc481eef 100644 --- a/src/main/resources/Babylon_tr.properties +++ b/src/main/resources/Babylon_tr.properties @@ -189,4 +189,8 @@ compatibility.mode.active = Uyumluluk modu etkin compatibility.mode.info = Riskleri en aza indirmek i\u00E7in l\u00FCtfen yard\u0131ml\u0131 en son s\u00FCr\u00FCme g\u00FCncellemeyi d\u00FC\u015F\u00FCn\u00FCn. changeLanguage = Dili de\u011Fi\u015Ftir -startChat = Sohbet ba\u015Flat \ No newline at end of file +startChat = Sohbet ba\u015Flat + +keyboardlayout.msg1 = Yard\u0131ml\u0131 \u015Fu anda farkl\u0131 bir klavye d\u00FCzeni kullan\u0131yor: %s +keyboardlayout.msg2 = Bu, \u00F6zellikle \u00F6zel karakterleri girerken sorunlara neden olabilir. +keyboardlayout.msg3 = Sorun ya\u015Farsan\u0131z, l\u00FCtfen her iki bilgisayarda da ayn\u0131 klavyeyi kulland\u0131\u011F\u0131n\u0131zdan emin olun. \ No newline at end of file diff --git a/src/main/resources/Babylon_zh.properties b/src/main/resources/Babylon_zh.properties index f6e70de9..7c644383 100644 --- a/src/main/resources/Babylon_zh.properties +++ b/src/main/resources/Babylon_zh.properties @@ -293,4 +293,8 @@ compatibility.mode.active = \u517C\u5BB9\u6A21\u5F0F\u5DF2\u6FC0\u6D3B compatibility.mode.info = \u8BF7\u8003\u8651\u5C06\u60A8\u7684\u540C\u884C\u7CFB\u7EDF\u5347\u7EA7\u5230\u6700\u65B0\u7248\u672C\uFF0C\u4EE5\u6700\u5927\u9650\u5EA6\u5730\u964D\u4F4E\u98CE\u9669\u3002 changeLanguage = \u6539\u53D8\u8BED\u8A00 -startChat = \u5F00\u59CB\u804A\u5929 \ No newline at end of file +startChat = \u5F00\u59CB\u804A\u5929 + +Keyboardlayout.msg1 = Assisted - \u7528\u6237\u7AEF\u5F53\u524D\u4F7F\u7528\u4E0D\u540C\u7684\u952E\u76D8\u5E03\u5C40\uFF1A%s +Keyboardlayout.msg2 = \u8FD9\u53EF\u80FD\u4F1A\u5BFC\u81F4\u95EE\u9898\uFF0C\u5C24\u5176\u662F\u5728\u8F93\u5165\u7279\u6B8A\u5B57\u7B26\u65F6\u3002 +Keyboardlayout.msg3 = \u5982\u679C\u60A8\u9047\u5230\u95EE\u9898\uFF0C\u8BF7\u786E\u4FDD\u60A8\u5728\u4E24\u53F0\u8BA1\u7B97\u673A\u4E0A\u4F7F\u7528\u76F8\u540C\u7684\u8BBE\u7F6E\u3002 \ No newline at end of file diff --git a/src/test/java/mpo/dayon/common/network/NetworkSenderTest.java b/src/test/java/mpo/dayon/common/network/NetworkSenderTest.java index b7f7c189..1147cefe 100644 --- a/src/test/java/mpo/dayon/common/network/NetworkSenderTest.java +++ b/src/test/java/mpo/dayon/common/network/NetworkSenderTest.java @@ -15,6 +15,7 @@ import org.mockito.Mockito; import java.awt.*; +import java.awt.im.InputContext; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.List; @@ -44,23 +45,16 @@ void init() { @Test void sendHello() throws IOException { // given - final int major = 0; - final int minor = 0; final char osId = 'l'; + final String inputLocale = InputContext.getInstance().getLocale().toString(); // when sender.sendHello(osId); // then verify(outMock, timeout(50)).writeByte(MAGIC_NUMBER); verify(outMock).write(NetworkMessageType.HELLO.ordinal()); - verify(outMock, times(2)).writeInt(valueCaptor.capture()); - verify(outMock).writeChar(valueCaptor.capture()); - final List capturedValues = valueCaptor.getAllValues(); - int first = capturedValues.get(0); - int second = capturedValues.get(1); - int last = capturedValues.get(capturedValues.size() - 1); - assertEquals(major, first); - assertEquals(minor, second); - assertEquals(osId, last); + verify(outMock, times(2)).writeInt(anyInt()); + verify(outMock).writeChar(osId); + verify(outMock).writeUTF(inputLocale); } @Test diff --git a/src/test/java/mpo/dayon/common/network/message/NetworkHelloMessageTest.java b/src/test/java/mpo/dayon/common/network/message/NetworkHelloMessageTest.java index e899f6d2..a0ca35a4 100644 --- a/src/test/java/mpo/dayon/common/network/message/NetworkHelloMessageTest.java +++ b/src/test/java/mpo/dayon/common/network/message/NetworkHelloMessageTest.java @@ -16,19 +16,21 @@ void testHelloMessage() { final int major = 0; final int minor = 0; final char osId = 'l'; + final String inputLocale = "de_CH"; // when - final NetworkHelloMessage message = new NetworkHelloMessage(major, minor, osId); + final NetworkHelloMessage message = new NetworkHelloMessage(major, minor, osId, inputLocale); // then assertEquals(major, message.getMajor()); assertEquals(minor, message.getMinor()); assertEquals(osId, message.getOsId()); + assertEquals(inputLocale, message.getInputLocale()); } @ParameterizedTest @CsvSource({ "13, 0", "12, 0", "11, 0" }) - void unmarshallHelloMessageFromLegacyVersion(int major, int minor) throws IOException { + void unmarshallHelloMessageFromLegacyVersion(int major, int minor) throws IOException, ClassNotFoundException { // given String fileName = "tmp"; ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream(fileName)); @@ -45,19 +47,21 @@ void unmarshallHelloMessageFromLegacyVersion(int major, int minor) throws IOExce assertEquals(major, message.getMajor()); assertEquals(minor, message.getMinor()); assertEquals('x', message.getOsId(), "Should use default value without trying to read osId from the stream"); + assertEquals("", message.getInputLocale(), "Should use default value without trying to read inputLocale from the stream"); } @ParameterizedTest @CsvSource({ "13, 1, l", "0, 0, w" }) - void unmarshallHelloMessageFromSupportedVersion(int major, int minor, char osId) throws IOException { + void unmarshallHelloMessageFromSupportedVersion(int major, int minor, char osId) throws IOException, ClassNotFoundException { // given String fileName = "tmp"; ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream(fileName)); output.writeInt(major); output.writeInt(minor); output.writeChar(osId); + output.writeUTF("de_CH"); output.close(); ObjectInputStream objStream = new ObjectInputStream(new FileInputStream(fileName)); @@ -69,5 +73,6 @@ void unmarshallHelloMessageFromSupportedVersion(int major, int minor, char osId) assertEquals(major, message.getMajor()); assertEquals(minor, message.getMinor()); assertEquals(osId, message.getOsId()); + assertEquals("de_CH", message.getInputLocale()); } } \ No newline at end of file