Skip to content

Commit

Permalink
Adds the HLK APO tests to the public github for windows-driver-sample…
Browse files Browse the repository at this point in the history
…s. (microsoft#597)

This change is to add the HLK APO tests to the windows-driver-samples to allow for any partners to take a look at the tests to know what exactly is being tested when they run the HLK APO tests.
  • Loading branch information
brober-msft authored Mar 29, 2021
1 parent db96264 commit 24e0600
Show file tree
Hide file tree
Showing 23 changed files with 4,839 additions and 0 deletions.
1,120 changes: 1,120 additions & 0 deletions audio/tests/HLK/ThirdPartyApoTests/APODeviceTest.cpp

Large diffs are not rendered by default.

180 changes: 180 additions & 0 deletions audio/tests/HLK/ThirdPartyApoTests/APODeviceTest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
#include <stdafx.h>

class CApoDeviceTests;

class CAPODevice
{
public:
CAPODevice
(
IMMDevice *pIEndpoint,
LPCWSTR pszClassId,
LPCWSTR pszEndpoint,
IPropertyStore *pIStoreDevice,
IPropertyStore *pIStoreFx,
LPARAM apoType,
LPCWSTR apoName,
LPCWSTR pszAttachedDevice,
BOOL bProxyAPO
);
CAPODevice
(
IAudioProcessingObject *pIAPO,
LPCWSTR pszClassId
);
~CAPODevice(void);
HRESULT InitializeAPO(IAudioProcessingObject *pIAPO);
DWORD GetDeviceType() { return (DWORD)(m_lpType); }
BOOL IsValid() { return (m_fValid); }
void GetClsID(GUID *pgClsID) { *pgClsID = m_gClsID; }
HRESULT GetAPOInterfaces
(
IAudioProcessingObject **pIAPO,
IAudioProcessingObjectRT **pIAPORT,
IAudioProcessingObjectConfiguration **pIAPOConfig
);
IUnknown *GetObject() { return ((IUnknown*)m_pIUnknown.get()); }
IMMDevice *GetEndpoint() { return m_pIEndpoint.get(); }
IPropertyStore *GetEndpointStore() { return m_pIEPStore.get(); }
IPropertyStore *GetFxStore() { return m_pIFXStore.get(); }
IMMDeviceCollection *GetDeviceCollection() { return m_pIDevCollection.get(); }
UINT GetSoftwareIoDeviceInCollection() { return m_nSoftwareIoDeviceInCollection; }
UINT GetSoftwareIoConnectorIndex() { return m_nSoftwareIoConnectorIndex; }
PAPO_REG_PROPERTIES GetProperties() { return (m_pRegProps); }
LPSTR GetAttachedDevice() { return (LPSTR)(m_szAttachedDevice.get()); }
BOOL IsProxyApo() { return m_bProxyAPO; }

BOOL m_fSelected; // if TRUE, this device will be selected
wil::unique_cotaskmem_string m_szEndpoint;
wil::unique_cotaskmem_string m_sApoName;
wil::unique_cotaskmem_string m_sApoTypeName;

private:
BOOL m_fValid;
GUID m_gClsID;
wil::com_ptr_nothrow<IUnknown> m_pIUnknown;
wil::com_ptr_nothrow<IAudioProcessingObject> m_pIAPO;
PAPO_REG_PROPERTIES m_pRegProps;

// These are only used for SysFx
wil::com_ptr_nothrow<IMMDevice> m_pIEndpoint;
wil::unique_cotaskmem_string m_szAttachedDevice;
wil::com_ptr_nothrow<IPropertyStore> m_pIEPStore;
wil::com_ptr_nothrow<IPropertyStore> m_pIFXStore;
wil::com_ptr_nothrow<IMMDeviceCollection> m_pIDevCollection;
UINT m_nSoftwareIoDeviceInCollection;
UINT m_nSoftwareIoConnectorIndex;
BOOL m_bProxyAPO;
wil::unique_cotaskmem_string m_szPnPId; // a string that represents the PnPId (or other description) of the device under test
LPARAM m_lpType; // flags that will be intersected with test case flags
};


// ----------------------------------------------------------
// Stores a list of APO devices on an endpoint pDevice
// The list is populated using AddSysFxDevices and accessed
// using m_DeviceList
// ----------------------------------------------------------
class CAPODeviceList
{
public:
CAPODeviceList();
~CAPODeviceList(VOID);

HRESULT Initialize(wil::com_ptr_nothrow<IMMDevice> pDevice, LPWSTR deviceName);
HRESULT AddSysFxDevices();

protected:
friend class CApoDeviceTests;

std::list<std::unique_ptr<CAPODevice>> m_DeviceList;
wil::com_ptr_nothrow<IMMDevice> m_spDevice;
WCHAR m_deviceName[MAX_PATH] = { '\0' };
};

class CApoDeviceTests : public WEX::TestClass<CApoDeviceTests>
{
CApoDeviceTests(){};
~CApoDeviceTests(){};

BEGIN_TEST_CLASS(CApoDeviceTests)
START_APPVERIFIFER
TEST_CLASS_PROPERTY(L"Owner", L"auddev")
TEST_CLASS_PROPERTY(L"TestClassification", L"Feature")
TEST_CLASS_PROPERTY(L"BinaryUnderTest", L"audiodg.exe")
TEST_CLASS_PROPERTY(L"ArtifactUnderTest", L"audioenginebaseapop.h")
TEST_CLASS_PROPERTY(L"ArtifactUnderTest", L"devicetopologyp.h")
TEST_CLASS_PROPERTY(L"RunAs", L"Elevated")
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"Ignore", L"false")
END_APPVERIFIER
END_TEST_CLASS()

public:
TEST_METHOD_SETUP(setUpMethod);
TEST_METHOD_CLEANUP(tearDownMethod);

protected:
BEGIN_TEST_METHOD(TestAPOInitialize)
COMMON_ONECORE_TEST_PROPERTIES
TEST_METHOD_PROPERTY(L"Kits.TestId", L"ED37B03B-F091-4C8D-9EDD-FE7EC803BC8E")
TEST_METHOD_PROPERTY(L"Kits.TestId2", L"5B0F542E-719A-4949-A9DF-F8BBAC0E9912")
TEST_METHOD_PROPERTY(L"Kits.TestName", L"Audio APO - Verify APO Initializes - TestAPOInitialize")
TEST_METHOD_PROPERTY(L"Kits.ExpectedRuntime", L"1")
TEST_METHOD_PROPERTY(L"Kits.TimeoutInMinutes", L"5")
TEST_METHOD_PROPERTY(L"Kits.Description", L"Third Party APO Test: TestAPOInitialize")
APO_TEST_PROPERTIES
END_TEST_METHOD()

BEGIN_TEST_METHOD(TestCustomFormatSupport)
COMMON_ONECORE_TEST_PROPERTIES
TEST_METHOD_PROPERTY(L"Kits.TestId", L"571BD021-64F5-4CD1-9BA4-8ABD0857025F")
TEST_METHOD_PROPERTY(L"Kits.TestId2", L"EB313E34-CD9D-410B-9C6F-E7032C74F4D1")
TEST_METHOD_PROPERTY(L"Kits.TestName", L"Audio APO - Verify All Formats on Device are Valid - TestCustomFormatSupport")
TEST_METHOD_PROPERTY(L"Kits.ExpectedRuntime", L"1")
TEST_METHOD_PROPERTY(L"Kits.TimeoutInMinutes", L"5")
TEST_METHOD_PROPERTY(L"Kits.Description", L"Third Party APO Test: TestCustomFormatSupport")
APO_TEST_PROPERTIES
END_TEST_METHOD()

BEGIN_TEST_METHOD(TestValidFrameCount)
COMMON_ONECORE_TEST_PROPERTIES
TEST_METHOD_PROPERTY(L"Kits.TestId", L"B9E9F61A-2882-4256-ABA8-D57A46E54B76")
TEST_METHOD_PROPERTY(L"Kits.TestId2", L"ABE4D880-7F1A-434C-A7B9-248FFA96D2CF")
TEST_METHOD_PROPERTY(L"Kits.TestName", L"Audio APO - Verify Frame Count is Valid - TestValidFrameCount")
TEST_METHOD_PROPERTY(L"Kits.ExpectedRuntime", L"1")
TEST_METHOD_PROPERTY(L"Kits.TimeoutInMinutes", L"5")
TEST_METHOD_PROPERTY(L"Kits.Description", L"Third Party APO Test: TestValidFrameCount")
APO_TEST_PROPERTIES
END_TEST_METHOD()

BEGIN_TEST_METHOD(TestAPODataStreaming)
COMMON_ONECORE_TEST_PROPERTIES
TEST_METHOD_PROPERTY(L"Kits.TestId", L"D327B019-99E4-41BD-BF66-AF1A92801DAC")
TEST_METHOD_PROPERTY(L"Kits.TestId2", L"9EBF7FC3-7ADB-49A1-B0E0-C7501841E05A")
TEST_METHOD_PROPERTY(L"Kits.TestName", L"Audio APO - Verify APO Streams Data - TestAPODataStreaming")
TEST_METHOD_PROPERTY(L"Kits.ExpectedRuntime", L"1")
TEST_METHOD_PROPERTY(L"Kits.TimeoutInMinutes", L"5")
TEST_METHOD_PROPERTY(L"Kits.Description", L"Third Party APO Test: TestAPODataStreaming")
APO_TEST_PROPERTIES
END_TEST_METHOD()

BEGIN_TEST_METHOD(TestActivateDeactivate)
COMMON_ONECORE_TEST_PROPERTIES
TEST_METHOD_PROPERTY(L"Kits.TestId", L"D1C21041-9080-4990-B6A2-5F718649A3F2")
TEST_METHOD_PROPERTY(L"Kits.TestId2", L"F0556EDA-4757-409F-AE89-C5C1B0E31A84")
TEST_METHOD_PROPERTY(L"Kits.TestName", L"Audio APO - Verify Proper APO Activation and Deactivation - TestActivateDeactivate")
TEST_METHOD_PROPERTY(L"Kits.ExpectedRuntime", L"1")
TEST_METHOD_PROPERTY(L"Kits.TimeoutInMinutes", L"5")
TEST_METHOD_PROPERTY(L"Kits.Description", L"Third Party APO Test: TestActivateDeactivate")
APO_TEST_PROPERTIES
END_TEST_METHOD()

private:
std::list<std::unique_ptr<CAPODeviceList>> m_testDeviceWrapperList;
};

