chromium/mojo/public/cpp/bindings/tests/flush_async_unittest.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <memory>
#include <optional>
#include <utility>
#include <vector>

#include "base/barrier_closure.h"
#include "base/containers/flat_map.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/test/bind.h"
#include "mojo/public/cpp/bindings/async_flusher.h"
#include "mojo/public/cpp/bindings/pending_flush.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "mojo/public/cpp/bindings/tests/bindings_test_base.h"
#include "mojo/public/cpp/bindings/tests/flush_async_unittest.test-mojom.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace mojo {
namespace test {
namespace flush_async_unittest {

// This implementation binds its receiver on an arbitrary ThreadPool task
// runner. Any incoming Writer receivers are in turn bound on arbitrary (and
// potentially different) ThreadPool task runners. There is therefore no general
// ordering guarantee regarding message dispatch among each bound interface,
// yielding generally racy behavior.
//
// This allows tests to reliably verify correctness of async flushing behavior.
class KeyValueStoreImpl : public base::RefCountedThreadSafe<KeyValueStoreImpl>,
                          public mojom::KeyValueStore {};

class FlushAsyncTest : public BindingsTestBase {};

TEST_P(FlushAsyncTest, WaitForMultipleFlushes) {}

TEST_P(FlushAsyncTest, MultipleFlushesInSequence) {}

TEST_P(FlushAsyncTest, DroppedFlusherCompletesPendingFlush) {}

class PingerImpl : public mojom::Pinger {};

TEST_P(FlushAsyncTest, PausedInterfaceDoesNotAutoResumeOnFlush) {}

TEST_P(FlushAsyncTest, ResumeDoesNotInterruptWaitingOnFlush) {}

class KeyValueStoreClientImpl : public mojom::KeyValueStoreClient {};

TEST_P(FlushAsyncTest, PauseRemote) {}

INSTANTIATE_MOJO_BINDINGS_TEST_SUITE_P();

}  // namespace flush_async_unittest
}  // namespace test
}  // namespace mojo