[SHELL32_APITEST]
authorThomas Faber <thomas.faber@reactos.org>
Thu, 28 Jul 2016 15:25:35 +0000 (15:25 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Thu, 28 Jul 2016 15:25:35 +0000 (15:25 +0000)
- Add a test for CShellLink::GetDescription/SetDescription
CORE-5272

svn path=/trunk/; revision=72035

rostests/apitests/shell32/CShellLink.cpp

index 62eefdb..b05f1aa 100644 (file)
@@ -155,6 +155,53 @@ test_checklinkpath(TestShellLinkDef* testDef)
     psl->Release();
 }
 
+static
+VOID
+TestDescription(void)
+{
+    HRESULT hr;
+    IShellLinkW *psl;
+    WCHAR buffer[64];
+    PCWSTR testDescription = L"This is a test description";
+
+    /* Test SetDescription */
+    hr = CoCreateInstance(CLSID_ShellLink,
+                          NULL,
+                          CLSCTX_INPROC_SERVER,
+                          IID_PPV_ARG(IShellLinkW, &psl));
+    ok(hr == S_OK, "CoCreateInstance, hr = %lx\n", hr);
+    if (FAILED(hr))
+    {
+        skip("Could not instantiate CShellLink\n");
+        return;
+    }
+
+    memset(buffer, 0x55, sizeof(buffer));
+    hr = psl->GetDescription(buffer, RTL_NUMBER_OF(buffer));
+    ok(hr == S_OK, "IShellLink::GetDescription returned hr = %lx\n", hr);
+    ok(buffer[0] == 0, "buffer[0] = %x\n", buffer[0]);
+    ok(buffer[1] == 0x5555, "buffer[1] = %x\n", buffer[1]);
+
+    hr = psl->SetDescription(testDescription);
+    ok(hr == S_OK, "IShellLink::SetDescription returned hr = %lx\n", hr);
+
+    memset(buffer, 0x55, sizeof(buffer));
+    hr = psl->GetDescription(buffer, RTL_NUMBER_OF(buffer));
+    ok(hr == S_OK, "IShellLink::GetDescription returned hr = %lx\n", hr);
+    ok(buffer[wcslen(testDescription)] == 0, "buffer[n] = %x\n", buffer[wcslen(testDescription)]);
+    ok(buffer[wcslen(testDescription) + 1] == 0x5555, "buffer[n+1] = %x\n", buffer[wcslen(testDescription) + 1]);
+    ok(!wcscmp(buffer, testDescription), "buffer = '%ls'\n", buffer);
+
+    hr = psl->SetDescription(NULL);
+    ok(hr == S_OK, "IShellLink::SetDescription returned hr = %lx\n", hr);
+
+    memset(buffer, 0x55, sizeof(buffer));
+    hr = psl->GetDescription(buffer, RTL_NUMBER_OF(buffer));
+    ok(hr == S_OK, "IShellLink::GetDescription returned hr = %lx\n", hr);
+    ok(buffer[0] == 0, "buffer[0] = %x\n", buffer[0]);
+    ok(buffer[1] == 0x5555, "buffer[1] = %x\n", buffer[1]);
+}
+
 static
 VOID
 TestShellLink(void)
@@ -176,6 +223,8 @@ TestShellLink(void)
     }
 
     SetEnvironmentVariableW(L"shell",NULL);
+
+    TestDescription();
 }
 
 START_TEST(CShellLink)