Skip to content

Commit

Permalink
Adjust screenshots names for automated tests (#1326)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban authored and ghuntley committed Aug 1, 2019
1 parent b96c944 commit 30a8be8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 27 deletions.
24 changes: 23 additions & 1 deletion src/SamplesApp/SamplesApp.UITests/SampleControlUITestBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using SamplesApp.UITests.TestFramework;
Expand Down Expand Up @@ -72,6 +73,27 @@ public void BeforeEachTest()
Helpers.App = _app;
}

public void TakeScreenshot(string stepName)
{
var title = $"{TestContext.CurrentContext.Test.Name}_{stepName}"
.Replace(" ", "_")
.Replace(".", "_");

var fileInfo = _app.Screenshot(title);

var fileNameWithoutExt = Path.GetFileNameWithoutExtension(fileInfo.Name);
if (fileNameWithoutExt != title)
{
var destFileName = Path.Combine(Path.GetDirectoryName(fileInfo.FullName), fileNameWithoutExt + "." + Path.GetExtension(fileInfo.Name));
if (File.Exists(destFileName))
{
File.Delete(destFileName);
}

File.Move(fileInfo.FullName, destFileName);
}
}

private static void ValidateAutoRetry()
{
var testType = Type.GetType(TestContext.CurrentContext.Test.ClassName);
Expand Down Expand Up @@ -125,7 +147,7 @@ protected void Run(string metadataName)
return bool.TryParse(result, out var testDone) && testDone;
});

_app.Screenshot(metadataName.Replace(".", "_"));
TakeScreenshot(metadataName.Replace(".", "_"));
}
}
}
52 changes: 26 additions & 26 deletions src/SamplesApp/SamplesApp.UITests/UnoSamples_Tests.Keyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,72 +42,72 @@ public void Keyboard_Textbox_InsideScrollViewer_Validation()
// Setting focus on normalTextBox
_app.Tap(normalTextBox);
_app.Wait(1);
_app.Screenshot("Inside ScrollViewer - 0 - Focus on normalTextBox ");
TakeScreenshot("0 - Focus on normalTextBox ");

// Removing focus on normalTextBox
_app.TapCoordinates(0f, 0f);
_app.Wait(1);
_app.Screenshot("Inside ScrollViewer - 0 - Remove Focus on normalTextBox");
TakeScreenshot("0 - Remove Focus on normalTextBox");
}

{
// Setting focus on normalTextBox
_app.Tap(filledTextBox);
_app.Wait(1);
_app.Screenshot("Inside ScrollViewer - 1 - Focus on filledTextBox");
TakeScreenshot("1 - Focus on filledTextBox");

// Removing focus on normalTextBox
_app.TapCoordinates(0f, 0f);
_app.Wait(1);
_app.Screenshot("Inside ScrollViewer - 1 - Remove Focus on filledTextBox");
TakeScreenshot("1 - Remove Focus on filledTextBox");
}

{
// Setting focus on placeholderTextTextBox
_app.Tap(placeholderTextTextBox);
_app.Wait(1);
_app.Screenshot("Inside ScrollViewer - 2 - Focus on placeholderTextTextBox");
TakeScreenshot("2 - Focus on placeholderTextTextBox");

// Removing focus on placeholderTextTextBox
_app.TapCoordinates(0f, 0f);
_app.Wait(1);
_app.Screenshot("Inside ScrollViewer - 2 - Remove Focus on placeholderTextTextBox");
TakeScreenshot("2 - Remove Focus on placeholderTextTextBox");
}

{
// Setting focus on disabledTextBox
_app.Tap(disabledTextBox);
_app.Wait(1);
_app.Screenshot("Inside ScrollViewer - 3 - Focus on disabledTextBox");
TakeScreenshot("3 - Focus on disabledTextBox");

// Removing focus on disabledTextBox
_app.TapCoordinates(0f, 0f);
_app.Wait(1);
_app.Screenshot("Inside ScrollViewer - 3 - Remove Focus on disabledTextBox");
TakeScreenshot("3 - Remove Focus on disabledTextBox");
}

{
// Setting focus on multilineTextBox
_app.Tap(multilineTextBox);
_app.Wait(1);
_app.Screenshot("Inside ScrollViewer - 4 - Focus on multilineTextBox");
TakeScreenshot("4 - Focus on multilineTextBox");

// Removing focus on multilineTextBox
_app.TapCoordinates(0f, 0f);
_app.Wait(1);
_app.Screenshot("Inside ScrollViewer - 4 - Remove Focus on multilineTextBox");
TakeScreenshot("4 - Remove Focus on multilineTextBox");
}

