Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
892a0b5f
Commit
892a0b5f
authored
May 04, 2008
by
Alex Villacís Lasso
Committed by
Alexandre Julliard
Jun 19, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
richedit: Add tests for URL autodetection for EM_SETTEXTEX, make them pass under Wine.
parent
f213af37
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
191 additions
and
0 deletions
+191
-0
editor.c
dlls/riched20/editor.c
+4
-0
editor.c
dlls/riched20/tests/editor.c
+187
-0
No files found.
dlls/riched20/editor.c
View file @
892a0b5f
...
...
@@ -2181,6 +2181,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
ME_StreamInRTFString
(
editor
,
0
,
(
char
*
)
lParam
);
else
ME_InsertTextFromCursor
(
editor
,
0
,
wszText
,
len
,
style
);
ME_ReleaseStyle
(
style
);
if
(
editor
->
AutoURLDetect_bEnable
)
ME_UpdateSelectionLinkAttribute
(
editor
);
}
else
{
ME_InternalDeleteText
(
editor
,
0
,
ME_GetTextLength
(
editor
));
...
...
@@ -2188,6 +2190,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
ME_StreamInRTFString
(
editor
,
0
,
(
char
*
)
lParam
);
else
ME_InsertTextFromCursor
(
editor
,
0
,
wszText
,
len
,
editor
->
pBuffer
->
pDefaultStyle
);
len
=
1
;
if
(
editor
->
AutoURLDetect_bEnable
)
ME_UpdateLinkAttribute
(
editor
,
0
,
-
1
);
}
ME_CommitUndo
(
editor
);
if
(
!
(
pStruct
->
flags
&
ST_KEEPUNDO
))
...
...
dlls/riched20/tests/editor.c
View file @
892a0b5f
...
...
@@ -1498,6 +1498,193 @@ static void test_EM_AUTOURLDETECT(void)
hwndRichEdit
=
NULL
;
}
/* Test detection of URLs within normal text - EM_SETTEXTEX case. */
for
(
i
=
0
;
i
<
sizeof
(
urls
)
/
sizeof
(
struct
urls_s
);
i
++
)
{
SETTEXTEX
st
;
hwndRichEdit
=
new_richedit
(
parent
);
/* There are at least three ways in which EM_SETTEXTEX must cause URLs to
be detected:
1) Set entire text, a la WM_SETTEXT
2) Set a selection of the text to the URL
3) Set a portion of the text at a time, which eventually results in
an URL
All of them should give equivalent results
*/
/* Set entire text in one go, like WM_SETTEXT */
for
(
j
=
0
;
j
<
sizeof
(
templates_delim
)
/
sizeof
(
const
char
*
);
j
++
)
{
char
*
at_pos
;
int
at_offset
;
int
end_offset
;
st
.
codepage
=
CP_ACP
;
st
.
flags
=
ST_DEFAULT
;
at_pos
=
strchr
(
templates_delim
[
j
],
'X'
);
at_offset
=
at_pos
-
templates_delim
[
j
];
strncpy
(
buffer
,
templates_delim
[
j
],
at_offset
);
buffer
[
at_offset
]
=
'\0'
;
strcat
(
buffer
,
urls
[
i
].
text
);
strcat
(
buffer
,
templates_delim
[
j
]
+
at_offset
+
1
);
end_offset
=
at_offset
+
strlen
(
urls
[
i
].
text
);
SendMessage
(
hwndRichEdit
,
EM_AUTOURLDETECT
,
TRUE
,
0
);
SendMessage
(
hwndRichEdit
,
EM_SETTEXTEX
,
(
WPARAM
)
&
st
,
(
LPARAM
)
buffer
);
/* This assumes no templates start with the URL itself, and that they
have at least two characters before the URL text */
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
0
,
1
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
0
,
1
,
buffer
);
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
at_offset
-
2
,
at_offset
-
1
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
at_offset
-
2
,
at_offset
-
1
,
buffer
);
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
at_offset
-
1
,
at_offset
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
at_offset
-
1
,
at_offset
,
buffer
);
if
(
urls
[
i
].
is_url
)
{
ok
(
check_CFE_LINK_selection
(
hwndRichEdit
,
at_offset
,
at_offset
+
1
),
"CFE_LINK not set in (%d-%d), text: %s
\n
"
,
at_offset
,
at_offset
+
1
,
buffer
);
ok
(
check_CFE_LINK_selection
(
hwndRichEdit
,
end_offset
-
1
,
end_offset
),
"CFE_LINK not set in (%d-%d), text: %s
\n
"
,
end_offset
-
1
,
end_offset
,
buffer
);
}
else
{
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
at_offset
,
at_offset
+
1
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
at_offset
,
at_offset
+
1
,
buffer
);
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
end_offset
-
1
,
end_offset
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
end_offset
-
1
,
end_offset
,
buffer
);
}
if
(
buffer
[
end_offset
]
!=
'\0'
)
{
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
end_offset
,
end_offset
+
1
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
end_offset
,
end_offset
+
1
,
buffer
);
if
(
buffer
[
end_offset
+
1
]
!=
'\0'
)
{
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
end_offset
+
1
,
end_offset
+
2
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
end_offset
+
1
,
end_offset
+
2
,
buffer
);
}
}
}
/* Set selection with X to the URL */
for
(
j
=
0
;
j
<
sizeof
(
templates_delim
)
/
sizeof
(
const
char
*
);
j
++
)
{
char
*
at_pos
;
int
at_offset
;
int
end_offset
;
at_pos
=
strchr
(
templates_delim
[
j
],
'X'
);
at_offset
=
at_pos
-
templates_delim
[
j
];
end_offset
=
at_offset
+
strlen
(
urls
[
i
].
text
);
st
.
codepage
=
CP_ACP
;
st
.
flags
=
ST_DEFAULT
;
SendMessage
(
hwndRichEdit
,
EM_AUTOURLDETECT
,
TRUE
,
0
);
SendMessage
(
hwndRichEdit
,
EM_SETTEXTEX
,
(
WPARAM
)
&
st
,
(
LPARAM
)
templates_delim
[
j
]);
st
.
flags
=
ST_SELECTION
;
SendMessage
(
hwndRichEdit
,
EM_SETSEL
,
at_offset
,
at_offset
+
1
);
SendMessage
(
hwndRichEdit
,
EM_SETTEXTEX
,
(
WPARAM
)
&
st
,
(
LPARAM
)
urls
[
i
].
text
);
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
sizeof
(
buffer
),
(
LPARAM
)
buffer
);
/* This assumes no templates start with the URL itself, and that they
have at least two characters before the URL text */
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
0
,
1
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
0
,
1
,
buffer
);
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
at_offset
-
2
,
at_offset
-
1
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
at_offset
-
2
,
at_offset
-
1
,
buffer
);
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
at_offset
-
1
,
at_offset
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
at_offset
-
1
,
at_offset
,
buffer
);
if
(
urls
[
i
].
is_url
)
{
ok
(
check_CFE_LINK_selection
(
hwndRichEdit
,
at_offset
,
at_offset
+
1
),
"CFE_LINK not set in (%d-%d), text: %s
\n
"
,
at_offset
,
at_offset
+
1
,
buffer
);
ok
(
check_CFE_LINK_selection
(
hwndRichEdit
,
end_offset
-
1
,
end_offset
),
"CFE_LINK not set in (%d-%d), text: %s
\n
"
,
end_offset
-
1
,
end_offset
,
buffer
);
}
else
{
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
at_offset
,
at_offset
+
1
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
at_offset
,
at_offset
+
1
,
buffer
);
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
end_offset
-
1
,
end_offset
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
end_offset
-
1
,
end_offset
,
buffer
);
}
if
(
buffer
[
end_offset
]
!=
'\0'
)
{
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
end_offset
,
end_offset
+
1
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
end_offset
,
end_offset
+
1
,
buffer
);
if
(
buffer
[
end_offset
+
1
]
!=
'\0'
)
{
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
end_offset
+
1
,
end_offset
+
2
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
end_offset
+
1
,
end_offset
+
2
,
buffer
);
}
}
}
/* Set selection with X to the first character of the URL, then the rest */
for
(
j
=
0
;
j
<
sizeof
(
templates_delim
)
/
sizeof
(
const
char
*
);
j
++
)
{
char
*
at_pos
;
int
at_offset
;
int
end_offset
;
at_pos
=
strchr
(
templates_delim
[
j
],
'X'
);
at_offset
=
at_pos
-
templates_delim
[
j
];
end_offset
=
at_offset
+
strlen
(
urls
[
i
].
text
);
strcpy
(
buffer
,
"YY"
);
buffer
[
0
]
=
urls
[
i
].
text
[
0
];
st
.
codepage
=
CP_ACP
;
st
.
flags
=
ST_DEFAULT
;
SendMessage
(
hwndRichEdit
,
EM_AUTOURLDETECT
,
TRUE
,
0
);
SendMessage
(
hwndRichEdit
,
EM_SETTEXTEX
,
(
WPARAM
)
&
st
,
(
LPARAM
)
templates_delim
[
j
]);
st
.
flags
=
ST_SELECTION
;
SendMessage
(
hwndRichEdit
,
EM_SETSEL
,
at_offset
,
at_offset
+
1
);
SendMessage
(
hwndRichEdit
,
EM_SETTEXTEX
,
(
WPARAM
)
&
st
,
(
LPARAM
)
buffer
);
SendMessage
(
hwndRichEdit
,
EM_SETSEL
,
at_offset
+
1
,
at_offset
+
2
);
SendMessage
(
hwndRichEdit
,
EM_SETTEXTEX
,
(
WPARAM
)
&
st
,
(
LPARAM
)(
urls
[
i
].
text
+
1
));
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
sizeof
(
buffer
),
(
LPARAM
)
buffer
);
/* This assumes no templates start with the URL itself, and that they
have at least two characters before the URL text */
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
0
,
1
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
0
,
1
,
buffer
);
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
at_offset
-
2
,
at_offset
-
1
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
at_offset
-
2
,
at_offset
-
1
,
buffer
);
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
at_offset
-
1
,
at_offset
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
at_offset
-
1
,
at_offset
,
buffer
);
if
(
urls
[
i
].
is_url
)
{
ok
(
check_CFE_LINK_selection
(
hwndRichEdit
,
at_offset
,
at_offset
+
1
),
"CFE_LINK not set in (%d-%d), text: %s
\n
"
,
at_offset
,
at_offset
+
1
,
buffer
);
ok
(
check_CFE_LINK_selection
(
hwndRichEdit
,
end_offset
-
1
,
end_offset
),
"CFE_LINK not set in (%d-%d), text: %s
\n
"
,
end_offset
-
1
,
end_offset
,
buffer
);
}
else
{
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
at_offset
,
at_offset
+
1
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
at_offset
,
at_offset
+
1
,
buffer
);
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
end_offset
-
1
,
end_offset
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
end_offset
-
1
,
end_offset
,
buffer
);
}
if
(
buffer
[
end_offset
]
!=
'\0'
)
{
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
end_offset
,
end_offset
+
1
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
end_offset
,
end_offset
+
1
,
buffer
);
if
(
buffer
[
end_offset
+
1
]
!=
'\0'
)
{
ok
(
!
check_CFE_LINK_selection
(
hwndRichEdit
,
end_offset
+
1
,
end_offset
+
2
),
"CFE_LINK incorrectly set in (%d-%d), text: %s
\n
"
,
end_offset
+
1
,
end_offset
+
2
,
buffer
);
}
}
}
DestroyWindow
(
hwndRichEdit
);
hwndRichEdit
=
NULL
;
}
DestroyWindow
(
parent
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment