mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
NativeAnimatedDriver: synchronize animation lifecycle closer to Fabric or Paper lifecycle
Summary: Switch between "Fabric" and "Non-Fabric" modes based on which types of native Views are being attached to animations. Don't allow non-Fabric to drive Fabric animations and vice-versa. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D21985411 fbshipit-source-id: fb9bef1e38375b384430b4e0275e7b6d62eda7a4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3346ac7f96
commit
472cf3f4ad
+60
-2
@@ -20,8 +20,11 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.Callback;
|
||||
import com.facebook.react.bridge.CatalystInstance;
|
||||
import com.facebook.react.bridge.JSIModuleType;
|
||||
import com.facebook.react.bridge.JavaOnlyArray;
|
||||
import com.facebook.react.bridge.JavaOnlyMap;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
@@ -54,6 +57,8 @@ public class NativeAnimatedNodeTraversalTest {
|
||||
@Rule public PowerMockRule rule = new PowerMockRule();
|
||||
|
||||
private long mFrameTimeNanos;
|
||||
private ReactApplicationContext mReactApplicationContextMock;
|
||||
private CatalystInstance mCatalystInstanceMock;
|
||||
private UIManagerModule mUIManagerMock;
|
||||
private EventDispatcher mEventDispatcherMock;
|
||||
private NativeAnimatedNodesManager mNativeAnimatedNodesManager;
|
||||
@@ -83,6 +88,59 @@ public class NativeAnimatedNodeTraversalTest {
|
||||
});
|
||||
|
||||
mFrameTimeNanos = INITIAL_FRAME_TIME_NANOS;
|
||||
|
||||
mReactApplicationContextMock = mock(ReactApplicationContext.class);
|
||||
PowerMockito.when(mReactApplicationContextMock.hasActiveCatalystInstance())
|
||||
.thenAnswer(
|
||||
new Answer<Boolean>() {
|
||||
@Override
|
||||
public Boolean answer(InvocationOnMock invocationOnMock) throws Throwable {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
PowerMockito.when(mReactApplicationContextMock.hasCatalystInstance())
|
||||
.thenAnswer(
|
||||
new Answer<Boolean>() {
|
||||
@Override
|
||||
public Boolean answer(InvocationOnMock invocationOnMock) throws Throwable {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
PowerMockito.when(mReactApplicationContextMock.getCatalystInstance())
|
||||
.thenAnswer(
|
||||
new Answer<CatalystInstance>() {
|
||||
@Override
|
||||
public CatalystInstance answer(InvocationOnMock invocationOnMock) throws Throwable {
|
||||
return mCatalystInstanceMock;
|
||||
}
|
||||
});
|
||||
PowerMockito.when(mReactApplicationContextMock.getNativeModule(any(Class.class)))
|
||||
.thenAnswer(
|
||||
new Answer<UIManagerModule>() {
|
||||
@Override
|
||||
public UIManagerModule answer(InvocationOnMock invocationOnMock) throws Throwable {
|
||||
return mUIManagerMock;
|
||||
}
|
||||
});
|
||||
|
||||
mCatalystInstanceMock = mock(CatalystInstance.class);
|
||||
PowerMockito.when(mCatalystInstanceMock.getJSIModule(any(JSIModuleType.class)))
|
||||
.thenAnswer(
|
||||
new Answer<UIManagerModule>() {
|
||||
@Override
|
||||
public UIManagerModule answer(InvocationOnMock invocationOnMock) throws Throwable {
|
||||
return mUIManagerMock;
|
||||
}
|
||||
});
|
||||
PowerMockito.when(mCatalystInstanceMock.getNativeModule(any(Class.class)))
|
||||
.thenAnswer(
|
||||
new Answer<UIManagerModule>() {
|
||||
@Override
|
||||
public UIManagerModule answer(InvocationOnMock invocationOnMock) throws Throwable {
|
||||
return mUIManagerMock;
|
||||
}
|
||||
});
|
||||
|
||||
mUIManagerMock = mock(UIManagerModule.class);
|
||||
mEventDispatcherMock = mock(EventDispatcher.class);
|
||||
PowerMockito.when(mUIManagerMock.getEventDispatcher())
|
||||
@@ -125,7 +183,7 @@ public class NativeAnimatedNodeTraversalTest {
|
||||
};
|
||||
}
|
||||
});
|
||||
mNativeAnimatedNodesManager = new NativeAnimatedNodesManager(mUIManagerMock);
|
||||
mNativeAnimatedNodesManager = new NativeAnimatedNodesManager(mReactApplicationContextMock);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -931,7 +989,7 @@ public class NativeAnimatedNodeTraversalTest {
|
||||
MapBuilder.of("topScroll", MapBuilder.of("registrationName", "onScroll")));
|
||||
}
|
||||
});
|
||||
mNativeAnimatedNodesManager = new NativeAnimatedNodesManager(mUIManagerMock);
|
||||
mNativeAnimatedNodesManager = new NativeAnimatedNodesManager(mReactApplicationContextMock);
|
||||
|
||||
createSimpleAnimatedViewWithOpacity(viewTag, 0d);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user