{
// Setting focus on numberTextBox
_app.Tap(numberTextBox);
_app.Wait(1);
_app.Screenshot("Inside ScrollViewer - 5 - Focus on numberTextBox");
TakeScreenshot("5 - Focus on numberTextBox");

// Removing focus on numberTextBox
_app.TapCoordinates(0f, 0f);
_app.Wait(1);
_app.Screenshot("Inside ScrollViewer - 5 - Remove Focus on numberTextBox");
TakeScreenshot("5 - Remove Focus on numberTextBox");
}
}

Expand Down Expand Up @@ -138,72 +138,72 @@ public void Keyboard_Textbox_NoScrollViewer_Validation()
// Setting focus on normalTextBox
_app.Tap(normalTextBox);
_app.Wait(1);
_app.Screenshot("No ScrollViewer - 0 - Focus on normalTextBox");
TakeScreenshot("0 - Focus on normalTextBox");

// Removing focus on normalTextBox
_app.TapCoordinates(0f, 0f);
_app.Wait(1);
_app.Screenshot("No ScrollViewer - 0 - Remove Focus on normalTextBox");
TakeScreenshot("0 - Remove Focus on normalTextBox");
}

{
// Setting focus on normalTextBox
_app.Tap(filledTextBox);
_app.Wait(1);
_app.Screenshot("No ScrollViewer - 1 - Focus on filledTextBox");
TakeScreenshot("1 - Focus on filledTextBox");

// Removing focus on normalTextBox
_app.TapCoordinates(0f, 0f);
_app.Wait(1);
_app.Screenshot("No ScrollViewer - 1 - Remove Focus on filledTextBox");
TakeScreenshot("1 - Remove Focus on filledTextBox");
}

{
// Setting focus on placeholderTextTextBox
_app.Tap(placeholderTextTextBox);
_app.Wait(1);
_app.Screenshot("No ScrollViewer - 2 - Focus on placeholderTextTextBox");
TakeScreenshot("2 - Focus on placeholderTextTextBox");

// Removing focus on placeholderTextTextBox
_app.TapCoordinates(0f, 0f);
_app.Wait(1);
_app.Screenshot("No ScrollViewer - 2 - Remove Focus on placeholderTextTextBox");
TakeScreenshot("2 - Remove Focus on placeholderTextTextBox");
}

{
// Setting focus on disabledTextBox
_app.Tap(disabledTextBox);
_app.Wait(1);
_app.Screenshot("No ScrollViewer - 3 - Focus on disabledTextBox");
TakeScreenshot("3 - Focus on disabledTextBox");

// Removing focus on disabledTextBox
_app.TapCoordinates(0f, 0f);
_app.Wait(1);
_app.Screenshot("No ScrollViewer - 3 - Remove Focus on disabledTextBox");
TakeScreenshot("3 - Remove Focus on disabledTextBox");
}

{
// Setting focus on multilineTextBox
_app.Tap(multilineTextBox);
_app.Wait(1);
_app.Screenshot("No ScrollViewer - 4 - Focus on multilineTextBox");
TakeScreenshot("4 - Focus on multilineTextBox");

// Removing focus on multilineTextBox
_app.TapCoordinates(0f, 0f);
_app.Wait(1);
_app.Screenshot("No ScrollViewer - 4 - Remove Focus on multilineTextBox");
TakeScreenshot("4 - Remove Focus on multilineTextBox");
}

{
// Setting focus on numberTextBox
_app.Tap(numberTextBox);
_app.Wait(1);
_app.Screenshot("No ScrollViewer - 5 - Focus on numberTextBox");
TakeScreenshot("5 - Focus on numberTextBox");

// Removing focus on numberTextBox
_app.TapCoordinates(0f, 0f);
_app.Wait(1);
_app.Screenshot("No ScrollViewer - 5 - Remove Focus on numberTextBox");
TakeScreenshot("5 - Remove Focus on numberTextBox");
}
}

Expand Down Expand Up @@ -394,7 +394,7 @@ public void Keyboard_DismissTesting()

_app.WaitForElement(singleTextBox);

var f = _app.Screenshot("initial");
TakeScreenshot("initial");

singleTextBox.Tap();
_app.Wait(2);
Expand All @@ -407,7 +407,7 @@ public void Keyboard_DismissTesting()
_app.Wait(3);
_app.Back();

var t = _app.Screenshot("final");
TakeScreenshot("final");
_app.Wait(2);

// TODO do not rely on GDI to do the image comparison
Expand Down

0 comments on commit 30a8be8

Please sign in to comment.