app_list_view_pixeltest.cc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include "ash/app_list/test/app_list_test_helper.h"
  5. #include "ash/app_list/views/search_box_view.h"
  6. #include "ash/shell.h"
  7. #include "ash/test/ash_pixel_diff_test_helper.h"
  8. #include "ash/test/ash_pixel_test_init_params.h"
  9. #include "ash/test/ash_test_base.h"
  10. #include "ui/views/controls/textfield/textfield_test_api.h"
  11. namespace ash {
  12. class AppListViewPixelRTLTest
  13. : public AshTestBase,
  14. public testing::WithParamInterface<bool /*is_rtl=*/> {
  15. public:
  16. AppListViewPixelRTLTest() {
  17. PrepareForPixelDiffTest();
  18. if (GetParam()) {
  19. pixel_test::InitParams init_params;
  20. init_params.under_rtl = true;
  21. SetPixelTestInitParam(init_params);
  22. }
  23. }
  24. AppListViewPixelRTLTest(const AppListViewPixelRTLTest&) = delete;
  25. AppListViewPixelRTLTest& operator=(const AppListViewPixelRTLTest&) = delete;
  26. ~AppListViewPixelRTLTest() override = default;
  27. void ShowAppListAndHideCursor() {
  28. AppListTestHelper* test_helper = GetAppListTestHelper();
  29. test_helper->ShowAppList();
  30. // Use a fixed placeholder text instead of the one picked randomly to
  31. // avoid the test flakiness.
  32. test_helper->GetSearchBoxView()->UseFixedPlaceholderTextForTest();
  33. // Hide the search box cursor to avoid the flakiness due to the
  34. // blinking.
  35. views::TextfieldTestApi(test_helper->GetBubbleSearchBoxView()->search_box())
  36. .SetCursorLayerOpacity(0.f);
  37. }
  38. // AshTestBase:
  39. void SetUp() override {
  40. AshTestBase::SetUp();
  41. pixel_test_helper_.InitSkiaGoldPixelDiff("app_list_view_pixel");
  42. }
  43. AshPixelDiffTestHelper pixel_test_helper_;
  44. };
  45. INSTANTIATE_TEST_SUITE_P(RTL, AppListViewPixelRTLTest, testing::Bool());
  46. // Verifies the app list view under the clamshell mode.
  47. TEST_P(AppListViewPixelRTLTest, Basics) {
  48. GetAppListTestHelper()->AddAppItemsWithColorAndName(
  49. 2, AppListTestHelper::IconColorType::kAlternativeColor,
  50. /*set_name=*/true);
  51. ShowAppListAndHideCursor();
  52. EXPECT_TRUE(pixel_test_helper_.ComparePrimaryFullScreen(
  53. GetParam() ? "bubble_launcher_basics_rtl" : "bubble_launcher_basics"));
  54. }
  55. } // namespace ash