scrollable_shelf_test_base.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2022 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_SHELF_TEST_SCROLLABLE_SHELF_TEST_BASE_H_
  5. #define ASH_SHELF_TEST_SCROLLABLE_SHELF_TEST_BASE_H_
  6. #include "ash/public/cpp/shelf_types.h"
  7. #include "ash/test/ash_test_base.h"
  8. #include "ash/test/ash_test_color_generator.h"
  9. namespace ash {
  10. class ScrollableShelfView;
  11. class ShelfView;
  12. class ShelfViewTestAPI;
  13. // Shared by the scrollable shelf pixel and non-pixel tests.
  14. class ScrollableShelfTestBase : public AshTestBase {
  15. public:
  16. ScrollableShelfTestBase();
  17. ScrollableShelfTestBase(const ScrollableShelfTestBase&) = delete;
  18. ScrollableShelfTestBase& operator=(const ScrollableShelfTestBase&) = delete;
  19. ~ScrollableShelfTestBase() override;
  20. // AshTestBase:
  21. void SetUp() override;
  22. void TearDown() override;
  23. protected:
  24. // Pins some app icons to shelf. If `use_alternative_color` is true, the
  25. // neighboring shelf app icons are of different colors.
  26. void PopulateAppShortcut(int number, bool use_alternative_color = false);
  27. // Keeps pinning app icons to shelf until the shelf arrow button shows.
  28. // If `use_alternative_color` is true, the neighboring shelf app icons are of
  29. // different colors.
  30. void AddAppShortcutsUntilOverflow(bool use_alternative_color = false);
  31. // Adds a shelf item of the specified type and color.
  32. ShelfID AddAppShortcutWithIconColor(ShelfItemType item_type, SkColor color);
  33. ScrollableShelfView* scrollable_shelf_view_ = nullptr;
  34. ShelfView* shelf_view_ = nullptr;
  35. std::unique_ptr<ShelfViewTestAPI> test_api_;
  36. // Used as the id of the next pinned app. Updates when an app is pinned.
  37. int id_ = 0;
  38. AshTestColorGenerator icon_color_generator_{/*default_color=*/SK_ColorRED};
  39. };
  40. } // namespace ash
  41. #endif // ASH_SHELF_TEST_SCROLLABLE_SHELF_TEST_BASE_H_