BEGIN_MODULE()
MODULE_PROPERTY(L"EtwLogger:WPRProfileFile", L"Audio-Tests.wprp")
MODULE_PROPERTY(L"EtwLogger:WPRProfile", L"MultimediaCategory.Verbose.File")
END_MODULE()
96 changes: 96 additions & 0 deletions audio/tests/HLK/ThirdPartyApoTests/APOOSUpgradeTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include <stdafx.h>

#include <initguid.h>
#include "propkey.h"
#include <AudioClient.h>
#include <SpatialAudioClient.h>
#include <functiondiscoverykeys.h>
#include <DevPKey.h>
#include <AudioEngineBaseAPOP.h>
#include "TestMediaType.h"
#include <audioenginebaseapo.h>
#include <MMDeviceAPI.h>
#include <MMDeviceAPIP.h>

#include <WexTestClass.h>

#include <list>
#include <memory>
#include <ctime>
#include <thread>
#include <future>
#include <mutex>
#include <functional>
#include <atlbase.h>

#include "APOOSUpgradeTest.h"
#include "APOStressTest.h"
#include "sinewave.h"

using namespace std;
using namespace wil;
using namespace WEX::Logging;
using namespace WEX::Common;

#define IF_FAILED_RETURN(hr) { HRESULT hrCode = hr; if(FAILED(hrCode)) { return hrCode; } }
#define IF_SUCCEEDED(hr) { HRESULT hrCode = hr; if (!(hrCode == S_OK || hrCode == AUDCLNT_E_WRONG_ENDPOINT_TYPE)) { VERIFY_SUCCEEDED(hrCode); } }

