[PATCH] ieframe/tests: Add some tests for Shell Embedding resizing.

Dmitry Timoshkov dmitry at baikal.ru
Mon Jun 22 04:34:48 CDT 2020


Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 dlls/ieframe/tests/webbrowser.c | 84 ++++++++++++++++++++++++++++++---
 1 file changed, 78 insertions(+), 6 deletions(-)

diff --git a/dlls/ieframe/tests/webbrowser.c b/dlls/ieframe/tests/webbrowser.c
index 95d5fc4988..9d8a4fc63d 100644
--- a/dlls/ieframe/tests/webbrowser.c
+++ b/dlls/ieframe/tests/webbrowser.c
@@ -1832,7 +1832,9 @@ static HWND create_container_window(void)
 static void test_DoVerb(IWebBrowser2 *unk)
 {
     IOleObject *oleobj;
-    RECT rect = {0,0,1000,1000};
+    IOleWindow *olewin;
+    HWND hwnd;
+    RECT rect;
     HRESULT hres;
 
     hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
@@ -1840,6 +1842,12 @@ static void test_DoVerb(IWebBrowser2 *unk)
     if(FAILED(hres))
         return;
 
+    hres = IOleObject_QueryInterface(oleobj, &IID_IOleWindow, (void**)&olewin);
+    ok(hres == S_OK, "Could not get IOleInPlaceSite: %08x\n", hres);
+
+    hres = IOleWindow_GetWindow(olewin, &hwnd);
+    ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
+
     SET_EXPECT(CanInPlaceActivate);
     SET_EXPECT(Site_GetWindow);
     SET_EXPECT(OnInPlaceActivate);
@@ -1853,10 +1861,16 @@ static void test_DoVerb(IWebBrowser2 *unk)
     SET_EXPECT(SetMenu);
     SET_EXPECT(OnFocus_TRUE);
 
+    SetRect(&rect, 0, 0, 500, 500);
     hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
                              0, (HWND)0xdeadbeef, &rect);
     ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
 
+    SetRectEmpty(&rect);
+    GetWindowRect(hwnd, &rect);
+    ok(rect.right - rect.left == 1000 && rect.bottom - rect.top == 900, "window size = {%d %d}\n",
+       rect.right - rect.left, rect.bottom - rect.top);
+
     CHECK_CALLED(CanInPlaceActivate);
     CHECK_CALLED(Site_GetWindow);
     CHECK_CALLED(OnInPlaceActivate);
@@ -1870,10 +1884,27 @@ static void test_DoVerb(IWebBrowser2 *unk)
     CHECK_CALLED(SetMenu);
     CHECK_CALLED(OnFocus_TRUE);
 
+    SetRect(&rect, 0, 0, 600, 600);
     hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
                            0, (HWND)0xdeadbeef, &rect);
     ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
 
+    SetRectEmpty(&rect);
+    GetWindowRect(hwnd, &rect);
+    ok(rect.right - rect.left == 1000 && rect.bottom - rect.top == 900, "window size = {%d %d}\n",
+       rect.right - rect.left, rect.bottom - rect.top);
+
+    SetRect(&rect, 0, 0, 700, 700);
+    hres = IOleObject_DoVerb(oleobj, OLEIVERB_UIACTIVATE, NULL, &ClientSite,
+                           0, (HWND)0xdeadbeef, &rect);
+    ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
+
+    SetRectEmpty(&rect);
+    GetWindowRect(hwnd, &rect);
+    ok(rect.right - rect.left == 1000 && rect.bottom - rect.top == 900, "window size = {%d %d}\n",
+       rect.right - rect.left, rect.bottom - rect.top);
+
+    IOleWindow_Release(olewin);
     IOleObject_Release(oleobj);
 }
 
@@ -2649,14 +2680,18 @@ static void test_GetControlInfo(IWebBrowser2 *unk)
     IOleControl_Release(control);
 }
 
