@Override
    public ChannelFuture writePing(ChannelHandlerContext ctx, boolean ack, long data, ChannelPromise promise) {
        // Only apply the limit to ping acks.
        if (ack) {
            ChannelPromise newPromise = handleOutstandingControlFrames(ctx, promise);
            if (newPromise == null) {
                return promise;
            }
            return super.writePing(ctx, ack, data, newPromise);
        }
        return super.writePing(ctx, ack, data, promise);
    }
@Test
    public void testLimitPingAck() {
        assertFalse(encoder.writePing(ctx, true, 8, newPromise()).isDone());
        // The second write is always marked as success by our mock, which means it will also not be queued and so
        // not count to the number of queued frames.
        assertTrue(encoder.writePing(ctx, true, 8, newPromise()).isSuccess());
        assertFalse(encoder.writePing(ctx, true, 8, newPromise()).isDone());

        verifyFlushAndClose(0, false);

        assertFalse(encoder.writePing(ctx, true, 8, newPromise()).isDone());
        assertFalse(encoder.writePing(ctx, true, 8, newPromise()).isDone());

        verifyFlushAndClose(1, true);
    }