#include "ui/compositor/test/layer_animation_stopped_waiter.h"
#include "base/run_loop.h"
#include "ui/compositor/layer.h"
namespace ui {
LayerAnimationStoppedWaiter::LayerAnimationStoppedWaiter() = default;
LayerAnimationStoppedWaiter::~LayerAnimationStoppedWaiter() = default;
void LayerAnimationStoppedWaiter::Wait(Layer* layer) {
if (!layer->GetAnimator()->is_animating())
return;
layer_animator_ = layer->GetAnimator();
layer_animator_observer_.Observe(layer_animator_);
wait_loop_ = std::make_unique<base::RunLoop>();
wait_loop_->Run();
layer_animator_ = nullptr;
wait_loop_.reset();
}
void LayerAnimationStoppedWaiter::OnLayerAnimationAborted(
LayerAnimationSequence* sequence) {
if (!layer_animator_->is_animating()) {
layer_animator_observer_.Reset();
wait_loop_->Quit();
}
}
void LayerAnimationStoppedWaiter::OnLayerAnimationEnded(
LayerAnimationSequence* sequence) {
if (!layer_animator_->is_animating()) {
layer_animator_observer_.Reset();
wait_loop_->Quit();
}
}
}