blob: 848e9e4f2f479bb7c75727f90345e00ef23e2322 [file] [log] [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/exo/test/surface_tree_host_test_util.h"
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/run_loop.h"
namespace exo::test {
void WaitForLastFrameAck(SurfaceTreeHost* surface_tree_host) {
CHECK(!surface_tree_host->GetFrameCallbacksForTesting().empty());
auto& list = surface_tree_host->GetFrameCallbacksForTesting().back();
base::RunLoop runloop;
list.push_back(base::BindRepeating(
[](base::RepeatingClosure callback, base::TimeTicks) { callback.Run(); },
runloop.QuitClosure()));
runloop.Run();
}
void WaitForLastFramePresentation(SurfaceTreeHost* surface_tree_host) {
CHECK(!surface_tree_host->GetActivePresentationCallbacksForTesting().empty());
auto& list = surface_tree_host->GetActivePresentationCallbacksForTesting()
.rbegin()
->second;
base::RunLoop runloop;
list.push_back(base::BindRepeating(
[](base::RepeatingClosure callback, const gfx::PresentationFeedback&) {
callback.Run();
},
runloop.QuitClosure()));
runloop.Run();
}
} // namespace exo::test