diff --git a/DS4WindowsTests/ProfileMigrationTests.cs b/DS4WindowsTests/ProfileMigrationTests.cs
index c724e7698..0730244f2 100644
--- a/DS4WindowsTests/ProfileMigrationTests.cs
+++ b/DS4WindowsTests/ProfileMigrationTests.cs
@@ -17,9 +17,11 @@ You should have received a copy of the GNU General Public License
*/
+using System.Text;
+using System.Xml;
+using System.Xml.Serialization;
using DS4Windows;
using DS4WinWPF.DS4Control.DTOXml;
-using System.Xml.Serialization;
namespace DS4WindowsTests
{
@@ -28,12 +30,12 @@ public class ProfileMigrationTests
{
private const int EXPECTED_JAYS_MIGRATED_VERSION = 5;
private string ds4winJays2KingsOldProfile = string.Empty;
+ private string ds4winJays2KingsExpectedMigratedProfile = string.Empty;
public ProfileMigrationTests()
{
#region TempDS4WinProfileXML
ds4winJays2KingsOldProfile = @"
-
True
@@ -79,6 +81,271 @@ public ProfileMigrationTests()
";
+
+ ds4winJays2KingsExpectedMigratedProfile = @"
+
+
+ True
+ 0
+ True
+ 0,0,255
+ 100
+ 0
+ None
+ False
+ 0
+ 0
+ 100
+ 0,0,0
+ 0,0,0
+ 0,0,0
+ True
+ False
+ 0
+ False
+ 0
+ 0
+ 0
+ 0
+ False
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 25
+ 0
+ 0
+ 0
+ 10
+ 10
+ 20
+ 20
+ 100
+ 100
+ 100
+ 100
+ 100
+ 100
+ False
+ False
+ Radial
+ Radial
+
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+ 0
+ 0
+ 0
+ 0
+ 75
+ 75
+ False
+ False
+
+ False
+ 4
+ 0.2
+ 0.01
+ 0.2
+ 1
+
+
+ False
+ 4
+ 0.2
+ 0.01
+ 0.2
+ 1
+
+ 0.25
+ 0.25
+ 100
+ 100
+ 0
+ 0
+ 1|1|1|1|1|1
+ 0
+ True
+ 0
+
+ False
+ False
+ None
+
+ and
+ None
+ 360
+ 0
+
+ False
+ 0.1
+ 0.1
+
+ -1
+ 100
+ 100
+ 0
+ False
+
+ -1
+ and
+ True
+ False
+
+
+ False
+ one-euro
+ 50
+ 0.4
+ 0.7
+
+ 0
+ 10
+ 1
+ False
+ True
+ Controls
+ -1
+ and
+ True
+ 0
+ 30
+ 830
+ None
+ None
+ 0.4
+ 0.4
+ 0
+ False
+ 100
+ False
+ 100
+ False
+
+ False
+ one-euro
+ 50
+ 0.4
+ 0.7
+
+
+ 80
+ 80
+ -1
+ and
+ True
+ Yaw
+ 0
+
+ 4
+ linear
+ linear
+ False
+ False
+ 5
+ 5
+ False
+ False
+ 135
+ 135
+ 50
+ 50
+ Controls
+ Controls
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+
+ Accurate
+ False
+ 0
+
+
+ linear
+ Disabled
+ Disabled
+ 0
+ 0
+ None
+ None
+ linear
+ linear
+ linear
+ False
+ 10
+ 0
+ 1
+
+ 90
+ 90
+ False
+
+
+ 0
+ 8
+ RightStick
+ XY
+ 0.4
+ 0.4
+ 0
+ 100
+ False
+ 100
+ Linear
+ 0
+
+ None
+ 0.8
+ 0.7
+
+
+ Click
+
+ 1
+ 1
+ 0.5
+ 0.5
+ 0
+ True
+
+ X360
+ Disconnect Controller
+
+
+";
#endregion
}
@@ -134,6 +401,50 @@ public void CheckJaysProfileRead()
DS4Color profileColor = tempStore.lightbarSettingInfo[0].ds4winSettings.m_Led;
Assert.AreEqual("0,0,255",
$"{profileColor.red},{profileColor.green},{profileColor.blue}");
+
+ // Check that profile migration worked as expected
+ string testMigratedProfileStr = ObtainConvertedJaysXML(tempStore);
+ Assert.AreEqual(ds4winJays2KingsExpectedMigratedProfile, testMigratedProfileStr);
+ }
+
+ private string ObtainConvertedJaysXML(BackingStore tempStore)
+ {
+ string testStr = string.Empty;
+ XmlSerializer serializer = new XmlSerializer(typeof(ProfileDTO),
+ ProfileDTO.GetAttributeOverrides());
+ using (Utf8StringWriter strWriter = new Utf8StringWriter())
+ {
+ using XmlWriter xmlWriter = XmlWriter.Create(strWriter,
+ new XmlWriterSettings()
+ {
+ Encoding = Encoding.UTF8,
+ Indent = true,
+ });
+
+ // Write header explicitly
+ //xmlWriter.WriteStartDocument();
+ //xmlWriter.WriteComment(string.Format(" DS4Windows Configuration Data. {0} ", DateTime.Now));
+ //xmlWriter.WriteComment(string.Format(" Made with DS4Windows version {0} ", Global.exeversion));
+ xmlWriter.WriteWhitespace("\r\n");
+ xmlWriter.WriteWhitespace("\r\n");
+
+ // Write root element and children
+ ProfileDTO dto = new ProfileDTO();
+ dto.DeviceIndex = 0; // Use default slot
+ dto.SerializeAppAttrs = false;
+ dto.MapFrom(tempStore);
+ // Omit xmlns:xsi and xmlns:xsd from output
+ serializer.Serialize(xmlWriter, dto,
+ new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty }));
+ xmlWriter.Flush();
+ xmlWriter.Close();
+
+ testStr = strWriter.ToString();
+ //Trace.WriteLine("TEST OUTPUT");
+ //Trace.WriteLine(testStr);
+ }
+
+ return testStr;
}
}
}