Skip to content

Commit e8ff3a6

Browse files
committed
Fix some test bugs
1 parent 45f7e08 commit e8ff3a6

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

src/UnitTests/UnitTest1.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ modified or altered in any way.
16301630
w.SendKeystrokes("{HOME}");
16311631
findDialog = OpenReplaceDialog();
16321632
findDialog.Window.SendKeystrokes("will not find%r");
1633-
var popup = findDialog.Window.ExpectingPopup("Find Error");
1633+
var popup = findDialog.Window.ExpectingPopup("Replace Error");
16341634
popup.DismissPopUp("{ENTER}");
16351635

16361636
Trace.WriteLine("Test we can replace 2 things in sequence");
@@ -2154,7 +2154,7 @@ public void TestResizePanes()
21542154
bounds = resizer.Bounds;
21552155
mid = bounds.Center();
21562156
// Drag the resizer right a few pixels.
2157-
Mouse.MouseDragDrop(mid, new Point(mid.X + 20, mid.Y), 1, MouseButtons.Left);
2157+
Mouse.MouseDragDrop(mid, new Point(mid.X + 50, mid.Y), 1, MouseButtons.Left);
21582158
newbounds = resizer.Bounds;
21592159
Assert.IsTrue(newbounds.Center().X > mid.X);
21602160
}

src/UnitTests/mouse.cs

+19-7
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ private static MouseInput GetAbsoluteMouseInput(int x, int y)
9797
input.dx = x;
9898
input.dy = y;
9999
input.dwFlags = (int)MouseFlags.MOUSEEVENTF_MOVE_NOCOALESCE;
100+
input.mouseData = 0;
100101
input.time = 0;
101102
return input;
102103
}
@@ -105,19 +106,27 @@ private static MouseInput GetVirtualMouseInput(int x, int y)
105106
{
106107
MouseInput input = new MouseInput();
107108
input.type = (int)(InputType.INPUT_MOUSE);
108-
input.dx = (x * 65536) / GetSystemMetrics(SM_CXSCREEN); ;
109-
input.dy = (y * 65536) / GetSystemMetrics(SM_CYSCREEN); ;
109+
input.dx = (x * 65536) / GetSystemMetrics(SM_CXSCREEN);
110+
input.dy = (y * 65536) / GetSystemMetrics(SM_CYSCREEN);
110111
input.dwFlags = (int)(MouseFlags.MOUSEEVENTF_MOVE_NOCOALESCE | MouseFlags.MOUSEEVENTF_VIRTUALDESK);
112+
input.mouseData = 0;
111113
input.time = 0;
112114
return input;
113115
}
114116

115-
public static void MouseMoveTo(int x, int y, MouseButtons buttons)
117+
public static void MouseMoveTo(int x, int y, MouseButtons buttons, bool buttonUp = false)
116118
{
117119
MouseInput input = GetVirtualMouseInput(x, y);
118120
MouseFlags flags = (MouseFlags)input.dwFlags;
119121
flags |= MouseFlags.MOUSEEVENTF_MOVE | MouseFlags.MOUSEEVENTF_ABSOLUTE;
120-
flags = AddMouseDownFlags(flags, buttons);
122+
if (buttonUp)
123+
{
124+
flags = AddMouseUpFlags(flags, buttons);
125+
}
126+
else
127+
{
128+
flags = AddMouseDownFlags(flags, buttons);
129+
}
121130
input.dwFlags = (int)flags;
122131
SendInput(input);
123132
Application.DoEvents();
@@ -132,8 +141,9 @@ public static void MouseDragDrop(Point start, Point end, int step, MouseButtons
132141
MouseDown(start, buttons);
133142
Application.DoEvents();
134143
Thread.Sleep(DragDelayDrop);
135-
MouseDragTo(start, end, step, buttons);
144+
MouseDragTo(start, end, step, buttons, true);
136145
Thread.Sleep(DragDelayDrop);
146+
MouseDragTo(end, end, step, buttons, true);
137147
MouseUp(end, buttons);
138148
Application.DoEvents();
139149
Thread.Sleep(DragDelayDrop);
@@ -145,7 +155,7 @@ public static void MouseMoveTo(Point start, Point end, int step)
145155
MouseDragTo(start, end, step, MouseButtons.None);
146156
}
147157

148-
public static void MouseDragTo(Point start, Point end, int step, MouseButtons buttons)
158+
public static void MouseDragTo(Point start, Point end, int step, MouseButtons buttons, bool finishWithButtonUp = false)
149159
{
150160
// Interpolate and move mouse smoothly over to given location.
151161
double dx = end.X - start.X;
@@ -157,9 +167,11 @@ public static void MouseDragTo(Point start, Point end, int step, MouseButtons bu
157167
int tx = start.X + (int)((dx * i) / length);
158168
int ty = start.Y + (int)((dy * i) / length);
159169
MouseMoveTo(tx, ty, buttons);
170+
Thread.Sleep(1);
171+
Application.DoEvents();
160172
}
161173

162-
MouseMoveTo(end.X, end.Y, buttons);
174+
MouseMoveTo(end.X, end.Y, buttons, finishWithButtonUp);
163175
}
164176

165177
public static void MouseWheel(AutomationWrapper w, int clicks)

src/XmlNotepad/NodeTextView.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ void FindString(object sender, string toFind)
927927
TreeNode start = node;
928928
while (node != null)
929929
{
930-
string s = node.Text.Trim();
930+
string s = node.Text == null ? string.Empty : node.Text.Trim();
931931
if (s != null && s.StartsWith(toFind, StringComparison.CurrentCultureIgnoreCase))
932932
{
933933
this.SelectedNode = node;

0 commit comments

Comments
 (0)