New issue
Advanced search Search tips

Issue 786854 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Task



Sign in to add a comment

Add unit tests for class VideoCaptureDeviceMFWin

Project Member Reported by chfremer@chromium.org, Nov 20 2017

Issue description

Class VideoCaptureDeviceMFWin has recently been reworked and we are planning to roll this implementation of media::VideoCaptureDevice out to users of Windows 8 and higher.

Since the class contains a fair amount of complexity, we need to unit test it before we can roll it out with high confidence. Unit testing of this class can be done as follows:
1. Break dependency of the class on the actual Windows Media Foundation by abstracting all invocations of MediaFoundation APIs into an interface that gets passed into the constructor.
2. In the unit test, use a mock implementation of that abstraction.

 
chfremer@,

I see 2 kind of interfaces to ease MediaFoundation mocking.

The 1st one is simple to write because it only provides objects produced by static methods.
Basically, it would expose the following method:

  IMFCaptureEngine CreateIMFCaptureEngine()

In the unit tests, we would need to mock the whole chain of objects produced by IMFCaptureEngine.
So mock would have to occurs on multiple levels of depth.



The 2nd one is more complex to write and allows to remove all direct MF references from VideoCaptureDeviceMFWin.
In the unit tests, the mocking would be a simpler, we would mock direct methods.
Mock would have to occurs on one level of depth.
But since we don't want to rewrite the whole MF api, IMO, this interface would be similar to VideoCaptureDevice interface.

What kind of interface and test are you expecting?
I was thinking of the first variant, i.e. creating a mock for IMFCaptureEngine and configuring it with behavior on multiple levels of depth. To save one level of depth, we can pass the IMFCaptureEngine into the VideoCaptureDeviceMFWin instance.

All other global methods called by VideoCaptureDeviceMFWin, we can probably just leave as is, since mocking them is probably not needed to reach the interesting cases e.g.
MFGetAttributeSize
MFGetAttributeRatio
MFCreateAttributes
MFCreateMediaType
PropVariantInit
PropVariantClear

Sign in to add a comment