Do more selection checks in form fill embedder tests

Make sure there is no text selection before doing an action that
triggers a text selection, so we can be more certain the action actually
did something.

Change-Id: Ibd733bbdbde64dd228a3c66b6de62418560f74e5
Reviewed-on: https://pdfium-review.googlesource.com/c/44112
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
diff --git a/fpdfsdk/fpdf_formfill_embeddertest.cpp b/fpdfsdk/fpdf_formfill_embeddertest.cpp
index 3e53753..e55997c 100644
--- a/fpdfsdk/fpdf_formfill_embeddertest.cpp
+++ b/fpdfsdk/fpdf_formfill_embeddertest.cpp
@@ -1035,6 +1035,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllRegularFormTextWithMouse();
   CheckSelection(L"Hello");
 }
@@ -1055,6 +1056,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllRegularFormTextWithMouse();
   CheckSelection(L"HelloABCDEFGH");
 }
@@ -1073,6 +1075,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllRegularFormTextWithMouse();
   CheckSelection(L"ABCDHelloEFGH");
 }
@@ -1091,6 +1094,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllRegularFormTextWithMouse();
   CheckSelection(L"ABCDEFGHHello");
 }
@@ -1100,6 +1104,7 @@
   TypeTextIntoTextField(12, RegularFormBegin());
 
   // Select entire string in text field.
+  CheckSelection(L"");
   SelectTextWithKeyboard(12, FWL_VKEY_Left, RegularFormEnd());
   CheckSelection(L"ABCDEFGHIJKL");
 
@@ -1111,6 +1116,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllRegularFormTextWithMouse();
   CheckSelection(L"Hello");
 }
@@ -1120,6 +1126,7 @@
   TypeTextIntoTextField(12, RegularFormBegin());
 
   // Select left portion of string in text field.
+  CheckSelection(L"");
   SelectTextWithKeyboard(6, FWL_VKEY_Left, RegularFormAtX(148.0));
   CheckSelection(L"ABCDEF");
 
@@ -1131,6 +1138,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllRegularFormTextWithMouse();
   CheckSelection(L"HelloGHIJKL");
 }
@@ -1140,6 +1148,7 @@
   TypeTextIntoTextField(12, RegularFormBegin());
 
   // Select middle portion of string in text field.
+  CheckSelection(L"");
   SelectTextWithKeyboard(6, FWL_VKEY_Left, RegularFormAtX(171.0));
   CheckSelection(L"DEFGHI");
 
@@ -1150,6 +1159,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllRegularFormTextWithMouse();
   CheckSelection(L"ABCHelloJKL");
 }
@@ -1159,6 +1169,7 @@
   TypeTextIntoTextField(12, RegularFormBegin());
 
   // Select right portion of string in text field.
+  CheckSelection(L"");
   SelectTextWithKeyboard(6, FWL_VKEY_Left, RegularFormEnd());
   CheckSelection(L"GHIJKL");
 
@@ -1169,6 +1180,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllRegularFormTextWithMouse();
   CheckSelection(L"ABCDEFHello");
 }
@@ -1186,6 +1198,7 @@
 
   // Select entire contents of user-editable combobox text field to check that
   // insertion worked as expected.
+  CheckSelection(L"");
   SelectAllEditableFormTextWithMouse();
   CheckSelection(L"Hello");
 }
@@ -1204,6 +1217,7 @@
 
   // Select entire contents of user-editable combobox text field to check that
   // insertion worked as expected.
+  CheckSelection(L"");
   SelectAllEditableFormTextWithMouse();
   CheckSelection(L"HelloABCDEF");
 }
@@ -1223,6 +1237,7 @@
 
   // Select entire contents of user-editable combobox text field to check that
   // insertion worked as expected.
+  CheckSelection(L"");
   SelectAllEditableFormTextWithMouse();
   CheckSelection(L"ABCHelloDEF");
 }
@@ -1241,6 +1256,7 @@
 
   // Select entire contents of user-editable combobox text field to check that
   // insertion worked as expected.
+  CheckSelection(L"");
   SelectAllEditableFormTextWithMouse();
   CheckSelection(L"ABCDEFHello");
 }
@@ -1250,6 +1266,7 @@
   TypeTextIntoTextField(10, EditableFormBegin());
 
   // Select entire string in user-editable combobox.
+  CheckSelection(L"");
   SelectTextWithKeyboard(10, FWL_VKEY_Left, EditableFormEnd());
   CheckSelection(L"ABCDEFGHIJ");
 
@@ -1260,6 +1277,7 @@
 
   // Select entire contents of user-editable combobox text field to check that
   // insertion worked as expected.
+  CheckSelection(L"");
   SelectAllEditableFormTextWithMouse();
   CheckSelection(L"Hello");
 }
@@ -1269,6 +1287,7 @@
   TypeTextIntoTextField(10, EditableFormBegin());
 
   // Select left portion of string in user-editable combobox.
