diff options
author | 2024-04-01 17:15:42 +0000 | |
---|---|---|
committer | 2024-04-01 17:15:42 +0000 | |
commit | d19d707e89301bb209bd02c8c4a3b5a8c84a46b1 (patch) | |
tree | 174f918266f8ef9074d70485cc33517d877ae7e1 | |
parent | 686b965eef8cb608cfa3db2de48a2c0c98ee56ec (diff) | |
parent | bf98a5759f3b7ae19b41ad4c66c535d33ae646a4 (diff) |
Merge "Add compile checks to EndToEndNativeInputTest" into main
-rw-r--r-- | libs/gui/tests/Android.bp | 3 | ||||
-rw-r--r-- | libs/gui/tests/BLASTBufferQueue_test.cpp | 5 | ||||
-rw-r--r-- | libs/gui/tests/BufferQueue_test.cpp | 7 | ||||
-rw-r--r-- | libs/gui/tests/DisplayedContentSampling_test.cpp | 8 | ||||
-rw-r--r-- | libs/gui/tests/EndToEndNativeInputTest.cpp | 14 | ||||
-rw-r--r-- | libs/gui/tests/Surface_test.cpp | 4 |
6 files changed, 23 insertions, 18 deletions
diff --git a/libs/gui/tests/Android.bp b/libs/gui/tests/Android.bp index 0f16f714dc..2faa330426 100644 --- a/libs/gui/tests/Android.bp +++ b/libs/gui/tests/Android.bp @@ -21,7 +21,8 @@ cc_test { cppflags: [ "-Wall", "-Werror", - "-Wno-extra", + "-Wextra", + "-Wthread-safety", "-DCOM_ANDROID_GRAPHICS_LIBGUI_FLAGS_BQ_SETFRAMERATE=true", ], diff --git a/libs/gui/tests/BLASTBufferQueue_test.cpp b/libs/gui/tests/BLASTBufferQueue_test.cpp index ea7078dd05..0cc0156d26 100644 --- a/libs/gui/tests/BLASTBufferQueue_test.cpp +++ b/libs/gui/tests/BLASTBufferQueue_test.cpp @@ -16,6 +16,9 @@ #define LOG_TAG "BLASTBufferQueue_test" +#pragma clang diagnostic ignored "-Wsign-compare" +#pragma clang diagnostic ignored "-Wthread-safety" + #include <gui/BLASTBufferQueue.h> #include <android/hardware/graphics/common/1.2/types.h> @@ -476,7 +479,7 @@ TEST_F(BLASTBufferQueueTest, TripleBuffering) { ASSERT_EQ(OK, igbProducer->requestBuffer(slot, &buf)); allocated.push_back({slot, fence}); } - for (int i = 0; i < allocated.size(); i++) { + for (size_t i = 0; i < allocated.size(); i++) { igbProducer->cancelBuffer(allocated[i].first, allocated[i].second); } diff --git a/libs/gui/tests/BufferQueue_test.cpp b/libs/gui/tests/BufferQueue_test.cpp index df7739c3fb..1ec6f915f7 100644 --- a/libs/gui/tests/BufferQueue_test.cpp +++ b/libs/gui/tests/BufferQueue_test.cpp @@ -119,8 +119,7 @@ TEST_F(BufferQueueTest, DISABLED_BufferQueueInAnotherProcess) { } sp<IServiceManager> serviceManager = defaultServiceManager(); - sp<IBinder> binderProducer = - serviceManager->getService(PRODUCER_NAME); + sp<IBinder> binderProducer = serviceManager->waitForService(PRODUCER_NAME); mProducer = interface_cast<IGraphicBufferProducer>(binderProducer); EXPECT_TRUE(mProducer != nullptr); sp<IBinder> binderConsumer = @@ -1114,7 +1113,7 @@ TEST_F(BufferQueueTest, TestDiscardFreeBuffers) { // Check onBuffersDiscarded is called with correct slots auto buffersDiscarded = pl->getDiscardedSlots(); - ASSERT_EQ(buffersDiscarded.size(), 1); + ASSERT_EQ(buffersDiscarded.size(), 1u); ASSERT_EQ(buffersDiscarded[0], releasedSlot); // Check no free buffers in dump @@ -1239,7 +1238,7 @@ TEST_F(BufferQueueTest, TestConsumerDetachProducerListener) { ASSERT_EQ(OK, mConsumer->detachBuffer(item.mSlot)); // Check whether the slot from IProducerListener is same to the detached slot. - ASSERT_EQ(pl->getDetachedSlots().size(), 1); + ASSERT_EQ(pl->getDetachedSlots().size(), 1u); ASSERT_EQ(pl->getDetachedSlots()[0], slots[1]); // Dequeue another buffer. diff --git a/libs/gui/tests/DisplayedContentSampling_test.cpp b/libs/gui/tests/DisplayedContentSampling_test.cpp index 0a2750a4dd..bffb3f0430 100644 --- a/libs/gui/tests/DisplayedContentSampling_test.cpp +++ b/libs/gui/tests/DisplayedContentSampling_test.cpp @@ -116,10 +116,10 @@ TEST_F(DisplayedContentSamplingTest, SampleCollectionCoherentWithSupportMask) { EXPECT_EQ(OK, status); if (stats.numFrames <= 0) return; - if (componentMask & (0x1 << 0)) EXPECT_NE(0, stats.component_0_sample.size()); - if (componentMask & (0x1 << 1)) EXPECT_NE(0, stats.component_1_sample.size()); - if (componentMask & (0x1 << 2)) EXPECT_NE(0, stats.component_2_sample.size()); - if (componentMask & (0x1 << 3)) EXPECT_NE(0, stats.component_3_sample.size()); + if (componentMask & (0x1 << 0)) EXPECT_NE(0u, stats.component_0_sample.size()); + if (componentMask & (0x1 << 1)) EXPECT_NE(0u, stats.component_1_sample.size()); + if (componentMask & (0x1 << 2)) EXPECT_NE(0u, stats.component_2_sample.size()); + if (componentMask & (0x1 << 3)) EXPECT_NE(0u, stats.component_3_sample.size()); } } // namespace android diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp index 8d5d1e449f..f441eaa95a 100644 --- a/libs/gui/tests/EndToEndNativeInputTest.cpp +++ b/libs/gui/tests/EndToEndNativeInputTest.cpp @@ -24,6 +24,7 @@ #include <memory> +#include <android-base/thread_annotations.h> #include <android/gui/BnWindowInfosReportedListener.h> #include <android/keycodes.h> #include <android/native_window.h> @@ -78,21 +79,22 @@ static constexpr std::chrono::nanoseconds DISPATCHING_TIMEOUT = 5s; class SynchronousWindowInfosReportedListener : public gui::BnWindowInfosReportedListener { public: binder::Status onWindowInfosReported() override { - std::lock_guard<std::mutex> lock{mMutex}; + std::scoped_lock lock{mLock}; mWindowInfosReported = true; mConditionVariable.notify_one(); return binder::Status::ok(); } void wait() { - std::unique_lock<std::mutex> lock{mMutex}; - mConditionVariable.wait(lock, [&] { return mWindowInfosReported; }); + std::unique_lock lock{mLock}; + android::base::ScopedLockAssertion assumeLocked(mLock); + mConditionVariable.wait(lock, [&]() REQUIRES(mLock) { return mWindowInfosReported; }); } private: - std::mutex mMutex; + std::mutex mLock; std::condition_variable mConditionVariable; - bool mWindowInfosReported{false}; + bool mWindowInfosReported GUARDED_BY(mLock){false}; }; class InputSurface { @@ -250,7 +252,7 @@ public: EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); } - void expectKey(uint32_t keycode) { + void expectKey(int32_t keycode) { InputEvent *ev = consumeEvent(); ASSERT_NE(ev, nullptr); ASSERT_EQ(InputEventType::KEY, ev->getType()); diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp index 93bf4faa13..f4b059c39b 100644 --- a/libs/gui/tests/Surface_test.cpp +++ b/libs/gui/tests/Surface_test.cpp @@ -173,7 +173,7 @@ protected: // Acquire and free 1+extraDiscardedBuffers buffer, check onBufferReleased is called. std::vector<BufferItem> releasedItems; releasedItems.resize(1+extraDiscardedBuffers); - for (int i = 0; i < releasedItems.size(); i++) { + for (size_t i = 0; i < releasedItems.size(); i++) { ASSERT_EQ(NO_ERROR, consumer->acquireBuffer(&releasedItems[i], 0)); ASSERT_EQ(NO_ERROR, consumer->releaseBuffer(releasedItems[i].mSlot, releasedItems[i].mFrameNumber, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, @@ -197,7 +197,7 @@ protected: // Check onBufferDiscarded is called with correct buffer auto discardedBuffers = listener->getDiscardedBuffers(); ASSERT_EQ(discardedBuffers.size(), releasedItems.size()); - for (int i = 0; i < releasedItems.size(); i++) { + for (size_t i = 0; i < releasedItems.size(); i++) { ASSERT_EQ(discardedBuffers[i], releasedItems[i].mGraphicBuffer); } |