bool SetupSkipRTHeap();
bool CleanupSkipRTHeap();

bool CAPOUpgradeTest::setUpMethod()
{
return SetupSkipRTHeap();
}

bool CAPOUpgradeTest::tearDownMethod()
{
return CleanupSkipRTHeap();
}

void CAPOUpgradeTest::TestUpgrade()
{
UINT cDevices = 0;
com_ptr_nothrow<IMMDeviceEnumerator> spEnumerator;
com_ptr_nothrow<IMMDeviceCollection> spDevices;

VERIFY_SUCCEEDED(CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, IID_PPV_ARGS(&spEnumerator)));
VERIFY_SUCCEEDED(spEnumerator->EnumAudioEndpoints(eAll, DEVICE_STATE_ACTIVE, &spDevices));
VERIFY_SUCCEEDED(spDevices->GetCount(&cDevices));

for (UINT i = 0; i < cDevices; i++)
{
com_ptr_nothrow<IMMDevice> pDevice = nullptr;
com_ptr_nothrow<IAudioClient2> pAudioClient = nullptr;
com_ptr_nothrow<IMMEndpoint> pEndpoint = nullptr;
BOOL bOffloadCapable = FALSE;
EDataFlow eFlow = eAll;

VERIFY_SUCCEEDED(spDevices->Item(i, &pDevice));

VERIFY_SUCCEEDED(com_query_to_nothrow(pDevice, &pEndpoint));
VERIFY_SUCCEEDED(pEndpoint->GetDataFlow(&eFlow));

VERIFY_SUCCEEDED(pDevice->Activate(__uuidof(IAudioClient2), CLSCTX_ALL, NULL, (void**)&pAudioClient));
VERIFY_SUCCEEDED(pAudioClient->IsOffloadCapable(AudioCategory_Media, &bOffloadCapable));

if (eFlow == eAll || eFlow == eRender)
{
VERIFY_SUCCEEDED(BasicAudioStreaming(pDevice.get()));

VERIFY_SUCCEEDED(BasicSpatialAudio(pDevice.get()));

VERIFY_SUCCEEDED(BasicAudioLoopback(pDevice.get()));

if (bOffloadCapable)
{
VERIFY_SUCCEEDED(BasicOffloadStreaming(pDevice.get()));
}
}

if (eFlow == eAll || eFlow == eCapture)
{
VERIFY_SUCCEEDED(BasicAudioCapture(pDevice.get()));
}
}
}
38 changes: 38 additions & 0 deletions audio/tests/HLK/ThirdPartyApoTests/APOOSUpgradeTest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <stdafx.h>

