[UITest] Change Query to WaitForElement on 45125 and change GetResult to await for Performance Gallery testing (#7057)

* change query to waitforelement and use async over GetResult

* - ConfigureAwait(false)
This commit is contained in:
Shane Neuville 2019-08-05 14:26:34 -06:00 коммит произвёл GitHub
Родитель 56151e8896
Коммит 229250aed7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 31 добавлений и 12 удалений

Просмотреть файл

@ -256,8 +256,8 @@ namespace Xamarin.Forms.Controls.Issues
RunningApp.WaitForElement (q => q.Marked (DisappearingLabelId));
RunningApp.Screenshot ("There should be appearing and disappearing events for the Groups and Items.");
var appearing = int.Parse(RunningApp.Query(q => q.Marked(AppearingLabelId))[0].Text);
var disappearing = int.Parse(RunningApp.Query(q=> q.Marked(DisappearingLabelId))[0].Text);
var appearing = int.Parse(RunningApp.WaitForElement(AppearingLabelId)[0].ReadText());
var disappearing = int.Parse(RunningApp.WaitForElement(DisappearingLabelId)[0].ReadText());
Assert.IsTrue(appearing > 0, $"Test {_TestNumber}: No appearing events for groups found.");
Assert.IsTrue(disappearing > 0, $"Test {_TestNumber}: No disappearing events for groups found.");

Просмотреть файл

@ -38,7 +38,7 @@ namespace Xamarin.Forms.Controls.Issues
public static async Task<Dictionary<string, double>> GetScenarioResults(string deviceId)
{
var response = await _client.GetAsync(GetScenarioResultsRoute + deviceId);
var response = await _client.GetAsync(GetScenarioResultsRoute + deviceId).ConfigureAwait(false);
if (!response.IsSuccessStatusCode)
return new Dictionary<string, double>();
@ -63,12 +63,12 @@ namespace Xamarin.Forms.Controls.Issues
};
var json = JsonConvert.SerializeObject(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await _client.PostAsync(PostScenarioResultRoute + scenarioName, content);
var responseContent = await response.Content.ReadAsStringAsync();
var response = await _client.PostAsync(PostScenarioResultRoute + scenarioName, content).ConfigureAwait(false);
var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var scenarioResult = JsonConvert.DeserializeObject<ScenarioResult>(responseContent);
await PostScenarioResultDetails(scenarioResult.Id, details);
await PostScenarioResultDetails(scenarioResult.Id, details).ConfigureAwait(false);
}
static async Task PostScenarioResultDetails(Guid scenarioResultId, Dictionary<string, PerformanceProvider.Statistic> details)
@ -84,7 +84,7 @@ namespace Xamarin.Forms.Controls.Issues
Name = detail.Key
};
var content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
await _client.PostAsync(PostScenarioResultDetailsRoute + scenarioResultId, content);
await _client.PostAsync(PostScenarioResultDetailsRoute + scenarioResultId, content).ConfigureAwait(false);
}
}

Просмотреть файл

@ -41,7 +41,7 @@ namespace Xamarin.Forms.Controls.Issues
PerformanceTracker _PerformanceTracker = new PerformanceTracker();
List<PerformanceScenario> _TestCases = new List<PerformanceScenario>();
int _TestNumber = 0;
Button nextButton;
PerformanceViewModel ViewModel => BindingContext as PerformanceViewModel;
protected override void Init()
@ -65,7 +65,7 @@ namespace Xamarin.Forms.Controls.Issues
_TestCases.AddRange(InflatePerformanceScenarios());
var nextButton = new Button { Text = Pending, IsEnabled = false, AutomationId = NextButtonId };
nextButton = new Button { Text = Pending, IsEnabled = false, AutomationId = NextButtonId };
nextButton.Clicked += NextButton_Clicked;
ViewModel.TestRunReferenceId = Guid.NewGuid();
@ -82,11 +82,30 @@ namespace Xamarin.Forms.Controls.Issues
};
Content = new StackLayout { Children = { testRunRef, nextButton, _PerformanceTracker } };
GetBenchmarkResults();
}
ViewModel.BenchmarkResults = Task.Run(() => PerformanceDataManager.GetScenarioResults(_DeviceIdentifier)).GetAwaiter().GetResult();
async void GetBenchmarkResults(int tryCount = 0)
{
bool success = false;
try
{
ViewModel.BenchmarkResults = await PerformanceDataManager.GetScenarioResults(_DeviceIdentifier);
success = true;
}
catch(Exception exc)
{
if (tryCount < 3)
GetBenchmarkResults(++tryCount);
else
nextButton.Text = exc.ToString();
}
nextButton.IsEnabled = true;
nextButton.Text = Next;
if (success)
{
nextButton.IsEnabled = true;
nextButton.Text = Next;
}
}
private static string GetBuildNumber()