hotseat_state_watcher.cc 958 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (c) 2020 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. #include "ash/shelf/test/hotseat_state_watcher.h"
  5. namespace ash {
  6. HotseatStateWatcher::HotseatStateWatcher(
  7. ShelfLayoutManager* shelf_layout_manager)
  8. : shelf_layout_manager_(shelf_layout_manager) {
  9. shelf_layout_manager_->AddObserver(this);
  10. }
  11. HotseatStateWatcher::~HotseatStateWatcher() {
  12. shelf_layout_manager_->RemoveObserver(this);
  13. }
  14. void HotseatStateWatcher::OnHotseatStateChanged(HotseatState old_state,
  15. HotseatState new_state) {
  16. run_loop_.QuitWhenIdle();
  17. state_changes_.push_back(new_state);
  18. }
  19. void HotseatStateWatcher::CheckEqual(std::vector<HotseatState> state_changes) {
  20. EXPECT_EQ(state_changes_, state_changes);
  21. }
  22. void HotseatStateWatcher::WaitUntilStateChanged() {
  23. run_loop_.Run();
  24. }
  25. } // namespace ash