remoting/docs/testing.md
When creating or updating tests in //remoting, follow these rules to ensure
stability and avoid flakiness:
LOG(ERROR) << "State: " << variable;
statements, rebuild, and re-run the test to empirically observe the state.base::test::TaskEnvironment over raw threads.base::test::TestFuture and
base::test::RunOnceCallback (from base/test/gmock_callback_support.h)
over manual RunLoops.RunUntilIdle(). It is
non-deterministic.run_loop.Quit() or
run_loop.QuitClosure() if completion is observable via a callback.base::test::RunUntil().remoting_unittests should run in <10s; longer runs likely indicate
a hang.base/test/gmock_callback_support.h)Provides RunOnceCallback<N>(args...) for mocking callbacks that take
base::OnceCallback. Use it in WillOnce() to provide results asynchronously.
base/test/test_future.h)A modern replacement for RunLoop. Use future.GetCallback() to pass to async
methods and future.Get() or future.Take() to wait for and retrieve results.
base/test/task_environment.h)Enables the use of base::ThreadPool and RunLoop in tests. Prefer
SingleThreadTaskEnvironment when multi-threading is not required.