[PATCH] riched20: Implement tests for IText{Selection, Range}::Set{Start, End}.

Jactry Zeng jactry92 at gmail.com
Wed May 8 07:28:23 CDT 2019


Hi Vijay,

Thanks for your upstreaming work!
I think we don't need it for current Wine, since we already had
test_ITextSelection_GetStart_GetEnd() and test_ITextRange_GetStart_GetEnd()
doing something similar for it.

On Wed, May 8, 2019 at 10:06 AM Vijay Kiran Kamuju <infyquest at gmail.com>
wrote:

> From: Jactry Zeng <wine at jactry.com>
>
> V2: convert macros to static functions (Vijay Kiran Kamuju)
>
> Signed-off-by: Vijay Kiran Kamuju <infyquest at gmail.com>
> ---
>  dlls/riched20/tests/richole.c | 163 ++++++++++++++++++++++++++++++++++
>  1 file changed, 163 insertions(+)
>
> diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
> index 40feb76f2b..38d28fb0e2 100644
> --- a/dlls/riched20/tests/richole.c
> +++ b/dlls/riched20/tests/richole.c
> @@ -3763,6 +3763,165 @@ static void test_MoveEnd(void)
>    ITextRange_Release(range);
>  }
>
> +#define CHECK_RANGE_START(txtrange, pos, expected_start, expected_end) \
> +  _check_range_start(txtrange, pos, expected_start, expected_end,
> __LINE__)
> +static void _check_range_start(ITextRange *txtrange, LONG pos, LONG
> expected_start, LONG expected_end, int line)
> +{
> +  HRESULT hres;
> +  LONG start, end;
> +
> +  hres = ITextRange_SetStart(txtrange, pos);
> +  ok_(__FILE__,line)(hres == S_OK, "ITextRange_SetStart\n");
> +  ITextRange_GetStart(txtrange, &start);
> +  ITextRange_GetEnd(txtrange, &end);
> +  ok_(__FILE__,line)(start == expected_start, "got wrong start value:
> %d\n", start);
> +  ok_(__FILE__,line)(end == expected_end, "got wrong end value: %d\n",
> end);
> +}
> +
> +static void test_ITextRange_SetStart(void)
> +{
> +  HWND w;
> +  IRichEditOle *reOle = NULL;
> +  ITextDocument *txtDoc = NULL;
> +  ITextRange *txtRge = NULL;
> +  HRESULT hr;
> +  LONG first, lim;
> +  static const CHAR test_text1[] = "TestSomeText";
> +
> +  create_interfaces(&w, &reOle, &txtDoc, NULL);
> +  SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
> +
> +  first = 4, lim = 8;
> +  ITextDocument_Range(txtDoc, first, lim, &txtRge);
> +  hr = ITextRange_SetStart(txtRge, first);
> +  ok(hr == S_FALSE, "ITextRange_SetStart\n");
> +
> +  CHECK_RANGE_START(txtRge, 2, 2, 8);
> +  CHECK_RANGE_START(txtRge, -1, 0, 8);
> +  CHECK_RANGE_START(txtRge, 13, 12, 12);
> +
> +  release_interfaces(&w, &reOle, &txtDoc, NULL);
> +}
> +
> +#define CHECK_RANGE_END(txtrange, pos, expected_start, expected_end) \
> +  _check_range_end(txtrange, pos, expected_start, expected_end, __LINE__)
> +static void _check_range_end(ITextRange *txtrange, LONG pos, LONG
> expected_start, LONG expected_end, int line)
> +{
> +  HRESULT hres;
> +  LONG start, end;
> +
> +  hres = ITextRange_SetEnd(txtrange, pos);
> +  ok_(__FILE__,line)(hres == S_OK, "ITextRange_SetEnd\n");
> +  ITextRange_GetStart(txtrange, &start);
> +  ITextRange_GetEnd(txtrange, &end);
> +  ok_(__FILE__,line)(start == expected_start, "got wrong start value:
> %d\n", start);
> +  ok_(__FILE__,line)(end == expected_end, "got wrong end value: %d\n",
> end);
> +}
> +
> +static void test_ITextRange_SetEnd(void)
> +{
> +  HWND w;
> +  IRichEditOle *reOle = NULL;
> +  ITextDocument *txtDoc = NULL;
> +  ITextRange *txtRge = NULL;
> +  HRESULT hr;
> +  LONG first, lim;
> +  static const CHAR test_text1[] = "TestSomeText";
> +
> +  create_interfaces(&w, &reOle, &txtDoc, NULL);
> +  SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
> +
> +  first = 4, lim = 8;
> +  ITextDocument_Range(txtDoc, first, lim, &txtRge);
> +  hr = ITextRange_SetEnd(txtRge, lim);
> +  ok(hr == S_FALSE, "ITextRange_SetEnd\n");
> +
> +  CHECK_RANGE_END(txtRge, 6, 4, 6);
> +  CHECK_RANGE_END(txtRge, 14, 4, 13);
> +  CHECK_RANGE_END(txtRge, -1, 0, 0);
> +
> +  ITextRange_Release(txtRge);
> +  release_interfaces(&w, &reOle, &txtDoc, NULL);
> +}
> +
> +#define CHECK_SELECTION_START(hwnd, txtselect, pos, expected_start,
> expected_end) \
> +  _check_selection_start(hwnd, txtselect, pos, expected_start,
> expected_end, __LINE__)
> +static void _check_selection_start(HWND hwnd, ITextSelection *txtselect,
> LONG pos, LONG expected_start, LONG expected_end, int line)
> +{
> +  HRESULT hres;
> +  LONG start, end;
> +
> +  hres = ITextSelection_SetStart(txtselect, pos);
> +  ok_(__FILE__,line)(hres == S_OK, "ITextSelection_SetStart\n");
> +  SendMessageA(hwnd, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);           \
> +  ok_(__FILE__,line)(start == expected_start, "got wrong start value:
> %d\n", start);
> +  ok_(__FILE__,line)(end == expected_end, "got wrong end value: %d\n",
> end);
> +}
> +
> +static void test_ITextSelection_SetStart(void)
> +{
> +  HWND w;
> +  IRichEditOle *reOle = NULL;
> +  ITextDocument *txtDoc = NULL;
> +  ITextSelection *txtSel = NULL;
> +  HRESULT hr;
> +  LONG first, lim;
> +  static const CHAR test_text1[] = "TestSomeText";
> +
> +  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
> +  SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
> +
> +  first = 4, lim = 8;
> +  SendMessageA(w, EM_SETSEL, first, lim);
> +  hr = ITextSelection_SetStart(txtSel, first);
> +  ok(hr == S_FALSE, "ITextSelection_SetStart\n");
> +
> +  CHECK_SELECTION_START(w, txtSel, 2, 2, 8);
> +  CHECK_SELECTION_START(w, txtSel, -1, 0, 8);
> +  CHECK_SELECTION_START(w, txtSel, 13, 12, 12);
> +
> +  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
> +}
> +
> +#define CHECK_SELECTION_END(hwnd, txtselect, pos, expected_start,
> expected_end) \
> +  _check_selection_end(hwnd, txtselect, pos, expected_start,
> expected_end, __LINE__)
> +static void _check_selection_end(HWND hwnd, ITextSelection *txtselect,
> LONG pos, LONG expected_start, LONG expected_end, int line)
> +{
> +  HRESULT hres;
> +  LONG start, end;
> +
> +  hres = ITextSelection_SetEnd(txtselect, pos);
> +  ok_(__FILE__,line)(hres == S_OK, "ITextSelection_SetEnd\n");
> +  SendMessageA(hwnd, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);           \
> +  ok_(__FILE__,line)(start == expected_start, "got wrong start value:
> %d\n", start);
> +  ok_(__FILE__,line)(end == expected_end, "got wrong end value: %d\n",
> end);
> +}
> +
> +static void test_ITextSelection_SetEnd(void)
> +{
> +  HWND w;
> +  IRichEditOle *reOle = NULL;
> +  ITextDocument *txtDoc = NULL;
> +  ITextSelection *txtSel = NULL;
> +  HRESULT hr;
> +  LONG first, lim;
> +  static const CHAR test_text1[] = "TestSomeText";
> +
> +  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
> +  SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
> +
> +  first = 4, lim = 8;
> +  SendMessageA(w, EM_SETSEL, first, lim);
> +  hr = ITextSelection_SetEnd(txtSel, lim);
> +  ok(hr == S_FALSE, "ITextSelection_SetEnd\n");
> +
> +  CHECK_SELECTION_END(w, txtSel, 6, 4, 6);
> +  CHECK_SELECTION_END(w, txtSel, 14, 4, 13);
> +  CHECK_SELECTION_END(w, txtSel, -1, 0, 0);
> +
> +  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
> +}
> +
>  START_TEST(richole)
>  {
>    /* Must explicitly LoadLibrary(). The test has no references to
> functions in
> @@ -3775,12 +3934,16 @@ START_TEST(richole)
>    test_GetText();
>    test_ITextSelection_GetChar();
>    test_ITextSelection_GetStart_GetEnd();
> +  test_ITextSelection_SetStart();
> +  test_ITextSelection_SetEnd();
>    test_ITextSelection_Collapse();
>    test_ITextDocument_Range();
>    test_ITextRange_GetChar();
>    test_ITextRange_ScrollIntoView();
>    test_ITextRange_GetStart_GetEnd();
>    test_ITextRange_GetDuplicate();
> +  test_ITextRange_SetStart();
> +  test_ITextRange_SetEnd();
>    test_ITextRange_Collapse();
>    test_GetClientSite();
>    test_IOleWindow_GetWindow();
> --
> 2.21.0
>
>
>
>

-- 
Regards,
Jactry Zeng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20190508/385c01eb/attachment-0001.html>


More information about the wine-devel mailing list