class CAPOUpgradeTest
{
CAPOUpgradeTest(){};
~CAPOUpgradeTest(){};

BEGIN_TEST_CLASS(CAPOUpgradeTest)
START_OSUPGRADE
START_APPVERIFIFER_UPGRADE
TEST_CLASS_PROPERTY(L"Owner", L"auddev")
TEST_CLASS_PROPERTY(L"TestClassification", L"Feature")
TEST_CLASS_PROPERTY(L"BinaryUnderTest", L"audiodg.exe")
TEST_CLASS_PROPERTY(L"ArtifactUnderTest", L"audioenginebaseapop.h")
TEST_CLASS_PROPERTY(L"RunAs", L"Elevated")
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"Ignore", L"false")
TEST_CLASS_PROPERTY(L"EtwLogger:WPRProfileFile", L"Audio-Tests.wprp")
TEST_CLASS_PROPERTY(L"EtwLogger:WPRProfile", L"MultimediaCategory.Verbose.File")
END_APPVERIFIER
END_TEST_CLASS()

public:
TEST_METHOD_SETUP(setUpMethod);
TEST_METHOD_CLEANUP(tearDownMethod);

protected:
BEGIN_TEST_METHOD(TestUpgrade)
COMMON_ONECORE_TEST_PROPERTIES
TEST_METHOD_PROPERTY(L"Kits.TestId", L"B98FD3CB-2E6E-4152-BA85-3021149B8E86")
TEST_METHOD_PROPERTY(L"Kits.TestId2", L"C467E942-EB43-477F-8E2A-01D07FEF90C4")
TEST_METHOD_PROPERTY(L"Kits.TestName", L"Audio APO - Verify APOs Work After an OS Upgrade - TestUpgrade")
TEST_METHOD_PROPERTY(L"Kits.ExpectedRuntime", L"60")
TEST_METHOD_PROPERTY(L"Kits.TimeoutInMinutes", L"240")
TEST_METHOD_PROPERTY(L"Kits.Description", L"Third Party APO Test: TestUpgrade")
APO_TEST_PROPERTIES
END_TEST_METHOD()
};
Loading

0 comments on commit 24e0600

Please sign in to comment.