SF: Add and use MockGraphicBufferProducer/Consumer
This has the benefit of allowing the tests to set expectations on the
producer/consumer queue calls.
Additionally this speeds up test execution (though possibly only for the
first test which creates a buffer queue) by a factor of 4x.
[Test execution time reduced from 25ms to 6.1ms]
Test: libsurfaceflinger_unittest passes on Pixel XL
Bug: None
Change-Id: Ic400e8d123fea497061c193df5036218ebef1d3a
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
index e55d778..4895e16 100644
--- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
+++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
@@ -50,6 +50,12 @@
HWC2::Connection::Connected);
}
+ using CreateBufferQueueFunction = SurfaceFlinger::CreateBufferQueueFunction;
+
+ void setCreateBufferQueueFunction(CreateBufferQueueFunction f) {
+ mFlinger->mCreateBufferQueue = f;
+ }
+
/* ------------------------------------------------------------------------
* Forwarding for functions being tested
*/