Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public data class LengthPercentage(
null
}
}
ReadableType.Null -> null
else -> {
FLog.w(ReactConstants.TAG, "Unsupported type for radius property: ${dynamic.type}")
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<3b339a7d81f8e32cf6b6ca93ae9a388b>>
* @generated SignedSource<<acbc1716191446a5c496c66dfa368b52>>
*/

/**
Expand Down Expand Up @@ -461,15 +461,17 @@ constructor(private val fpsListener: FpsListener? = null) :
companion object {
const val REACT_CLASS: String = "RCTScrollView"

fun createExportedCustomDirectEventTypeConstants(): Map<String, Any> = mapOf(
getJSEventName(ScrollEventType.SCROLL) to mapOf("registrationName" to "onScroll"),
getJSEventName(ScrollEventType.BEGIN_DRAG) to
mapOf("registrationName" to "onScrollBeginDrag"),
getJSEventName(ScrollEventType.END_DRAG) to mapOf("registrationName" to "onScrollEndDrag"),
getJSEventName(ScrollEventType.MOMENTUM_BEGIN) to
mapOf("registrationName" to "onMomentumScrollBegin"),
getJSEventName(ScrollEventType.MOMENTUM_END) to
mapOf("registrationName" to "onMomentumScrollEnd"),
)
fun createExportedCustomDirectEventTypeConstants(): Map<String, Any> =
mapOf(
getJSEventName(ScrollEventType.SCROLL) to mapOf("registrationName" to "onScroll"),
getJSEventName(ScrollEventType.BEGIN_DRAG) to
mapOf("registrationName" to "onScrollBeginDrag"),
getJSEventName(ScrollEventType.END_DRAG) to
mapOf("registrationName" to "onScrollEndDrag"),
getJSEventName(ScrollEventType.MOMENTUM_BEGIN) to
mapOf("registrationName" to "onMomentumScrollBegin"),
getJSEventName(ScrollEventType.MOMENTUM_END) to
mapOf("registrationName" to "onMomentumScrollEnd"),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.common.logging.FLog
import com.facebook.react.bridge.DynamicFromObject
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.mockito.Mockito.mockStatic

class LengthPercentageTest {

@Test
fun parsesPointAndPercentageValues() {
assertThat(LengthPercentage.setFromDynamic(DynamicFromObject(12.0)))
.isEqualTo(LengthPercentage(12f, LengthPercentageType.POINT))
assertThat(LengthPercentage.setFromDynamic(DynamicFromObject("25%")))
.isEqualTo(LengthPercentage(25f, LengthPercentageType.PERCENT))
}

@Test
fun rejectsNegativeValuesByDefault() {
assertThat(LengthPercentage.setFromDynamic(DynamicFromObject(-1.0))).isNull()
assertThat(LengthPercentage.setFromDynamic(DynamicFromObject("-1%"))).isNull()
}

@Test
fun acceptsNegativeValuesWhenAllowed() {
assertThat(LengthPercentage.setFromDynamic(DynamicFromObject(-1.0), allowNegative = true))
.isEqualTo(LengthPercentage(-1f, LengthPercentageType.POINT))
assertThat(LengthPercentage.setFromDynamic(DynamicFromObject("-1%"), allowNegative = true))
.isEqualTo(LengthPercentage(-1f, LengthPercentageType.PERCENT))
}

@Test
fun clearsNullWithoutWarning() {
mockStatic(FLog::class.java).use { flog ->
assertThat(LengthPercentage.setFromDynamic(DynamicFromObject(null))).isNull()
flog.verifyNoInteractions()
}
}
}
Loading