-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some StdComponentCategoriesManager tests
- Loading branch information
1 parent
b2c883d
commit 1df1f32
Showing
9 changed files
with
95 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Jeremy W. Kuhne. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Windows.Win32.System.Com; | ||
|
||
public static class CATID | ||
{ | ||
/// <summary> | ||
/// ActiveX control category id. | ||
/// </summary> | ||
public static Guid Control { get; } | ||
// 40fc6ed4-2438-11cf-a3db-080036f12502 | ||
= new(0x40fc6ed4, 0x2438, 0x11cf, 0xa3, 0xdb, 0x08, 0x00, 0x36, 0xf1, 0x25, 0x02); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/thirtytwo_tests/Win32/System/Com/ComponentCategoriesManagerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Jeremy W. Kuhne. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Windows.Win32; | ||
using Windows.Win32.Foundation; | ||
using Windows.Win32.System.Com; | ||
|
||
namespace Tests.Windows.Win32.System.Com; | ||
|
||
public unsafe class ComponentCategoriesManagerTests | ||
{ | ||
[StaFact] | ||
public void EnumerateCategories() | ||
{ | ||
using AgileComPointer<IUnknown> unknown = new(ComHelpers.CreateComClass(CLSID.StdComponentCategoriesManager), takeOwnership: true); | ||
using var categoriesInfo = unknown.TryGetInterface<ICatInformation>(out HRESULT hr); | ||
|
||
using ComScope<IEnumCATEGORYINFO> enumCategories = new(null); | ||
hr = categoriesInfo.Value->EnumCategories(Interop.GetUserDefaultLCID(), enumCategories); | ||
|
||
Dictionary<Guid, string> categories = new(); | ||
CATEGORYINFO categoryInfo = default; | ||
uint fetched = 0; | ||
while (enumCategories.Value->Next(1, &categoryInfo, &fetched).Succeeded && fetched == 1) | ||
{ | ||
categories.Add(categoryInfo.catid, categoryInfo.szDescription.ToString()); | ||
} | ||
|
||
categories.Should().Contain(new KeyValuePair<Guid, string>(CATID.Control, "Controls")); | ||
} | ||
|
||
[StaFact] | ||
public void EnumerateActiveXClasses() | ||
{ | ||
using AgileComPointer<IUnknown> unknown = new(ComHelpers.CreateComClass(CLSID.StdComponentCategoriesManager), takeOwnership: true); | ||
using var categoriesInfo = unknown.TryGetInterface<ICatInformation>(out HRESULT hr); | ||
|
||
using ComScope<IEnumGUID> enumGuids = new(null); | ||
Guid control = CATID.Control; | ||
hr = categoriesInfo.Value->EnumClassesOfCategories(1, &control, 0, null, enumGuids); | ||
hr.Succeeded.Should().BeTrue(); | ||
|
||
List<Guid> classGuids = new(); | ||
Guid guid = default; | ||
uint fetched = 0; | ||
while (enumGuids.Value->Next(1, &guid, &fetched).Succeeded && fetched == 1) | ||
{ | ||
classGuids.Add(guid); | ||
} | ||
|
||
classGuids.Should().Contain(CLSID.WindowsMediaPlayer); | ||
} | ||
} |