| ... |
... |
@@ -46,9 +46,10 @@ |
|
46
|
46
|
static const int TEXT_HEIGHT = 200;
|
|
47
|
47
|
|
|
48
|
48
|
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
|
49
|
|
-#define wxHAS_2CHAR_NEWLINES 1
|
|
50
|
|
-#else
|
|
51
|
|
-#define wxHAS_2CHAR_NEWLINES 0
|
|
|
49
|
+ #define wxHAS_2CHAR_NEWLINES
|
|
|
50
|
+ #if wxUSE_UIACTIONSIMULATOR && wxUSE_RICHEDIT
|
|
|
51
|
+ #define wxHAS_TEXT_URL_TEST
|
|
|
52
|
+ #endif
|
|
52
|
53
|
#endif
|
|
53
|
54
|
|
|
54
|
55
|
// ----------------------------------------------------------------------------
|
| ... |
... |
@@ -80,7 +81,9 @@ protected: |
|
80
|
81
|
// And these ones only make sense for the multi-line ones.
|
|
81
|
82
|
void MultiLineReplace();
|
|
82
|
83
|
//void ProcessEnter();
|
|
|
84
|
+#ifdef wxHAS_TEXT_URL_TEST
|
|
83
|
85
|
void Url();
|
|
|
86
|
+#endif
|
|
84
|
87
|
void Style();
|
|
85
|
88
|
void FontStyle();
|
|
86
|
89
|
void Lines();
|
| ... |
... |
@@ -169,9 +172,9 @@ wxTEXT_CTRL_SINGLE_LINE_TEST(PositionToXYSingleLine) |
|
169
|
172
|
wxTEXT_CTRL_SINGLE_LINE_TEST(XYToPositionSingleLine)
|
|
170
|
173
|
|
|
171
|
174
|
wxTEXT_CTRL_MULTI_LINE_TEST(MultiLineReplace)
|
|
172
|
|
-#if wxUSE_UIACTIONSIMULATOR
|
|
|
175
|
+#ifdef wxHAS_TEXT_URL_TEST
|
|
173
|
176
|
wxTEXT_CTRL_MULTI_LINE_TEST(Url)
|
|
174
|
|
-#endif // wxUSE_UIACTIONSIMULATOR
|
|
|
177
|
+#endif
|
|
175
|
178
|
wxTEXT_CTRL_MULTI_LINE_TEST(Style)
|
|
176
|
179
|
wxTEXT_CTRL_MULTI_LINE_TEST(FontStyle)
|
|
177
|
180
|
wxTEXT_CTRL_MULTI_LINE_TEST(Lines)
|
| ... |
... |
@@ -647,32 +650,43 @@ void TextCtrlTestCase::ProcessEnter() |
|
647
|
650
|
}
|
|
648
|
651
|
#endif
|
|
649
|
652
|
|
|
|
653
|
+#ifdef wxHAS_TEXT_URL_TEST
|
|
650
|
654
|
void TextCtrlTestCase::Url()
|
|
651
|
655
|
{
|
|
652
|
|
-#if wxUSE_UIACTIONSIMULATOR && defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
|
653
|
|
- if ( !EnableUITests() )
|
|
654
|
|
- return;
|
|
655
|
|
-
|
|
656
|
|
- // For some reason, this test sporadically fails when run in AppVeyor or
|
|
657
|
|
- // GitHub Actions CI environments, even though it passes locally.
|
|
658
|
|
- if ( IsAutomaticTest() )
|
|
659
|
|
- return;
|
|
660
|
|
-
|
|
661
|
656
|
CreateText(wxTE_RICH | wxTE_AUTO_URL);
|
|
662
|
657
|
|
|
663
|
658
|
m_text->AppendText("http://www.wxwidgets.org");
|
|
664
|
659
|
|
|
665
|
|
- wxUIActionSimulator sim;
|
|
666
|
|
- REQUIRE(sim.MouseMove(m_text->ClientToScreen(wxPoint(5, 5))));
|
|
|
660
|
+ YieldForAWhile();
|
|
|
661
|
+
|
|
|
662
|
+ const long urlStart = 0;
|
|
|
663
|
+ const long urlEnd = m_text->GetLastPosition();
|
|
|
664
|
+
|
|
|
665
|
+ const wxPoint posStart = m_text->PositionToCoords(urlStart);
|
|
|
666
|
+ const wxPoint posEnd = m_text->PositionToCoords(urlEnd);
|
|
|
667
|
+ REQUIRE(posStart != wxDefaultPosition);
|
|
|
668
|
+ REQUIRE(posEnd != wxDefaultPosition);
|
|
|
669
|
+
|
|
|
670
|
+ const wxPoint urlPoint((posStart.x + posEnd.x) / 2,
|
|
|
671
|
+ posStart.y +
|
|
|
672
|
+ std::max(1, m_text->GetCharHeight() / 2));
|
|
|
673
|
+
|
|
|
674
|
+ long hitPos = wxNOT_FOUND;
|
|
|
675
|
+ REQUIRE(m_text->HitTest(urlPoint, &hitPos) == wxTE_HT_ON_TEXT);
|
|
|
676
|
+ REQUIRE(hitPos >= urlStart);
|
|
|
677
|
+ REQUIRE(hitPos < urlEnd);
|
|
667
|
678
|
|
|
668
|
679
|
EventCounter url(m_text.get(), wxEVT_TEXT_URL);
|
|
669
|
680
|
|
|
|
681
|
+ wxUIActionSimulator sim;
|
|
|
682
|
+ REQUIRE(sim.MouseMove(m_text->ClientToScreen(urlPoint)));
|
|
670
|
683
|
REQUIRE(sim.MouseClick());
|
|
|
684
|
+
|
|
671
|
685
|
wxYield();
|
|
672
|
686
|
|
|
673
|
687
|
CHECK(url.GetCount() >= 1);
|
|
674
|
|
-#endif
|
|
675
|
688
|
}
|
|
|
689
|
+#endif // wxHAS_TEXT_URL_TEST
|
|
676
|
690
|
|
|
677
|
691
|
void TextCtrlTestCase::Style()
|
|
678
|
692
|
{
|
| ... |
... |
@@ -889,7 +903,7 @@ void TextCtrlTestCase::DoPositionToCoordsTestWithStyle(long style) |
|
889
|
903
|
const wxPoint pos0 = m_text->PositionToCoords(0);
|
|
890
|
904
|
if ( pos0 == wxDefaultPosition )
|
|
891
|
905
|
{
|
|
892
|
|
-#if ( wxHAS_2CHAR_NEWLINES ) || defined(__WXGTK__)
|
|
|
906
|
+#if defined(wxHAS_2CHAR_NEWLINES) || defined(__WXGTK__)
|
|
893
|
907
|
FAIL( "PositionToCoords() unexpectedly failed." );
|
|
894
|
908
|
#endif
|
|
895
|
909
|
return;
|
| ... |
... |
@@ -980,7 +994,7 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) |
|
980
|
994
|
{
|
|
981
|
995
|
CreateText(style|wxTE_MULTILINE|wxTE_DONTWRAP);
|
|
982
|
996
|
|
|
983
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
997
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
984
|
998
|
const bool isRichEdit = (style & (wxTE_RICH | wxTE_RICH2)) != 0;
|
|
985
|
999
|
#endif
|
|
986
|
1000
|
|
| ... |
... |
@@ -1031,7 +1045,7 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) |
|
1031
|
1045
|
text = wxS("123\nab\nX");
|
|
1032
|
1046
|
m_text->SetValue(text);
|
|
1033
|
1047
|
|
|
1034
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1048
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1035
|
1049
|
// Take into account that every new line mark occupies
|
|
1036
|
1050
|
// two characters, not one.
|
|
1037
|
1051
|
const long numChars_msw_2 = 8 + 2;
|
| ... |
... |
@@ -1050,14 +1064,14 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) |
|
1050
|
1064
|
{ 0, 2 }, { 1, 2 } };
|
|
1051
|
1065
|
|
|
1052
|
1066
|
const long &ref_numChars_2 =
|
|
1053
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1067
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1054
|
1068
|
isRichEdit ? numChars_2 : numChars_msw_2;
|
|
1055
|
1069
|
#else
|
|
1056
|
1070
|
numChars_2;
|
|
1057
|
1071
|
#endif
|
|
1058
|
1072
|
|
|
1059
|
1073
|
XYPos *ref_coords_2 =
|
|
1060
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1074
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1061
|
1075
|
isRichEdit ? coords_2 : coords_2_msw;
|
|
1062
|
1076
|
#else
|
|
1063
|
1077
|
coords_2;
|
| ... |
... |
@@ -1079,7 +1093,7 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) |
|
1079
|
1093
|
text = wxS("\n\n\n");
|
|
1080
|
1094
|
m_text->SetValue(text);
|
|
1081
|
1095
|
|
|
1082
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1096
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1083
|
1097
|
// Take into account that every new line mark occupies
|
|
1084
|
1098
|
// two characters, not one.
|
|
1085
|
1099
|
const long numChars_msw_3 = 3 + 3;
|
| ... |
... |
@@ -1100,14 +1114,14 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) |
|
1100
|
1114
|
{ 0, 3 } };
|
|
1101
|
1115
|
|
|
1102
|
1116
|
const long &ref_numChars_3 =
|
|
1103
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1117
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1104
|
1118
|
isRichEdit ? numChars_3 : numChars_msw_3;
|
|
1105
|
1119
|
#else
|
|
1106
|
1120
|
numChars_3;
|
|
1107
|
1121
|
#endif
|
|
1108
|
1122
|
|
|
1109
|
1123
|
XYPos *ref_coords_3 =
|
|
1110
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1124
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1111
|
1125
|
isRichEdit ? coords_3 : coords_3_msw;
|
|
1112
|
1126
|
#else
|
|
1113
|
1127
|
coords_3;
|
| ... |
... |
@@ -1129,7 +1143,7 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) |
|
1129
|
1143
|
text = wxS("123\na\n\nX\n\n");
|
|
1130
|
1144
|
m_text->SetValue(text);
|
|
1131
|
1145
|
|
|
1132
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1146
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1133
|
1147
|
// Take into account that every new line mark occupies
|
|
1134
|
1148
|
// two characters, not one.
|
|
1135
|
1149
|
const long numChars_msw_4 = 10 + 5;
|
| ... |
... |
@@ -1154,14 +1168,14 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) |
|
1154
|
1168
|
{ 0, 5 } };
|
|
1155
|
1169
|
|
|
1156
|
1170
|
const long &ref_numChars_4 =
|
|
1157
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1171
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1158
|
1172
|
isRichEdit ? numChars_4 : numChars_msw_4;
|
|
1159
|
1173
|
#else
|
|
1160
|
1174
|
numChars_4;
|
|
1161
|
1175
|
#endif
|
|
1162
|
1176
|
|
|
1163
|
1177
|
XYPos *ref_coords_4 =
|
|
1164
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1178
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1165
|
1179
|
isRichEdit ? coords_4 : coords_4_msw;
|
|
1166
|
1180
|
#else
|
|
1167
|
1181
|
coords_4;
|
| ... |
... |
@@ -1201,7 +1215,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) |
|
1201
|
1215
|
{
|
|
1202
|
1216
|
CreateText(style|wxTE_MULTILINE|wxTE_DONTWRAP);
|
|
1203
|
1217
|
|
|
1204
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1218
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1205
|
1219
|
const bool isRichEdit = (style & (wxTE_RICH | wxTE_RICH2)) != 0;
|
|
1206
|
1220
|
#endif
|
|
1207
|
1221
|
|
| ... |
... |
@@ -1245,7 +1259,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) |
|
1245
|
1259
|
const long maxLineLength_2 = 4;
|
|
1246
|
1260
|
const long numLines_2 = 3;
|
|
1247
|
1261
|
CHECK( m_text->GetNumberOfLines() == numLines_2 );
|
|
1248
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1262
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1249
|
1263
|
// Note: New lines are occupied by two characters.
|
|
1250
|
1264
|
long pos_2_msw[numLines_2 + 1][maxLineLength_2 + 1] =
|
|
1251
|
1265
|
{ { 0, 1, 2, 3, -1 }, // New line occupies positions 3, 4
|
| ... |
... |
@@ -1260,7 +1274,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) |
|
1260
|
1274
|
{ -1, -1, -1, -1, -1 } };
|
|
1261
|
1275
|
|
|
1262
|
1276
|
long (&ref_pos_2)[numLines_2 + 1][maxLineLength_2 + 1] =
|
|
1263
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1277
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1264
|
1278
|
isRichEdit ? pos_2 : pos_2_msw;
|
|
1265
|
1279
|
#else
|
|
1266
|
1280
|
pos_2;
|
| ... |
... |
@@ -1280,7 +1294,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) |
|
1280
|
1294
|
const long maxLineLength_3 = 1;
|
|
1281
|
1295
|
const long numLines_3 = 4;
|
|
1282
|
1296
|
CHECK( m_text->GetNumberOfLines() == numLines_3 );
|
|
1283
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1297
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1284
|
1298
|
// Note: New lines are occupied by two characters.
|
|
1285
|
1299
|
long pos_3_msw[numLines_3 + 1][maxLineLength_3 + 1] =
|
|
1286
|
1300
|
{ { 0, -1 }, // New line occupies positions 0, 1
|
| ... |
... |
@@ -1297,7 +1311,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) |
|
1297
|
1311
|
{ -1, -1 } };
|
|
1298
|
1312
|
|
|
1299
|
1313
|
long (&ref_pos_3)[numLines_3 + 1][maxLineLength_3 + 1] =
|
|
1300
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1314
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1301
|
1315
|
isRichEdit ? pos_3 : pos_3_msw;
|
|
1302
|
1316
|
#else
|
|
1303
|
1317
|
pos_3;
|
| ... |
... |
@@ -1317,7 +1331,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) |
|
1317
|
1331
|
const long maxLineLength_4 = 4;
|
|
1318
|
1332
|
const long numLines_4 = 6;
|
|
1319
|
1333
|
CHECK( m_text->GetNumberOfLines() == numLines_4 );
|
|
1320
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1334
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1321
|
1335
|
// Note: New lines are occupied by two characters.
|
|
1322
|
1336
|
long pos_4_msw[numLines_4 + 1][maxLineLength_4 + 1] =
|
|
1323
|
1337
|
{ { 0, 1, 2, 3, -1 }, // New line occupies positions 3, 4
|
| ... |
... |
@@ -1338,7 +1352,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) |
|
1338
|
1352
|
{ -1, -1, -1, -1, -1 } };
|
|
1339
|
1353
|
|
|
1340
|
1354
|
long (&ref_pos_4)[numLines_4 + 1][maxLineLength_4 + 1] =
|
|
1341
|
|
-#if wxHAS_2CHAR_NEWLINES
|
|
|
1355
|
+#ifdef wxHAS_2CHAR_NEWLINES
|
|
1342
|
1356
|
isRichEdit ? pos_4 : pos_4_msw;
|
|
1343
|
1357
|
#else
|
|
1344
|
1358
|
pos_4;
|