Skip to content

Commit

Permalink
Merge pull request #6 from rogermiranda1000/fix/pico-10.1-config-read
Browse files Browse the repository at this point in the history
Fix/pico 10.1 config read
  • Loading branch information
rogermiranda1000 committed May 18, 2024
2 parents 996b9ee + 54bd4f4 commit 4ecae6d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 44 deletions.
49 changes: 48 additions & 1 deletion PicoStreamingAssistantFTTests/PicoConnectConfigCheckerShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,58 @@ public static Mock<ILogger> GetLoggerMock(List<string> errors)
return logger;
}

public static string GetSettingsJson(int transferProtocol = 0)
public static string GetLegacySettingsJson(int transferProtocol = 0)
{
return "{\"video\":{\"resolution\":\"ultra\",\"bitrate\":{\"smooth\":20,\"sd\":60,\"hd\":100,\"ultra\":150},\"autoBitrate\":false,\"refreshRate90Hz\":true,\"frameBuffer\":true,\"codec\":\"hevc\",\"asw\":false,\"sharpenRate\":75},\"audio\":{\"mic\":false,\"volume\":50,\"output\":\"both\",\"latency\":30},\"general\":{\"autoConnect\":\"off\",\"language\":\"es-ES\"},\"lab\":{\"quic\":false,\"superResolution\":true,\"gamma\":100,\"faceTrackingMode\":4,\"faceTrackingTransferProtocol\":" + transferProtocol + ",\"bodyTracking\":false,\"controllerSensitivity\":50}}";
}

public static string GetSettingsJson(int transferProtocol = 0)
{
return "{\"video\":{\"resolution\":\"ultra\",\"bitrate\":{\"smooth\":20,\"sd\":150,\"hd\":100,\"ultra\":150},\"autoBitrate\":false,\"refreshRate90Hz\":false,\"frameBuffer\":true,\"codec\":\"hevc\",\"asw\":false,\"sharpenRate\":75},\"audio\":{\"mic\":true,\"volume\":58,\"output\":\"both\",\"latency\":30},\"general\":{\"autoConnect\":false,\"language\":\"en-US\",\"loginItem\":true,\"closeToTray\":false},\"lab\":{\"quic\":false,\"superResolution\":false,\"gamma\":100,\"faceTrackingMode\":4,\"faceTrackingTransferProtocol\":" + transferProtocol + ",\"bodyTracking\":false,\"controllerSensitivity\":49},\"game\":{\"resolution\":\"ultra\",\"bitrate\":{\"smooth\":20,\"sd\":150,\"hd\":100,\"ultra\":150,\"uhd\":150},\"autoBitrate\":false,\"refreshRate90Hz\":false,\"frameBuffer\":false,\"codec\":\"hevc\",\"asw\":false,\"sharpenRate\":75,\"superResolution\":true,\"gamma\":1,\"refreshRate\":72},\"desktop\":{\"sharpenRate\":0}}";
}

[TestMethod]
public void ReturnTransferProtocol0WhenLegacyFileContainsTransferProtocol0()
{
// arrange
List<string> errors = new List<string>();
Mock<ILogger> logger = GetLoggerMock(errors);

MockFileSystem mockFileSysteme = new MockFileSystem();
MockFileData mockFileData = new MockFileData(GetLegacySettingsJson(0));
mockFileSysteme.AddFile(CONFIG_FILE_PATH, mockFileData);

PicoConnectConfigChecker uut = new PicoConnectConfigChecker(logger.Object, mockFileSysteme);

// act
int got = uut.GetTransferProtocolNumber(PicoPrograms.PicoConnect);

// assert
Assert.AreEqual(0, errors.Count, "Expected no errors; instead got:\n" + String.Join("\n", errors));
Assert.AreEqual(0, got);
}

[TestMethod]
public void ReturnTransferProtocol2WhenLegacyFileContainsTransferProtocol2()
{
// arrange
List<string> errors = new List<string>();
Mock<ILogger> logger = GetLoggerMock(errors);

MockFileSystem mockFileSysteme = new MockFileSystem();
MockFileData mockFileData = new MockFileData(GetLegacySettingsJson(2));
mockFileSysteme.AddFile(CONFIG_FILE_PATH, mockFileData);

PicoConnectConfigChecker uut = new PicoConnectConfigChecker(logger.Object, mockFileSysteme);

// act
int got = uut.GetTransferProtocolNumber(PicoPrograms.PicoConnect);

// assert
Assert.AreEqual(0, errors.Count, "Expected no errors; instead got:\n" + String.Join("\n", errors));
Assert.AreEqual(2, got);
}

[TestMethod]
public void ReturnTransferProtocol0WhenFileContainsTransferProtocol0()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,10 @@

public class Config
{
public Video video { get; set; }
public Audio audio { get; set; }
public General general { get; set; }
public Lab lab { get; set; }
}

public class Video
{
public string resolution { get; set; }
public Bitrate bitrate { get; set; }
public bool autoBitrate { get; set; }
public bool refreshRate90Hz { get; set; }
public bool frameBuffer { get; set; }
public string codec { get; set; }
public bool asw { get; set; }
public int sharpenRate { get; set; }
}

public class Bitrate
{
public int smooth { get; set; }
public int sd { get; set; }
public int hd { get; set; }
public int ultra { get; set; }
}

public class Audio
{
public bool mic { get; set; }
public int volume { get; set; }
public string output { get; set; }
public int latency { get; set; }
}

public class General
{
public string autoConnect { get; set; }
public string language { get; set; }
}

public class Lab
{
public bool quic { get; set; }
public bool superResolution { get; set; }
public int gamma { get; set; }
public int faceTrackingMode { get; set; }
public int faceTrackingTransferProtocol { get; set; }
public bool bodyTracking { get; set; }
public int controllerSensitivity { get; set; }
}

0 comments on commit 4ecae6d

Please sign in to comment.