-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
☂️ BaseViewManagerTest.java => BaseViewManagerTest.kt (#38841)
Summary: Issue: #38825 (comment) ## Changelog: [GENERAL] [CHANGED] - `BaseViewManagerTest.java` => `BaseViewManagerTest.kt` Pull Request resolved: #38841 Test Plan: ```shell ./gradlew :packages:react-native:ReactAndroid:test ``` Reviewed By: cortinico Differential Revision: D48153909 Pulled By: rshest fbshipit-source-id: cac20a64b72b77c23edb2e20b65717c1a425a08a
- Loading branch information
1 parent
8cb4a52
commit 3660b7c
Showing
2 changed files
with
75 additions
and
88 deletions.
There are no files selected for viewing
88 changes: 0 additions & 88 deletions
88
...t-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BaseViewManagerTest.java
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
...act-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BaseViewManagerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.uimanager | ||
|
||
import com.facebook.react.R | ||
import com.facebook.react.bridge.Arguments | ||
import com.facebook.react.bridge.JavaOnlyMap | ||
import com.facebook.react.views.view.ReactViewGroup | ||
import com.facebook.react.views.view.ReactViewManager | ||
import java.util.Locale | ||
import org.assertj.core.api.Assertions | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.powermock.api.mockito.PowerMockito.mockStatic | ||
import org.powermock.api.mockito.PowerMockito.`when` as whenever | ||
import org.powermock.core.classloader.annotations.PowerMockIgnore | ||
import org.powermock.core.classloader.annotations.PrepareForTest | ||
import org.powermock.modules.junit4.rule.PowerMockRule | ||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.RuntimeEnvironment | ||
|
||
@PrepareForTest(Arguments::class) | ||
@RunWith(RobolectricTestRunner::class) | ||
@PowerMockIgnore("org.mockito.*", "org.robolectric.*", "androidx.*", "android.*") | ||
class BaseViewManagerTest { | ||
private lateinit var viewManager: BaseViewManager<ReactViewGroup, *> | ||
private lateinit var view: ReactViewGroup | ||
|
||
@get:Rule var rule = PowerMockRule() | ||
|
||
@Before | ||
fun setUp() { | ||
viewManager = ReactViewManager() | ||
view = ReactViewGroup(RuntimeEnvironment.getApplication()) | ||
mockStatic(Arguments::class.java) | ||
whenever(Arguments.createMap()).thenAnswer { JavaOnlyMap() } | ||
} | ||
|
||
@Test | ||
fun testAccessibilityRoleNone() { | ||
viewManager.setAccessibilityRole(view, "none") | ||
Assertions.assertThat(view.getTag(R.id.accessibility_role)) | ||
.isEqualTo(ReactAccessibilityDelegate.AccessibilityRole.NONE) | ||
} | ||
|
||
@Test | ||
fun testAccessibilityRoleTurkish() { | ||
Locale.setDefault(Locale.forLanguageTag("tr-TR")) | ||
viewManager.setAccessibilityRole(view, "image") | ||
Assertions.assertThat(view.getTag(R.id.accessibility_role)) | ||
.isEqualTo(ReactAccessibilityDelegate.AccessibilityRole.IMAGE) | ||
} | ||
|
||
@Test | ||
fun testAccessibilityStateSelected() { | ||
val accessibilityState = Arguments.createMap() | ||
accessibilityState.putBoolean("selected", true) | ||
viewManager.setViewState(view, accessibilityState) | ||
Assertions.assertThat(view.getTag(R.id.accessibility_state)).isEqualTo(accessibilityState) | ||
Assertions.assertThat(view.isSelected).isEqualTo(true) | ||
} | ||
|
||
@Test | ||
fun testRoleList() { | ||
viewManager.setRole(view, "list") | ||
Assertions.assertThat(view.getTag(R.id.role)).isEqualTo(ReactAccessibilityDelegate.Role.LIST) | ||
} | ||
} |