-static void test_Extent(IWebBrowser2 *unk)
+static void test_Extent(IWebBrowser2 *unk, BOOL activated)
 {
     IOleObject *oleobj;
+    IOleWindow *olewin;
     SIZE size, expected;
+    RECT rc;
     HRESULT hres;
     DWORD dpi_x;
     DWORD dpi_y;
     HDC hdc;
+    HWND hwnd;
+    char buf[256];
 
     /* default aspect ratio is 96dpi / 96dpi */
     hdc = GetDC(0);
@@ -2671,15 +2706,41 @@ static void test_Extent(IWebBrowser2 *unk)
     if(FAILED(hres))
         return;
 
+    hres = IOleObject_QueryInterface(oleobj, &IID_IOleWindow, (void**)&olewin);
+    ok(hres == S_OK, "Could not get IOleInPlaceSite: %08x\n", hres);
+
+    hres = IOleWindow_GetWindow(olewin, &hwnd);
+    ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
+
+    buf[0] = 0;
+    GetClassNameA(hwnd, buf, sizeof(buf));
+    ok(!strcmp(buf, "Shell Embedding"), "got %s\n", buf);
+
     size.cx = size.cy = 0xdeadbeef;
     hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
-    /* Default size is 50x20 pixels, in himetric units */
-    expected.cx = MulDiv( 50, 2540, dpi_x );
-    expected.cy = MulDiv( 20, 2540, dpi_y );
+    if(activated) {
+        /* FIXME: what is 300x150 coming from? */
+        expected.cx = MulDiv( 300, 2540, dpi_x );
+        expected.cy = MulDiv( 150, 2540, dpi_y );
+    }else {
+        /* Default size is 50x20 pixels, in himetric units */
+        expected.cx = MulDiv( 50, 2540, dpi_x );
+        expected.cy = MulDiv( 20, 2540, dpi_y );
+    }
+todo_wine_if(activated)
     ok(size.cx == expected.cx && size.cy == expected.cy, "size = {%d %d} (expected %d %d)\n",
        size.cx, size.cy, expected.cx, expected.cy );
 
+    SetRectEmpty(&rc);
+    GetWindowRect(hwnd, &rc);
+    if(activated)
+        /* window size should match what was set by last ::SetExtent() before activation */
+        ok(rc.right - rc.left == 1000 && rc.bottom - rc.top == 900, "window size = {%d %d}\n",
+           rc.right - rc.left, rc.bottom - rc.top);
+    else
+        ok(IsRectEmpty(&rc), "window size = {%d %d}\n", rc.right - rc.left, rc.bottom - rc.top);
+
     size.cx = 800;
     size.cy = 700;
     hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &size);
@@ -2695,6 +2756,15 @@ static void test_Extent(IWebBrowser2 *unk)
     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
     ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
 
+    SetRectEmpty(&rc);
+    GetWindowRect(hwnd, &rc);
+    if(activated)
+        /* window size should match what was set by last ::SetExtent() before activation */
+        ok(rc.right - rc.left == 1000 && rc.bottom - rc.top == 900, "window size = {%d %d}\n",
+           rc.right - rc.left, rc.bottom - rc.top);
+    else
+        ok(IsRectEmpty(&rc), "window size = {%d %d}\n", rc.right - rc.left, rc.bottom - rc.top);
+
     size.cx = 900;
     size.cy = 800;
     hres = IOleObject_SetExtent(oleobj, 0, &size);
@@ -2725,6 +2795,7 @@ static void test_Extent(IWebBrowser2 *unk)
     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
     ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
 
+    IOleWindow_Release(olewin);
     IOleObject_Release(oleobj);
 }
 
@@ -3754,9 +3825,10 @@ static void test_WebBrowser(DWORD flags, BOOL do_close)
     test_LocationURL(webbrowser, L"");
     test_ConnectionPoint(webbrowser, TRUE);
     test_ClientSite(webbrowser, &ClientSite, !do_download);
-    test_Extent(webbrowser);
+    test_Extent(webbrowser, FALSE);
     test_wb_funcs(webbrowser, TRUE);
     test_DoVerb(webbrowser);
+    test_Extent(webbrowser, TRUE);
     test_olecmd(webbrowser, FALSE);
     test_Navigate2(webbrowser, L"about:blank");
     test_QueryStatusWB(webbrowser, TRUE);
-- 
2.26.2




More information about the wine-devel mailing list