Commit eb59527f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

scrrun/tests: Add some tests for DoOpenPipeStream().

parent 8f8fe74f
...@@ -839,6 +839,13 @@ static HRESULT create_textstream(const WCHAR *filename, DWORD disposition, IOMod ...@@ -839,6 +839,13 @@ static HRESULT create_textstream(const WCHAR *filename, DWORD disposition, IOMod
return S_OK; return S_OK;
} }
HRESULT WINAPI DoOpenPipeStream(HANDLE pipe, IOMode mode, ITextStream **stream)
{
FIXME("%p, %d, %p.\n", pipe, mode, stream);
return E_NOTIMPL;
}
static HRESULT WINAPI drive_QueryInterface(IDrive *iface, REFIID riid, void **obj) static HRESULT WINAPI drive_QueryInterface(IDrive *iface, REFIID riid, void **obj)
{ {
struct drive *This = impl_from_IDrive(iface); struct drive *This = impl_from_IDrive(iface);
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
@ stdcall -private DllGetClassObject(ptr ptr ptr) @ stdcall -private DllGetClassObject(ptr ptr ptr)
@ stdcall -private DllRegisterServer() @ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer() @ stdcall -private DllUnregisterServer()
@ stub DoOpenPipeStream @ stdcall DoOpenPipeStream(long long ptr)
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
static IFileSystem3 *fs3; static IFileSystem3 *fs3;
static HRESULT (WINAPI *pDoOpenPipeStream)(HANDLE pipe, DWORD mode, ITextStream **stream);
/* w2k and 2k3 error code. */ /* w2k and 2k3 error code. */
#define E_VAR_NOT_SET 0x800a005b #define E_VAR_NOT_SET 0x800a005b
...@@ -2590,6 +2592,91 @@ static void test_MoveFile(void) ...@@ -2590,6 +2592,91 @@ static void test_MoveFile(void)
SysFreeString(str); SysFreeString(str);
} }
static void test_DoOpenPipeStream(void)
{
static const char testdata[] = "test";
ITextStream *stream_read, *stream_write;
SECURITY_ATTRIBUTES pipe_attr;
HANDLE piperead, pipewrite;
DWORD written;
HRESULT hr;
BSTR str;
BOOL ret;
pDoOpenPipeStream = (void *)GetProcAddress(GetModuleHandleA("scrrun.dll"), "DoOpenPipeStream");
pipe_attr.nLength = sizeof(SECURITY_ATTRIBUTES);
pipe_attr.bInheritHandle = TRUE;
pipe_attr.lpSecurityDescriptor = NULL;
ret = CreatePipe(&piperead, &pipewrite, &pipe_attr, 0);
ok(ret, "Failed to create pipes.\n");
hr = pDoOpenPipeStream(piperead, ForReading, &stream_read);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
ok(!!stream_read, "Unexpected stream pointer.\n");
ret = WriteFile(pipewrite, testdata, sizeof(testdata), &written, NULL);
ok(ret, "Failed to write to the pipe.\n");
ok(written == sizeof(testdata), "Write to anonymous pipe wrote %d bytes.\n", written);
hr = ITextStream_Read(stream_read, 4, &str);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!wcscmp(str, L"test"), "Unexpected data read %s.\n", wine_dbgstr_w(str));
SysFreeString(str);
ITextStream_Release(stream_read);
}
ret = CloseHandle(pipewrite);
ok(ret, "Unexpected return value.\n");
/* Stream takes ownership. */
ret = CloseHandle(piperead);
todo_wine
ok(!ret, "Unexpected return value.\n");
/* Streams on both ends. */
ret = CreatePipe(&piperead, &pipewrite, &pipe_attr, 0);
ok(ret, "Failed to create pipes.\n");
stream_read = NULL;
hr = pDoOpenPipeStream(piperead, ForReading, &stream_read);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
stream_write = NULL;
hr = pDoOpenPipeStream(pipewrite, ForWriting, &stream_write);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
str = SysAllocString(L"data");
hr = ITextStream_Write(stream_write, str);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = ITextStream_Write(stream_read, str);
ok(hr == CTL_E_BADFILEMODE, "Unexpected hr %#x.\n", hr);
SysFreeString(str);
hr = ITextStream_Read(stream_write, 1, &str);
ok(hr == CTL_E_BADFILEMODE, "Unexpected hr %#x.\n", hr);
hr = ITextStream_Read(stream_read, 4, &str);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!wcscmp(str, L"data"), "Unexpected data.\n");
SysFreeString(str);
}
if (stream_read)
ITextStream_Release(stream_read);
if (stream_write)
ITextStream_Release(stream_write);
}
START_TEST(filesystem) START_TEST(filesystem)
{ {
HRESULT hr; HRESULT hr;
...@@ -2632,6 +2719,7 @@ START_TEST(filesystem) ...@@ -2632,6 +2719,7 @@ START_TEST(filesystem)
test_GetExtensionName(); test_GetExtensionName();
test_GetSpecialFolder(); test_GetSpecialFolder();
test_MoveFile(); test_MoveFile();
test_DoOpenPipeStream();
IFileSystem3_Release(fs3); IFileSystem3_Release(fs3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment