SF: reduce timeout for unit tests
change the timeout used in transaction application
to make the unit tests run faster.
Bug: 198190384
Test: libsurfaceflinger_unittest
Change-Id: I92e19f1b2957b406c1b61d0b948c3fb0c1f61d6c
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
index d292e08..4fe1e98 100644
--- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
+++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
@@ -177,6 +177,11 @@
public:
using HotplugEvent = SurfaceFlinger::HotplugEvent;
+ TestableSurfaceFlinger()
+ : mFlinger(sp<SurfaceFlinger>::make(mFactory, SurfaceFlinger::SkipInitialization)) {
+ mFlinger->mAnimationTransactionTimeout = ms2ns(10);
+ }
+
SurfaceFlinger* flinger() { return mFlinger.get(); }
scheduler::TestableScheduler* scheduler() { return mScheduler; }
@@ -466,6 +471,10 @@
return static_cast<mock::FrameTracer*>(mFlinger->mFrameTracer.get());
}
+ nsecs_t getAnimationTransactionTimeout() const {
+ return mFlinger->mAnimationTransactionTimeout;
+ }
+
/* ------------------------------------------------------------------------
* Read-write access to private data to set up preconditions and assert
* post-conditions.
diff --git a/services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp b/services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp
index 8bd54db..ed23176 100644
--- a/services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp
+++ b/services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp
@@ -159,9 +159,9 @@
// completed. If this is animation, it should not time out waiting.
nsecs_t returnedTime = systemTime();
if (flags & ISurfaceComposer::eSynchronous || syncInputWindows) {
- EXPECT_GE(returnedTime, applicationTime + s2ns(5));
+ EXPECT_GE(returnedTime, applicationTime + mFlinger.getAnimationTransactionTimeout());
} else {
- EXPECT_LE(returnedTime, applicationTime + s2ns(5));
+ EXPECT_LE(returnedTime, applicationTime + mFlinger.getAnimationTransactionTimeout());
}
// Each transaction should have been placed on the transaction queue
auto transactionQueue = mFlinger.getTransactionQueue();
@@ -188,9 +188,11 @@
nsecs_t returnedTime = systemTime();
if ((flags & ISurfaceComposer::eSynchronous) || syncInputWindows) {
- EXPECT_GE(systemTime(), applicationSentTime + s2ns(5));
+ EXPECT_GE(systemTime(),
+ applicationSentTime + mFlinger.getAnimationTransactionTimeout());
} else {
- EXPECT_LE(returnedTime, applicationSentTime + s2ns(5));
+ EXPECT_LE(returnedTime,
+ applicationSentTime + mFlinger.getAnimationTransactionTimeout());
}
// This transaction should have been placed on the transaction queue
auto transactionQueue = mFlinger.getTransactionQueue();
@@ -228,7 +230,7 @@
// This thread should not have been blocked by the above transaction
// (5s is the timeout period that applyTransactionState waits for SF to
// commit the transaction)
- EXPECT_LE(systemTime(), applicationSentTime + s2ns(5));
+ EXPECT_LE(systemTime(), applicationSentTime + mFlinger.getAnimationTransactionTimeout());
// transaction that would goes to pending transaciton queue.
mFlinger.flushTransactionQueues();
@@ -246,9 +248,11 @@
// the transaction should be placed on the pending queue
if (flags & (ISurfaceComposer::eAnimation | ISurfaceComposer::eSynchronous) ||
syncInputWindows) {
- EXPECT_GE(systemTime(), applicationSentTime + s2ns(5));
+ EXPECT_GE(systemTime(),
+ applicationSentTime + mFlinger.getAnimationTransactionTimeout());
} else {
- EXPECT_LE(systemTime(), applicationSentTime + s2ns(5));
+ EXPECT_LE(systemTime(),
+ applicationSentTime + mFlinger.getAnimationTransactionTimeout());
}
// transaction that would goes to pending transaciton queue.