diff --git a/components/concept/engine/src/main/java/mozilla/components/concept/engine/InputResultDetail.kt b/components/concept/engine/src/main/java/mozilla/components/concept/engine/InputResultDetail.kt index f84dfec221e..f52f38b431d 100644 --- a/components/concept/engine/src/main/java/mozilla/components/concept/engine/InputResultDetail.kt +++ b/components/concept/engine/src/main/java/mozilla/components/concept/engine/InputResultDetail.kt @@ -134,9 +134,9 @@ class InputResultDetail private constructor( @Suppress("MagicNumber") override fun hashCode(): Int { - var hash = inputResult.hashCode() * 31 - hash += (scrollDirections.hashCode()) * 31 - hash += (overscrollDirections.hashCode()) * 31 + var hash = inputResult.hashCode() + hash += (scrollDirections.hashCode()) * 10 + hash += (overscrollDirections.hashCode()) * 100 return hash } diff --git a/components/concept/engine/src/test/java/mozilla/components/concept/engine/InputResultDetailTest.kt b/components/concept/engine/src/test/java/mozilla/components/concept/engine/InputResultDetailTest.kt index 5113d1f306e..96c2444734c 100644 --- a/components/concept/engine/src/test/java/mozilla/components/concept/engine/InputResultDetailTest.kt +++ b/components/concept/engine/src/test/java/mozilla/components/concept/engine/InputResultDetailTest.kt @@ -115,15 +115,15 @@ class InputResultDetailTest { assertTrue(inputResultDetail == inputResultDetail) } - // @Test - // fun `GIVEN an InputResultDetail WHEN hashCode is called for same values objects THEN it returns the same result`() { - // assertEquals(inputResultDetail.hashCode(), inputResultDetail.hashCode()) - // - // assertEquals(inputResultDetail.hashCode(), InputResultDetail.newInstance().hashCode()) - // - // inputResultDetail = inputResultDetail.copy(OVERSCROLL_DIRECTIONS_VERTICAL) - // assertEquals(inputResultDetail.hashCode(), InputResultDetail.newInstance(true).hashCode()) - // } + @Test + fun `GIVEN an InputResultDetail WHEN hashCode is called for same values objects THEN it returns the same result`() { + assertEquals(inputResultDetail.hashCode(), inputResultDetail.hashCode()) + + assertEquals(inputResultDetail.hashCode(), InputResultDetail.newInstance().hashCode()) + + inputResultDetail = inputResultDetail.copy(overscrollDirections = OVERSCROLL_DIRECTIONS_VERTICAL) + assertEquals(inputResultDetail.hashCode(), InputResultDetail.newInstance(true).hashCode()) + } @Test fun `GIVEN an InputResultDetail WHEN hashCode is called for different values objects THEN it returns different results`() {