wayland_keyboard_delegate_unittest.cc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #include "components/exo/wayland/wayland_keyboard_delegate.h"
  5. #include "testing/gtest/include/gtest/gtest.h"
  6. namespace exo {
  7. namespace wayland {
  8. namespace {
  9. using WaylandKeyboardDelegateTest = testing::Test;
  10. TEST_F(WaylandKeyboardDelegateTest, RepeatRateIsZeroIfRepeatDisabled) {
  11. EXPECT_EQ(GetWaylandRepeatRateForTesting(false, base::Seconds(1)), 0);
  12. }
  13. TEST_F(WaylandKeyboardDelegateTest, Converts100MsIntervalTo10Hertz) {
  14. EXPECT_EQ(GetWaylandRepeatRateForTesting(true, base::Milliseconds(100)), 10);
  15. }
  16. TEST_F(WaylandKeyboardDelegateTest, Converts333MsIntervalTo3Hertz) {
  17. EXPECT_EQ(GetWaylandRepeatRateForTesting(true, base::Milliseconds(333)), 3);
  18. }
  19. TEST_F(WaylandKeyboardDelegateTest, Converts500MsIntervalTo2Hertz) {
  20. EXPECT_EQ(GetWaylandRepeatRateForTesting(true, base::Milliseconds(500)), 2);
  21. }
  22. TEST_F(WaylandKeyboardDelegateTest, Converts1SecondIntervalTo1Hertz) {
  23. EXPECT_EQ(GetWaylandRepeatRateForTesting(true, base::Seconds(1)), 1);
  24. }
  25. TEST_F(WaylandKeyboardDelegateTest,
  26. Converts2SecondIntervalTo1HertzDueToLimitations) {
  27. // Should really be 0.5Hz, but Wayland only supports integer repeat rates.
  28. // Make sure we fallback to 1Hz so some repeating occurs, rather than 0Hz
  29. // which disables key repeat.
  30. EXPECT_EQ(GetWaylandRepeatRateForTesting(true, base::Seconds(2)), 1);
  31. }
  32. } // namespace
  33. } // namespace wayland
  34. } // namespace exo