mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-19 21:03:11 -07:00
enable internet server for development
This commit is contained in:
parent
6370f28f8e
commit
b159a89570
3 changed files with 10 additions and 25 deletions
|
@ -63,5 +63,6 @@
|
||||||
</Applications>
|
</Applications>
|
||||||
<Capabilities>
|
<Capabilities>
|
||||||
<Capability Name="internetClient" />
|
<Capability Name="internetClient" />
|
||||||
|
<Capability Name="internetClientServer"/>
|
||||||
</Capabilities>
|
</Capabilities>
|
||||||
</Package>
|
</Package>
|
||||||
|
|
|
@ -40,7 +40,15 @@ namespace CalculatorUITestFramework
|
||||||
private static void OnGetContext(IAsyncResult result)
|
private static void OnGetContext(IAsyncResult result)
|
||||||
{
|
{
|
||||||
var listener = (HttpListener)result.AsyncState;
|
var listener = (HttpListener)result.AsyncState;
|
||||||
var context = listener.EndGetContext(result);
|
HttpListenerContext context;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
context = listener.EndGetContext(result);
|
||||||
|
}
|
||||||
|
catch (HttpListenerException)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
var request = context.Request;
|
var request = context.Request;
|
||||||
var response = context.Response;
|
var response = context.Response;
|
||||||
if (request.HttpMethod == "GET" && TryGetServerFile(request.Url, out var content))
|
if (request.HttpMethod == "GET" && TryGetServerFile(request.Url, out var content))
|
||||||
|
|
|
@ -26,7 +26,6 @@ namespace CalculatorUITests
|
||||||
{
|
{
|
||||||
// Create session to launch a Calculator window
|
// Create session to launch a Calculator window
|
||||||
_currencyServer = new MockedCurrencyServer();
|
_currencyServer = new MockedCurrencyServer();
|
||||||
Thread.Sleep(5000);
|
|
||||||
CalculatorDriver.Instance.SetupCalculatorSession(context);
|
CalculatorDriver.Instance.SetupCalculatorSession(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,10 +46,7 @@ namespace CalculatorUITests
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void TestInit()
|
public void TestInit()
|
||||||
{
|
{
|
||||||
VerifyConnection("http://localhost/calctesting/file/?id=currency+converter+data&localCurrency=en-US");
|
|
||||||
VerifyConnection("http://localhost/calctesting/file/?id=currency+static+data&localizeFor=en-US");
|
|
||||||
CalculatorApp.EnsureCalculatorHasFocus();
|
CalculatorApp.EnsureCalculatorHasFocus();
|
||||||
Thread.Sleep(5000);
|
|
||||||
page.EnsureCalculatorIsCurrencyMode();
|
page.EnsureCalculatorIsCurrencyMode();
|
||||||
page.EnsureCalculatorResultTextIsZero();
|
page.EnsureCalculatorResultTextIsZero();
|
||||||
page.EnsureSameUnitsAreSelected();
|
page.EnsureSameUnitsAreSelected();
|
||||||
|
@ -62,26 +58,6 @@ namespace CalculatorUITests
|
||||||
page.ClearAll();
|
page.ClearAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void VerifyConnection(string url)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"VerifyConnection begins: url: {url}");
|
|
||||||
var process = new Process();
|
|
||||||
var startInfo = new ProcessStartInfo
|
|
||||||
{
|
|
||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
|
||||||
FileName = "cmd.exe",
|
|
||||||
Arguments = @$"/C curl ""{url}""",
|
|
||||||
RedirectStandardOutput = true, // Redirect the standard output
|
|
||||||
UseShellExecute = false,
|
|
||||||
CreateNoWindow = true
|
|
||||||
};
|
|
||||||
process.StartInfo = startInfo;
|
|
||||||
process.Start();
|
|
||||||
var debug = process.StandardOutput.ReadToEnd();
|
|
||||||
process.WaitForExit();
|
|
||||||
Console.WriteLine($"VerifyConnection ends: exitcode: {process.ExitCode}, curl result: {debug}");
|
|
||||||
}
|
|
||||||
|
|
||||||
private string NormalizeCurrencyText(string realValue, int fractionDigits)
|
private string NormalizeCurrencyText(string realValue, int fractionDigits)
|
||||||
{
|
{
|
||||||
if (!realValue.Contains('.')) return realValue;
|
if (!realValue.Contains('.')) return realValue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue