1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33

ash / system / notification_center / message_popup_animation_waiter.cc [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 "ash/system/notification_center/message_popup_animation_waiter.h"

#include "ash/system/notification_center/ash_message_popup_collection.h"
#include "base/functional/bind.h"

namespace ash {

MessagePopupAnimationWaiter::MessagePopupAnimationWaiter(
    AshMessagePopupCollection* message_popup_collection)
    : message_popup_collection_(message_popup_collection) {
  DCHECK(message_popup_collection_);
}

MessagePopupAnimationWaiter::~MessagePopupAnimationWaiter() = default;

void MessagePopupAnimationWaiter::Wait() {
  if (message_popup_collection_->popups_animating_for_test()) {
    message_popup_collection_->SetAnimationIdleClosureForTest(  // IN-TEST
        base::BindOnce(&MessagePopupAnimationWaiter::OnPopupAnimationFinished,
                       weak_ptr_factory_.GetWeakPtr()));
    run_loop_.Run();
  }
}

void MessagePopupAnimationWaiter::OnPopupAnimationFinished() {
  run_loop_.Quit();
}

}  // namespace ash