Skip to content

Commit

Permalink
Program: Add the test environment check
Browse files Browse the repository at this point in the history
For automation tests, we need to check if we are in the test
environment and if so, read the login name and password from a file
and set the login form with these values.

Signed-off-by: Matheus Castello <[email protected]>
  • Loading branch information
microhobby committed Jun 21, 2024
1 parent ad250ec commit f691a09
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,34 @@
win.Width = 800;
win.Height = 700;
});

// check if we are in the test environment
if (System.IO.File.Exists("/mnt/c/Users/Public/.torizon/password.txt"))
{
// read the file
// the pattern is loginName:loginRepPsswd
var _file = System.IO.File.ReadAllText(
"/mnt/c/Users/Public/.torizon/password.txt"
);

var _split = _file.Split(':');
var _loginName = _split[0];
var _loginRepPsswd = _split[1];

// set the login name
win.RunOnUiThread(() => {
win.loginName = _loginName;
win.loginPsswd = _loginRepPsswd;
win.loginRepPsswd = _loginRepPsswd;
win.createLoginShow = true;
win.welcomeShow = false;
});

Slint.Timer.Start(TimerMode.SingleShot, 2000, () =>
{
win.CreateLogin.Invoke();
});
}
});

win.Run();

0 comments on commit f691a09

Please sign in to comment.