1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef ASH_WM_OVERVIEW_OVERVIEW_ANIMATION_STATE_WAITER_H_ 6 #define ASH_WM_OVERVIEW_OVERVIEW_ANIMATION_STATE_WAITER_H_ 7 8 #include "ash/ash_export.h" 9 #include "ash/public/cpp/overview_test_api.h" 10 #include "ash/wm/overview/overview_observer.h" 11 #include "base/callback.h" 12 #include "base/macros.h" 13 14 namespace ash { 15 16 // Wait until an overview animation completes. This self destruct 17 // after executing the callback. Used by testing APIs. 18 class ASH_EXPORT OverviewAnimationStateWaiter : public OverviewObserver { 19 public: 20 // Type of the callback. It receives true when the overview animation finishes 21 // properly. 22 typedef base::OnceCallback<void(bool)> DoneCallback; 23 24 OverviewAnimationStateWaiter(OverviewAnimationState expected_state, 25 DoneCallback callback); 26 ~OverviewAnimationStateWaiter() override; 27 28 // Cancels the ongoing observation of the overview animation and invokes 29 // |callback_| with false. This also destructs itself. 30 void Cancel(); 31 32 private: 33 // OverviewObserver: 34 void OnOverviewModeStartingAnimationComplete(bool canceled) override; 35 void OnOverviewModeEndingAnimationComplete(bool canceled) override; 36 37 OverviewAnimationState expected_state_; 38 DoneCallback callback_; 39 40 DISALLOW_COPY_AND_ASSIGN(OverviewAnimationStateWaiter); 41 }; 42 43 } // namespace ash 44 45 #endif // ASH_WM_OVERVIEW_OVERVIEW_ANIMATION_STATE_WAITER_H_ 46