mirror of https://github.com/dahall/Vanara.git
Updated shell object tests
parent
859b7094b7
commit
b063def5da
|
@ -21,6 +21,18 @@ namespace Vanara.Windows.Shell.Tests
|
|||
var items = menu.GetItems(CMF.CMF_EXTENDEDVERBS | CMF.CMF_EXPLORE | CMF.CMF_CANRENAME | CMF.CMF_ITEMMENU);
|
||||
for (var i = 0; i < items.Length; i++)
|
||||
ShowMII(items[i], i);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateTest2()
|
||||
{
|
||||
using var shi = ShellItem.Open(TestCaseSources.ImageFile);
|
||||
using var shi2 = ShellItem.Open(TestCaseSources.Image2File);
|
||||
using var menu = new ShellContextMenu(shi, shi2);
|
||||
var items = menu.GetItems(CMF.CMF_EXTENDEDVERBS | CMF.CMF_EXPLORE | CMF.CMF_CANRENAME | CMF.CMF_ITEMMENU);
|
||||
for (var i = 0; i < items.Length; i++)
|
||||
ShowMII(items[i], i);
|
||||
}
|
||||
|
||||
static void ShowMII(ShellContextMenu.MenuItemInfo mii, int c, int indent = 0)
|
||||
{
|
||||
|
@ -29,5 +41,4 @@ namespace Vanara.Windows.Shell.Tests
|
|||
ShowMII(mii.SubMenus[j], j, indent + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -135,7 +135,7 @@ namespace Vanara.Windows.Shell.Tests
|
|||
var sv = f.GetViewObject<IShellView>(null);
|
||||
Assert.That(sv, Is.Not.Null.And.InstanceOf<IShellView>());
|
||||
Assert.That(() => f.GetChildrenUIObjects<IShellLibrary>(null, i), Throws.TypeOf<NotImplementedException>());
|
||||
Assert.That(() => f.GetViewObject<IShellLibrary>(null), Throws.TypeOf<NotImplementedException>());
|
||||
Assert.That(() => f.GetViewObject<IShellLibrary>(null), Throws.TypeOf<InvalidCastException>());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -212,9 +212,16 @@ namespace Vanara.Windows.Shell.Tests
|
|||
var handles = new List<SafeHBITMAP>();
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
Assert.That(() => handles.Add(imageFile.Images.GetImageAsync(list[i].sz, list[i].opt).Result), Throws.Nothing);
|
||||
try
|
||||
{
|
||||
handles.Add(imageFile.Images.GetImageAsync(list[i].sz, list[i].opt).Result);
|
||||
Assert.That(handles[i], ResultIs.ValidHandle);
|
||||
}
|
||||
catch (AggregateException) when (list[i].opt == ShellItemGetImageOptions.ThumbnailOnly)
|
||||
{
|
||||
handles.Add(CreateBitmap(1,1,1,1,null));
|
||||
}
|
||||
}
|
||||
//new ImageViewer(handles.Select(h => Image.FromHbitmap(h.DangerousGetHandle())).Prepend(Image.FromFile(TestCaseSources.ImageFile))).ShowDialog();
|
||||
new ImageViewer(handles.Select((h, idx) => ((Image)HToBitmap(h), $"{list[idx].opt} {list[idx].sz}"))).ShowDialog();
|
||||
foreach (var h in handles) h.Dispose();
|
||||
|
@ -253,7 +260,7 @@ namespace Vanara.Windows.Shell.Tests
|
|||
|
||||
//var bounds = new Rectangle(0, 0, width, Math.Abs(height));
|
||||
var bmp = new Bitmap(width, height, scanBytes, fmt, bits);
|
||||
if (height < 0) bmp.RotateFlip(RotateFlipType.Rotate180FlipNone);
|
||||
bmp.RotateFlip(RotateFlipType.Rotate180FlipNone);
|
||||
return bmp;
|
||||
//using var bitmap = new Bitmap(bounds.Width, bounds.Height, dib.dsBm.bmWidthBytes, fmt, dib.dsBm.bmBits);
|
||||
|
||||
|
|
|
@ -30,5 +30,14 @@ namespace Vanara.Windows.Shell.Tests
|
|||
lnk.ViewInExplorer();
|
||||
System.IO.File.Delete(fn);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPaths()
|
||||
{
|
||||
const string lnkPath = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Word.lnk";
|
||||
const string targetPath = @"C:\Program Files (x86)\Microsoft Office\root\Office16\WINWORD.EXE";
|
||||
using var lnk = new ShellLink(lnkPath);
|
||||
StringAssert.AreEqualIgnoringCase(targetPath, lnk.TargetPath);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue