diff --git a/litho-it/src/test/java/com/facebook/litho/NoOpEventHandlerTest.java b/litho-it/src/test/java/com/facebook/litho/NoOpEventHandlerTest.java deleted file mode 100644 index 63b851d21d1..00000000000 --- a/litho-it/src/test/java/com/facebook/litho/NoOpEventHandlerTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.facebook.litho; - -import static androidx.test.core.app.ApplicationProvider.getApplicationContext; -import static org.assertj.core.api.Assertions.assertThat; - -import com.facebook.litho.testing.testrunner.LithoTestRunner; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(LithoTestRunner.class) -public class NoOpEventHandlerTest { - @Test - public void testGetNoOpEventHandler() { - EventHandler eventHandler = NoOpEventHandler.getNoOpEventHandler(); - assertThat(eventHandler.isEquivalentTo(null)).isFalse(); - EventHandler eventHandler1 = NoOpEventHandler.getNoOpEventHandler(); - assertThat(eventHandler.isEquivalentTo(eventHandler1)).isTrue(); - } - - @Test - public void testHasEventDispatcherNotNull() { - NoOpEventHandler eventHandler = NoOpEventHandler.getNoOpEventHandler(); - assertThat(eventHandler.isEquivalentTo(null)).isFalse(); - assertThat(NoOpEventHandler.getNoOpEventHandler().dispatchInfo.hasEventDispatcher != null) - .isTrue(); - } - - @Test(expected = RuntimeException.class) - public void testComponentContextThrowsExceptionWithoutComponentScope() { - ComponentContext componentContext = new ComponentContext(getApplicationContext()); - assertThat( - componentContext - .newEventHandler(1, new Object[1]) - .isEquivalentTo(NoOpEventHandler.getNoOpEventHandler())) - .isTrue(); - } - - @Test(expected = RuntimeException.class) - public void testComponentLifeCycleThrowsExceptionWithoutComponentScope() { - ComponentContext componentContext = new ComponentContext(getApplicationContext()); - Component component = null; - assertThat( - Component.newEventHandler( - component.getClass(), "Component", componentContext, 1, new Object[1]) - .isEquivalentTo(NoOpEventHandler.getNoOpEventHandler())) - .isTrue(); - } -} diff --git a/litho-it/src/test/java/com/facebook/litho/NoOpEventHandlerTest.kt b/litho-it/src/test/java/com/facebook/litho/NoOpEventHandlerTest.kt new file mode 100644 index 00000000000..450806a05e3 --- /dev/null +++ b/litho-it/src/test/java/com/facebook/litho/NoOpEventHandlerTest.kt @@ -0,0 +1,66 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.facebook.litho + +import android.content.Context +import androidx.test.core.app.ApplicationProvider +import com.facebook.litho.NoOpEventHandler.Companion.getNoOpEventHandler +import com.facebook.litho.testing.testrunner.LithoTestRunner +import java.lang.RuntimeException +import org.assertj.core.api.Assertions.assertThat +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(LithoTestRunner::class) +class NoOpEventHandlerTest { + + @Test + fun testGetNoOpEventHandler() { + val eventHandler: EventHandler<*> = getNoOpEventHandler() + assertThat(eventHandler.isEquivalentTo(null)).isFalse + val eventHandler1: EventHandler<*> = getNoOpEventHandler() + assertThat(eventHandler.isEquivalentTo(eventHandler1)).isTrue + } + + @Test + fun testHasEventDispatcherNotNull() { + val eventHandler: NoOpEventHandler<*> = getNoOpEventHandler() + assertThat(eventHandler.isEquivalentTo(null)).isFalse + assertThat(getNoOpEventHandler().dispatchInfo.hasEventDispatcher != null).isTrue + } + + @Test(expected = RuntimeException::class) + fun testComponentContextThrowsExceptionWithoutComponentScope() { + val componentContext = ComponentContext(ApplicationProvider.getApplicationContext()) + assertThat( + componentContext + .newEventHandler(1, arrayOfNulls(1)) + .isEquivalentTo(getNoOpEventHandler())) + .isTrue + } + + @Test(expected = RuntimeException::class) + fun testComponentLifeCycleThrowsExceptionWithoutComponentScope() { + val componentContext = ComponentContext(ApplicationProvider.getApplicationContext()) + val component: Component? = null + assertThat( + Component.newEventHandler( + component!!.javaClass, "Component", componentContext, 1, arrayOfNulls(1)) + .isEquivalentTo(getNoOpEventHandler())) + .isTrue + } +}