forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssue24977.cs
More file actions
74 lines (63 loc) · 1.93 KB
/
Issue24977.cs
File metadata and controls
74 lines (63 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#if IOS
using System.Drawing;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;
using System.Text;
namespace Microsoft.Maui.TestCases.Tests.Issues;
public class Issue24977 : _IssuesUITest
{
public Issue24977(TestDevice device) : base(device) { }
public override string Issue => "Keyboard Scrolling in editors with Center or End VerticalTextAlignment is off";
[Test]
[Category(UITestCategories.Editor)]
public void KeepEditorCursorAboveKeyboardWithVerticalAlignmentAsCenter()
{
TestKeepEditorCursorAboveKeyboard("CenterButton", true);
}
[Test]
[Category(UITestCategories.Editor)]
public void KeepEditorCursorAboveKeyboardWithVerticalAlignmentAsEnd()
{
TestKeepEditorCursorAboveKeyboard("EndButton");
}
void TestKeepEditorCursorAboveKeyboard(string buttonId, bool fromCenter = false)
{
App.WaitForElement(buttonId);
App.Tap(buttonId);
Thread.Sleep(1000);
var app = App as AppiumApp;
if (app == null)
return;
var editorRect = app.WaitForElement("IssueEditor").GetRect();
app.Click("IssueEditor");
var sb = new StringBuilder();
for (int i = 1; i <= 20; i++)
{
sb.Append($"\n{i}");
}
app.EnterText("IssueEditor", sb.ToString());
var keyboardLocation = KeyboardScrolling.FindiOSKeyboardLocation(app.Driver);
var cursorLabel = app.WaitForElement("CursorHeightTracker").GetText();
var cursorHeight1 = Convert.ToDouble(cursorLabel);
try
{
if (keyboardLocation is Point keyboardPoint)
{
Assert.That(cursorHeight1 < keyboardPoint.Y);
}
else
{
Assert.Fail("keyboardLocation is null");
}
}
finally
{
if (fromCenter)
{
App.Back();
}
}
}
}
#endif