+  CheckSelection(L"");
   SelectTextWithKeyboard(5, FWL_VKEY_Left, EditableFormAtX(142.0));
   CheckSelection(L"ABCDE");
 
@@ -1279,6 +1298,7 @@
 
   // Select entire contents of user-editable combobox text field to check that
   // insertion worked as expected.
+  CheckSelection(L"");
   SelectAllEditableFormTextWithMouse();
   CheckSelection(L"HelloFGHIJ");
 }
@@ -1288,6 +1308,7 @@
   TypeTextIntoTextField(10, EditableFormBegin());
 
   // Select middle portion of string in user-editable combobox.
+  CheckSelection(L"");
   SelectTextWithKeyboard(5, FWL_VKEY_Left, EditableFormAtX(167.0));
   CheckSelection(L"DEFGH");
 
@@ -1298,6 +1319,7 @@
 
   // Select entire contents of user-editable combobox text field to check that
   // insertion worked as expected.
+  CheckSelection(L"");
   SelectAllEditableFormTextWithMouse();
   CheckSelection(L"ABCHelloIJ");
 }
@@ -1307,6 +1329,7 @@
   TypeTextIntoTextField(10, EditableFormBegin());
 
   // Select right portion of string in user-editable combobox.
+  CheckSelection(L"");
   SelectTextWithKeyboard(5, FWL_VKEY_Left, EditableFormEnd());
   CheckSelection(L"FGHIJ");
 
@@ -1317,6 +1340,7 @@
 
   // Select entire contents of user-editable combobox text field to check that
   // insertion worked as expected.
+  CheckSelection(L"");
   SelectAllEditableFormTextWithMouse();
   CheckSelection(L"ABCDEHello");
 }
@@ -1329,6 +1353,7 @@
   CheckFocusedFieldText(L"Elephant");
 
   // Delete pre-filled contents of text field with char limit.
+  CheckSelection(L"");
   SelectAllCharLimitFormTextWithMouse();
   CheckSelection(L"Elephant");
   FORM_ReplaceSelection(form_handle(), page(), nullptr);
@@ -1343,6 +1368,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllCharLimitFormTextWithMouse();
   CheckSelection(L"Hippopotam");
 }
@@ -1354,6 +1380,7 @@
   CheckFocusedFieldText(L"Elephant");
 
   // Delete pre-filled contents of text field with char limit.
+  CheckSelection(L"");
   SelectAllCharLimitFormTextWithMouse();
   CheckSelection(L"Elephant");
   FORM_ReplaceSelection(form_handle(), page(), nullptr);
@@ -1367,6 +1394,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllCharLimitFormTextWithMouse();
   CheckSelection(L"Zebra");
 }
@@ -1383,6 +1411,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllCharLimitFormTextWithMouse();
   CheckSelection(L"HiElephant");
 }
@@ -1405,6 +1434,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllCharLimitFormTextWithMouse();
   CheckSelection(L"ElephHiant");
 }
@@ -1423,6 +1453,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllCharLimitFormTextWithMouse();
   CheckSelection(L"ElephantHi");
 }
@@ -1432,6 +1463,7 @@
   TypeTextIntoTextField(12, RegularFormBegin());
 
   // Select entire string in text field.
+  CheckSelection(L"");
   SelectTextWithKeyboard(12, FWL_VKEY_Left, CharLimitFormEnd());
   CheckSelection(L"Elephant");
 
@@ -1442,6 +1474,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllCharLimitFormTextWithMouse();
   CheckSelection(L"Hippopotam");
 }
@@ -1451,6 +1484,7 @@
   TypeTextIntoTextField(12, RegularFormBegin());
 
   // Select left portion of string in text field.
+  CheckSelection(L"");
   SelectTextWithKeyboard(4, FWL_VKEY_Left, CharLimitFormAtX(122.0));
   CheckSelection(L"Elep");
 
@@ -1461,6 +1495,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllCharLimitFormTextWithMouse();
   CheckSelection(L"Hippophant");
 }
@@ -1470,6 +1505,7 @@
   TypeTextIntoTextField(12, RegularFormBegin());
 
   // Select middle portion of string in text field.
+  CheckSelection(L"");
   SelectTextWithKeyboard(4, FWL_VKEY_Left, CharLimitFormAtX(136.0));
   CheckSelection(L"epha");
 
@@ -1480,6 +1516,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllCharLimitFormTextWithMouse();
   CheckSelection(L"ElHippopnt");
 }
@@ -1489,6 +1526,7 @@
   TypeTextIntoTextField(12, RegularFormBegin());
 
   // Select right portion of string in text field.
+  CheckSelection(L"");
   SelectTextWithKeyboard(4, FWL_VKEY_Left, CharLimitFormAtX(152.0));
   CheckSelection(L"hant");
 
@@ -1499,6 +1537,7 @@
 
   // Select entire contents of text field to check that insertion worked
   // as expected.
+  CheckSelection(L"");
   SelectAllCharLimitFormTextWithMouse();
   CheckSelection(L"ElepHippop");
 }