Signed-off-by: Nigel Baillie metreckk@gmail.com --- dlls/shell32/tests/shlview.c | 89 ++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+)
diff --git a/dlls/shell32/tests/shlview.c b/dlls/shell32/tests/shlview.c index f5d96c8d44..4d0cf641a7 100644 --- a/dlls/shell32/tests/shlview.c +++ b/dlls/shell32/tests/shlview.c @@ -1502,6 +1502,94 @@ todo_wine IUnknown_Release(unk); }
+static void do_events(void) +{ + MSG msg; + while(PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)){ + TranslateMessage(&msg); + DispatchMessageA(&msg); + } +} + +static void test_external_change(void) +{ + IShellFolder *desktop, *folder; + FOLDERSETTINGS settings; + IShellView *view; + IShellBrowser *browser; + IFolderView *fv; + HWND hwnd_view; + LPITEMIDLIST pidl; + HRESULT hr; + HANDLE file; + INT count; + RECT r; + BOOLEAN b; + static const WCHAR test_folder_path[] = + {'C',':','\','s','h','l','v','i','e','w','_','t','e','s','t',0}; + static const WCHAR test_file_path[] = + {'C',':','\','s','h','l','v','i','e','w','_','t','e','s','t','\','f','.','t','x','t',0}; + + /* create test folder, get a PIDL to it */ + b = CreateDirectoryW(test_folder_path, NULL); + ok(b, "failed to create test directory\n"); + + pidl = ILCreateFromPathW(test_folder_path); + ok(pidl != NULL, "couldn't get a PIDL to the test directory\n"); + + /* Get an IFolderView for the test folder */ + hr = SHGetDesktopFolder(&desktop); + ok(hr == S_OK, "got (0x%08x) when trying to grab desktop folder\n", hr); + + hr = IShellFolder_BindToObject(desktop, pidl, NULL, &IID_IShellFolder, (void**)&folder); + ok(hr == S_OK, "got (0x%08x) from BindToObject\n", hr); + + hr = IShellFolder_CreateViewObject(folder, NULL, &IID_IShellView, (void**)&view); + ok(hr == S_OK, "got (0x%08x) from CreateViewObject\n", hr); + + hr = IShellView_QueryInterface(view, &IID_IFolderView, (void**)&fv); + ok(hr == S_OK, "got (0x%08x) when trying to get an IFolderView interface\n", hr); + + /* create window */ + browser = IShellBrowserImpl_Construct(); + settings.ViewMode = FVM_ICON; + settings.fFlags = 0; + hwnd_view = (HWND)0xdeadbeef; + SetRect(&r, 0, 0, 100, 100); + hr = IShellView_CreateViewWindow(view, NULL, &settings, browser, &r, &hwnd_view); + ok(hr == S_OK, "got (0x%08x) when trying to create view window\n", hr); + ok(IsWindow(hwnd_view), "got %p instead of a valid HWND\n", hwnd_view); + + /* item count should be zero */ + IFolderView_ItemCount(fv, SVGIO_ALLVIEW, &count); + ok(count == 0, "count should've been 0, but was %i\n", count); + + /* create test file */ + file = CreateFileW(test_file_path, 0, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + ok(file != INVALID_HANDLE_VALUE, "failed to create test file\n"); + if (file != INVALID_HANDLE_VALUE) + CloseHandle(file); /* we don't actually need the file open */ + + /* let the shlview figure out that it was created */ + Sleep(1000); + do_events(); + + /* it should now show the new file! */ + IFolderView_ItemCount(fv, SVGIO_ALLVIEW, &count); + ok(count == 1, "count should've been 1, but was %i\n", count); + + /* cleanup */ + hr = IShellView_DestroyViewWindow(view); + DeleteFileW(test_file_path); + RemoveDirectoryW(test_folder_path); + IShellBrowser_Release(browser); + IFolderView_Release(fv); + IShellView_Release(view); + IShellFolder_Release(desktop); +} + START_TEST(shlview) { OleInitialize(NULL); @@ -1518,6 +1606,7 @@ START_TEST(shlview) test_SHCreateShellFolderView(); test_SHCreateShellFolderViewEx(); test_newmenu(); + test_external_change();
OleUninitialize(); }