test_ash_web_view.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 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. #ifndef ASH_TEST_TEST_ASH_WEB_VIEW_H_
  5. #define ASH_TEST_TEST_ASH_WEB_VIEW_H_
  6. #include "ash/public/cpp/ash_web_view.h"
  7. #include "base/observer_list.h"
  8. namespace views {
  9. class View;
  10. } // namespace views
  11. namespace ash {
  12. // An implementation of AshWebView for use in unittests.
  13. class TestAshWebView : public AshWebView {
  14. public:
  15. explicit TestAshWebView(const AshWebView::InitParams& init_params);
  16. ~TestAshWebView() override;
  17. TestAshWebView(const TestAshWebView&) = delete;
  18. TestAshWebView& operator=(const TestAshWebView&) = delete;
  19. // AshWebView:
  20. void AddObserver(Observer* observer) override;
  21. void RemoveObserver(Observer* observer) override;
  22. gfx::NativeView GetNativeView() override;
  23. bool GoBack() override;
  24. void Navigate(const GURL& url) override;
  25. views::View* GetInitiallyFocusedView() override;
  26. void RequestFocus() override;
  27. bool HasFocus() const override;
  28. const AshWebView::InitParams& init_params_for_testing() const {
  29. return init_params_;
  30. }
  31. private:
  32. base::ObserverList<Observer> observers_;
  33. bool focused_ = false;
  34. AshWebView::InitParams init_params_;
  35. base::WeakPtrFactory<TestAshWebView> weak_factory_{this};
  36. };
  37. } // namespace ash
  38. #endif // ASH_TEST_TEST_ASH_WEB_VIEW_H_