react-native-navigation 7.24.2 → 7.24.3-snapshot.492
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/android/app/build.gradle +12 -9
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +1 -0
- package/lib/ios/RNNComponentRootView.m +0 -14
- package/package.json +1 -1
- package/.buildkite/pipeline.yml +0 -59
- package/lib/android/app/src/test/java/com/reactnativenavigation/BaseTest.java +0 -178
- package/lib/android/app/src/test/java/com/reactnativenavigation/EnvironmentTest.java +0 -43
- package/lib/android/app/src/test/java/com/reactnativenavigation/TestActivity.java +0 -23
- package/lib/android/app/src/test/java/com/reactnativenavigation/TestApplication.java +0 -35
- package/lib/android/app/src/test/java/com/reactnativenavigation/TestUtils.java +0 -62
- package/lib/android/app/src/test/java/com/reactnativenavigation/fakes/IconResolverFake.kt +0 -8
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/BackDrawable.java +0 -30
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/ImageLoaderMock.kt +0 -49
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/Mocks.kt +0 -18
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleComponentViewController.java +0 -15
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleOverlay.java +0 -54
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleViewController.java +0 -113
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentLayout.java +0 -79
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentViewCreator.java +0 -18
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestReactView.java +0 -71
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TitleBarButtonCreatorMock.java +0 -34
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TitleBarReactViewCreatorMock.java +0 -20
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TopBarBackgroundViewCreatorMock.java +0 -20
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TypefaceLoaderMock.kt +0 -21
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/LayoutNodeParserTest.java +0 -51
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/OptionsTest.java +0 -315
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/OrientationOptionsTest.java +0 -81
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/TopBarButtonsTest.kt +0 -95
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/TransitionAnimationOptionsTest.kt +0 -122
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/BoolParserTest.java +0 -28
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/ColorParseTest.java +0 -50
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/JSONParserTest.java +0 -64
- package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/PresenterTest.java +0 -56
- package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/RenderCheckerTest.java +0 -59
- package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/SideMenuPresenterTest.java +0 -35
- package/lib/android/app/src/test/java/com/reactnativenavigation/react/NavigationModuleTest.java +0 -102
- package/lib/android/app/src/test/java/com/reactnativenavigation/react/ReloadListenerTest.java +0 -24
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/AnimationHelper.kt +0 -33
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ButtonPresenterTest.java +0 -241
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ButtonSpanTest.java +0 -57
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/CompatUtilsTest.java +0 -17
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/LayoutFactoryTest.java +0 -78
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/MotionEventTest.kt +0 -47
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/NativeCommandListenerTest.java +0 -60
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/OptionHelper.java +0 -16
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ReflectionUtilsTest.java +0 -26
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/StringUtilsTest.java +0 -19
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/SystemUiUtilsTest.kt +0 -27
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleAndButtonsMeasurerTest.kt +0 -357
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleBarHelper.java +0 -54
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiThreadTest.java +0 -29
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiUtilsTest.java +0 -22
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ViewHelper.java +0 -9
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java +0 -149
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabPresenterTest.java +0 -206
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsAttacherTest.java +0 -62
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.kt +0 -589
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsPresenterTest.kt +0 -173
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/AfterInitialTabTest.java +0 -38
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/AttachModeTest.java +0 -86
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/OnSwitchToTabTest.java +0 -31
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/TogetherTest.java +0 -20
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/button/NavigationIconResolverTest.java +0 -78
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllerTest.java +0 -80
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllersRegistryTest.java +0 -56
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewControllerTest.java +0 -209
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/ExternalComponentViewControllerTest.java +0 -97
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/FragmentCreatorMock.java +0 -34
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/SomeFragment.java +0 -8
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/fakes/FakeParentController.kt +0 -33
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorMock.java +0 -40
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorTest.kt +0 -213
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalPresenterTest.java +0 -319
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalStackTest.java +0 -367
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/NavigatorTest.java +0 -898
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/RootPresenterTest.kt +0 -254
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayManagerTest.java +0 -108
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/parent/ParentControllerTest.java +0 -299
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuControllerTest.java +0 -446
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/BackButtonHelperTest.java +0 -77
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/FloatingActionButtonTest.java +0 -154
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/IdStackTest.java +0 -114
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackAnimatorTest.kt +0 -241
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.kt +0 -1165
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenterTest.kt +0 -1081
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TitleBarButtonControllerTest.java +0 -61
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TitleBarReactViewControllerTest.java +0 -43
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarButtonControllerTest.java +0 -120
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarControllerTest.kt +0 -432
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsViewControllerTest.java +0 -249
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewControllerTest.java +0 -337
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegateTest.java +0 -68
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/OverlayTouchDelegateTest.java +0 -60
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/TitleAndButtonsContainerTest.kt +0 -477
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java +0 -82
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/BaseViewAnimatorTest.kt +0 -109
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/DefaultViewAnimatorCreatorFake.kt +0 -36
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsContainerTest.kt +0 -101
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsTest.kt +0 -40
- package/lib/android/app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +0 -1
|
@@ -172,6 +172,7 @@ allprojects { p ->
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
dependencies {
|
|
175
|
+
|
|
175
176
|
implementation "androidx.core:core-ktx:1.6.0"
|
|
176
177
|
implementation "org.jetbrains.kotlin:$kotlinStdlib:$kotlinVersion"
|
|
177
178
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutinesCore"
|
|
@@ -189,13 +190,15 @@ dependencies {
|
|
|
189
190
|
//noinspection GradleDynamicVersion
|
|
190
191
|
implementation 'com.facebook.react:react-native:+'
|
|
191
192
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
193
|
+
if("Playground".toLowerCase() == rootProject.name.toLowerCase()){
|
|
194
|
+
// tests only for our playground
|
|
195
|
+
testImplementation 'junit:junit:4.13.2'
|
|
196
|
+
testImplementation "org.robolectric:robolectric:4.7.2"
|
|
197
|
+
testImplementation 'org.assertj:assertj-core:3.11.1'
|
|
198
|
+
testImplementation 'org.mockito:mockito-core:4.0.0'
|
|
199
|
+
testImplementation 'com.squareup.assertj:assertj-android:1.2.0'
|
|
200
|
+
testImplementation 'org.mockito:mockito-inline:3.4.0'
|
|
201
|
+
testImplementation "org.mockito.kotlin:mockito-kotlin:4.0.0"
|
|
202
|
+
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
|
|
203
|
+
}
|
|
201
204
|
}
|
|
@@ -78,6 +78,7 @@ public class ComponentViewController extends ChildController<ComponentLayout> {
|
|
|
78
78
|
if (view != null)
|
|
79
79
|
view.sendComponentWillStart();
|
|
80
80
|
super.onViewDidAppear();
|
|
81
|
+
view.requestApplyInsets();
|
|
81
82
|
if (view != null && lastVisibilityState == VisibilityState.Disappear) view.sendComponentStart();
|
|
82
83
|
lastVisibilityState = VisibilityState.Appear;
|
|
83
84
|
}
|
|
@@ -2,20 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
@implementation RNNComponentRootView
|
|
4
4
|
|
|
5
|
-
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
|
6
|
-
moduleName:(NSString *)moduleName
|
|
7
|
-
initialProperties:(NSDictionary *)initialProperties
|
|
8
|
-
eventEmitter:(RNNEventEmitter *)eventEmitter
|
|
9
|
-
reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
|
|
10
|
-
self = [super initWithBridge:bridge
|
|
11
|
-
moduleName:moduleName
|
|
12
|
-
initialProperties:initialProperties
|
|
13
|
-
eventEmitter:eventEmitter
|
|
14
|
-
reactViewReadyBlock:reactViewReadyBlock];
|
|
15
|
-
[bridge.uiManager setAvailableSize:UIScreen.mainScreen.bounds.size forRootView:self];
|
|
16
|
-
return self;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
5
|
- (NSString *)componentType {
|
|
20
6
|
return ComponentTypeScreen;
|
|
21
7
|
}
|
package/package.json
CHANGED
package/.buildkite/pipeline.yml
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
steps:
|
|
2
|
-
- block: ":rocket: Release!"
|
|
3
|
-
prompt: "Fill out the details for release"
|
|
4
|
-
if: 'build.message =~ /^release\$/i'
|
|
5
|
-
fields:
|
|
6
|
-
- text: "VERSION"
|
|
7
|
-
key: "version"
|
|
8
|
-
- text: "NPM_TAG"
|
|
9
|
-
key: "npm-tag"
|
|
10
|
-
default: 'null'
|
|
11
|
-
required: false
|
|
12
|
-
- text: "BUILD_DOCUMENTATION_VERSION"
|
|
13
|
-
key: "build-documentation-version"
|
|
14
|
-
default: 'null'
|
|
15
|
-
hint: 'Leave NULL if no version is specified'
|
|
16
|
-
- text: "REMOVE_DOCUMENTATION_VERSION"
|
|
17
|
-
key: "remove-documentation-version"
|
|
18
|
-
default: 'null'
|
|
19
|
-
hint: 'Leave NULL if no version is specified'
|
|
20
|
-
|
|
21
|
-
- label: ":android: Android"
|
|
22
|
-
command:
|
|
23
|
-
- "nvm install"
|
|
24
|
-
- "npm install"
|
|
25
|
-
- "npm run test-js"
|
|
26
|
-
- "npm run test-unit-android -- --release"
|
|
27
|
-
- "npm run test-e2e-android-multi -- --release --headless --verbose --ci"
|
|
28
|
-
key: "android_build"
|
|
29
|
-
timeout_in_minutes: 90
|
|
30
|
-
|
|
31
|
-
- label: ":ios: iOS - Unit"
|
|
32
|
-
command:
|
|
33
|
-
- "nvm install"
|
|
34
|
-
- "npm install"
|
|
35
|
-
- "npm run test-unit-ios -- --release"
|
|
36
|
-
key: "ios_unit"
|
|
37
|
-
timeout_in_minutes: 90
|
|
38
|
-
|
|
39
|
-
- label: ":ios: iOS - E2E"
|
|
40
|
-
command:
|
|
41
|
-
- "nvm install"
|
|
42
|
-
- "npm install"
|
|
43
|
-
- "npm run test-snapshot-ios -- --release"
|
|
44
|
-
- "npm run test-e2e-ios -- --release --multi --ci"
|
|
45
|
-
key: "ios_e2e"
|
|
46
|
-
timeout_in_minutes: 90
|
|
47
|
-
|
|
48
|
-
- label: ":package: Publish"
|
|
49
|
-
env:
|
|
50
|
-
if: "build.pull_request.id == null"
|
|
51
|
-
command:
|
|
52
|
-
- "nvm install"
|
|
53
|
-
- "npm install"
|
|
54
|
-
- "npm run release"
|
|
55
|
-
depends_on:
|
|
56
|
-
- "android_build"
|
|
57
|
-
- "ios_unit"
|
|
58
|
-
- "ios_e2e"
|
|
59
|
-
timeout_in_minutes: 90
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation;
|
|
2
|
-
|
|
3
|
-
import static com.reactnativenavigation.utils.CollectionUtils.forEach;
|
|
4
|
-
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
5
|
-
import static org.mockito.ArgumentMatchers.any;
|
|
6
|
-
import static org.mockito.Mockito.mock;
|
|
7
|
-
import static org.mockito.Mockito.when;
|
|
8
|
-
|
|
9
|
-
import android.app.Activity;
|
|
10
|
-
import android.content.Context;
|
|
11
|
-
import android.content.res.Configuration;
|
|
12
|
-
import android.content.res.Resources;
|
|
13
|
-
import android.os.Handler;
|
|
14
|
-
import android.os.Looper;
|
|
15
|
-
import android.view.View;
|
|
16
|
-
import android.view.ViewGroup;
|
|
17
|
-
|
|
18
|
-
import androidx.annotation.CallSuper;
|
|
19
|
-
import androidx.appcompat.app.AppCompatActivity;
|
|
20
|
-
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
21
|
-
|
|
22
|
-
import com.reactnativenavigation.options.params.Bool;
|
|
23
|
-
import com.reactnativenavigation.utils.Functions;
|
|
24
|
-
import com.reactnativenavigation.utils.SystemUiUtils;
|
|
25
|
-
import com.reactnativenavigation.utils.ViewUtils;
|
|
26
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
27
|
-
|
|
28
|
-
import org.junit.After;
|
|
29
|
-
import org.junit.Before;
|
|
30
|
-
import org.junit.runner.RunWith;
|
|
31
|
-
import org.mockito.ArgumentMatchers;
|
|
32
|
-
import org.mockito.MockedStatic;
|
|
33
|
-
import org.mockito.Mockito;
|
|
34
|
-
import org.robolectric.Robolectric;
|
|
35
|
-
import org.robolectric.RobolectricTestRunner;
|
|
36
|
-
import org.robolectric.Shadows;
|
|
37
|
-
import org.robolectric.android.controller.ActivityController;
|
|
38
|
-
import org.robolectric.annotation.Config;
|
|
39
|
-
import org.robolectric.shadows.ShadowLooper;
|
|
40
|
-
|
|
41
|
-
import java.util.Arrays;
|
|
42
|
-
|
|
43
|
-
@RunWith(RobolectricTestRunner.class)
|
|
44
|
-
@Config(sdk = 28, application = TestApplication.class)
|
|
45
|
-
public abstract class BaseTest {
|
|
46
|
-
private final Handler handler = new Handler(Looper.getMainLooper());
|
|
47
|
-
private final ShadowLooper shadowMainLooper = Shadows.shadowOf(Looper.getMainLooper());
|
|
48
|
-
protected Configuration mockConfiguration;
|
|
49
|
-
|
|
50
|
-
@Before
|
|
51
|
-
public void beforeEach() {
|
|
52
|
-
NavigationApplication.instance = Mockito.mock(NavigationApplication.class);
|
|
53
|
-
mockConfiguration = Mockito.mock(Configuration.class);
|
|
54
|
-
Resources res = mock(Resources.class);
|
|
55
|
-
mockConfiguration.uiMode = Configuration.UI_MODE_NIGHT_NO;
|
|
56
|
-
when(res.getConfiguration()).thenReturn(mockConfiguration);
|
|
57
|
-
when(NavigationApplication.instance.getResources()).thenReturn(res);
|
|
58
|
-
when(res.getColor(ArgumentMatchers.anyInt())).thenReturn(0x00000);
|
|
59
|
-
when(res.getColor(ArgumentMatchers.anyInt(),any())).thenReturn(0x00000);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
public void mockSystemUiUtils(int statusBarHeight, int statusBarHeightDp, Functions.Func1<MockedStatic<SystemUiUtils>> mockedBlock) {
|
|
64
|
-
try (MockedStatic<SystemUiUtils> theMock = Mockito.mockStatic(SystemUiUtils.class)) {
|
|
65
|
-
theMock.when(() -> {
|
|
66
|
-
SystemUiUtils.getStatusBarHeight(any());
|
|
67
|
-
}).thenReturn(statusBarHeight);
|
|
68
|
-
theMock.when(() -> {
|
|
69
|
-
SystemUiUtils.getStatusBarHeightDp(any());
|
|
70
|
-
}).thenReturn(statusBarHeightDp);
|
|
71
|
-
mockedBlock.run(theMock);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@After
|
|
76
|
-
@CallSuper
|
|
77
|
-
public void afterEach() {
|
|
78
|
-
idleMainLooper();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
public Activity newActivity() {
|
|
82
|
-
return Robolectric.setupActivity(AppCompatActivity.class);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public <T extends AppCompatActivity> ActivityController<T> newActivityController(Class<T> clazz) {
|
|
86
|
-
return Robolectric.buildActivity(clazz);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public void assertIsChild(ViewGroup parent, ViewController<?>... children) {
|
|
90
|
-
forEach(Arrays.asList(children), c -> assertIsChild(parent, c.getView()));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public void assertIsChild(ViewGroup parent, View child) {
|
|
94
|
-
assertThat(parent).isNotNull();
|
|
95
|
-
assertThat(child).isNotNull();
|
|
96
|
-
assertThat(ViewUtils.isChildOf(parent, child)).isTrue();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
public void assertNotChildOf(ViewGroup parent, ViewController<?>... children) {
|
|
100
|
-
forEach(Arrays.asList(children), c -> assertNotChildOf(parent, c.getView()));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
public void assertNotChildOf(ViewGroup parent, View child) {
|
|
104
|
-
assertThat(parent).isNotNull();
|
|
105
|
-
assertThat(child).isNotNull();
|
|
106
|
-
assertThat(ViewUtils.isChildOf(parent, child)).isFalse();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
public void assertMatchParent(View view) {
|
|
110
|
-
assertThat(view.getLayoutParams().width).isEqualTo(ViewGroup.LayoutParams.MATCH_PARENT);
|
|
111
|
-
assertThat(view.getLayoutParams().height).isEqualTo(ViewGroup.LayoutParams.MATCH_PARENT);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
protected void disablePushAnimation(ViewController<?>... controllers) {
|
|
115
|
-
for (ViewController<?> controller : controllers) {
|
|
116
|
-
controller.options.animations.push.enabled = new Bool(false);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
protected void disablePopAnimation(ViewController<?>... controllers) {
|
|
121
|
-
for (ViewController<?> controller : controllers) {
|
|
122
|
-
controller.options.animations.pop.enabled = new Bool(false);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
protected void disableModalAnimations(ViewController<?>... modals) {
|
|
127
|
-
disableShowModalAnimation(modals);
|
|
128
|
-
disableDismissModalAnimation(modals);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
protected void disableShowModalAnimation(ViewController<?>... modals) {
|
|
132
|
-
for (ViewController<?> modal : modals) {
|
|
133
|
-
modal.options.animations.showModal.toggle(new Bool(false));
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
protected void disableDismissModalAnimation(ViewController<?>... modals) {
|
|
138
|
-
for (ViewController<?> modal : modals) {
|
|
139
|
-
modal.options.animations.dismissModal.toggle(new Bool(false));
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
protected void dispatchPreDraw(View view) {
|
|
144
|
-
view.getViewTreeObserver().dispatchOnPreDraw();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
protected void dispatchOnGlobalLayout(View view) {
|
|
148
|
-
view.getViewTreeObserver().dispatchOnGlobalLayout();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
protected void addToParent(Context context, ViewController<?>... controllers) {
|
|
152
|
-
for (ViewController<?> controller : controllers) {
|
|
153
|
-
new CoordinatorLayout(context).addView(controller.getView());
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
protected View mockView(Activity activity) {
|
|
158
|
-
View mock = Mockito.mock(View.class);
|
|
159
|
-
when(mock.getContext()).thenReturn(activity);
|
|
160
|
-
return mock;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
protected void assertVisible(View view) {
|
|
164
|
-
assertThat(view.getVisibility()).isEqualTo(View.VISIBLE);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
protected void assertGone(View view) {
|
|
168
|
-
assertThat(view.getVisibility()).isEqualTo(View.GONE);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
protected void post(Runnable runnable) {
|
|
172
|
-
handler.post(runnable);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
protected void idleMainLooper() {
|
|
176
|
-
shadowMainLooper.idle();
|
|
177
|
-
}
|
|
178
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation;
|
|
2
|
-
|
|
3
|
-
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
4
|
-
import androidx.appcompat.app.AppCompatActivity;
|
|
5
|
-
|
|
6
|
-
import com.facebook.react.common.*;
|
|
7
|
-
|
|
8
|
-
import org.junit.*;
|
|
9
|
-
import org.robolectric.*;
|
|
10
|
-
|
|
11
|
-
import static org.assertj.core.api.Java6Assertions.*;
|
|
12
|
-
|
|
13
|
-
public class EnvironmentTest extends BaseTest {
|
|
14
|
-
@Test
|
|
15
|
-
public void assertJ() {
|
|
16
|
-
assertThat(1 + 2).isEqualTo(3).isGreaterThan(2).isLessThan(4).isNotNegative().isPositive().isNotZero();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@Test
|
|
20
|
-
public void react() {
|
|
21
|
-
assertThat(ReactConstants.TAG).isNotEmpty();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@Test
|
|
25
|
-
public void supportV7AppCompat() {
|
|
26
|
-
assertThat(AppCompatActivity.class).isNotNull();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@Test
|
|
30
|
-
public void supportDesign() {
|
|
31
|
-
assertThat(FloatingActionButton.class).isNotNull();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@Test
|
|
35
|
-
public void androidR() {
|
|
36
|
-
assertThat(R.string.bottom_sheet_behavior).isNotZero();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@Test
|
|
40
|
-
public void ableToLoadApplication() throws Exception {
|
|
41
|
-
assertThat(RuntimeEnvironment.application).isNotNull();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation;
|
|
2
|
-
|
|
3
|
-
import com.reactnativenavigation.react.ReactGateway;
|
|
4
|
-
import com.reactnativenavigation.viewcontrollers.navigator.Navigator;
|
|
5
|
-
|
|
6
|
-
import org.mockito.Mockito;
|
|
7
|
-
|
|
8
|
-
public class TestActivity extends NavigationActivity {
|
|
9
|
-
|
|
10
|
-
@Override
|
|
11
|
-
public ReactGateway getReactGateway() {
|
|
12
|
-
return Mockito.mock(ReactGateway.class);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public void setNavigator(Navigator navigator) {
|
|
16
|
-
this.navigator = navigator;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@Override
|
|
20
|
-
public void onBackPressed() {
|
|
21
|
-
super.onBackPressed();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation;
|
|
2
|
-
|
|
3
|
-
import android.app.*;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.ReactApplication;
|
|
6
|
-
import com.facebook.react.ReactNativeHost;
|
|
7
|
-
import com.facebook.react.ReactPackage;
|
|
8
|
-
|
|
9
|
-
import java.util.Collections;
|
|
10
|
-
import java.util.List;
|
|
11
|
-
|
|
12
|
-
public class TestApplication extends Application implements ReactApplication {
|
|
13
|
-
private final ReactNativeHost host = new ReactNativeHost(this) {
|
|
14
|
-
@Override
|
|
15
|
-
public boolean getUseDeveloperSupport() {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@Override
|
|
20
|
-
protected List<ReactPackage> getPackages() {
|
|
21
|
-
return Collections.emptyList();
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
@Override
|
|
26
|
-
public void onCreate() {
|
|
27
|
-
super.onCreate();
|
|
28
|
-
setTheme(R.style.Theme_AppCompat);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@Override
|
|
32
|
-
public ReactNativeHost getReactNativeHost() {
|
|
33
|
-
return host;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.content.Context;
|
|
5
|
-
import android.view.View;
|
|
6
|
-
import android.view.ViewGroup;
|
|
7
|
-
|
|
8
|
-
import androidx.annotation.NonNull;
|
|
9
|
-
|
|
10
|
-
import com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock;
|
|
11
|
-
import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
|
|
12
|
-
import com.reactnativenavigation.mocks.TitleBarButtonCreatorMock;
|
|
13
|
-
import com.reactnativenavigation.mocks.TypefaceLoaderMock;
|
|
14
|
-
import com.reactnativenavigation.options.Options;
|
|
15
|
-
import com.reactnativenavigation.options.params.Bool;
|
|
16
|
-
import com.reactnativenavigation.utils.RenderChecker;
|
|
17
|
-
import com.reactnativenavigation.viewcontrollers.stack.StackPresenter;
|
|
18
|
-
import com.reactnativenavigation.react.events.EventEmitter;
|
|
19
|
-
import com.reactnativenavigation.utils.CompatUtils;
|
|
20
|
-
import com.reactnativenavigation.utils.ImageLoader;
|
|
21
|
-
import com.reactnativenavigation.utils.UiUtils;
|
|
22
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
23
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
24
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.IconResolver;
|
|
25
|
-
import com.reactnativenavigation.viewcontrollers.stack.StackControllerBuilder;
|
|
26
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController;
|
|
27
|
-
import com.reactnativenavigation.views.stack.StackLayout;
|
|
28
|
-
import com.reactnativenavigation.views.stack.topbar.TopBar;
|
|
29
|
-
|
|
30
|
-
import org.mockito.Mockito;
|
|
31
|
-
|
|
32
|
-
public class TestUtils {
|
|
33
|
-
public static StackControllerBuilder newStackController(Activity activity) {
|
|
34
|
-
TopBarController topBarController = new TopBarController() {
|
|
35
|
-
@Override
|
|
36
|
-
protected TopBar createTopBar(@NonNull Context context, @NonNull StackLayout stackLayout) {
|
|
37
|
-
TopBar topBar = super.createTopBar(context, stackLayout);
|
|
38
|
-
topBar.layout(0, 0, 1000, UiUtils.getTopBarHeight(context));
|
|
39
|
-
return topBar;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
return new StackControllerBuilder(activity, Mockito.mock(EventEmitter.class))
|
|
43
|
-
.setId("stack" + CompatUtils.generateViewId())
|
|
44
|
-
.setChildRegistry(new ChildControllersRegistry())
|
|
45
|
-
.setTopBarController(topBarController)
|
|
46
|
-
.setStackPresenter(new StackPresenter(activity, new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TitleBarButtonCreatorMock(), new IconResolver(activity, new ImageLoader()), new TypefaceLoaderMock(), new RenderChecker(), new Options()))
|
|
47
|
-
.setInitialOptions(new Options());
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public static void hideBackButton(ViewController<?> viewController) {
|
|
51
|
-
viewController.options.topBar.buttons.back.visible = new Bool(false);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public static <T extends View> T spyOn(T child) {
|
|
55
|
-
ViewGroup parent = (ViewGroup) child.getParent();
|
|
56
|
-
int indexOf = parent.indexOfChild(child);
|
|
57
|
-
parent.removeView(child);
|
|
58
|
-
T spy = Mockito.spy(child);
|
|
59
|
-
parent.addView(spy, indexOf);
|
|
60
|
-
return spy;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.fakes
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import com.reactnativenavigation.mocks.ImageLoaderMock
|
|
5
|
-
import com.reactnativenavigation.utils.ImageLoader
|
|
6
|
-
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.IconResolver
|
|
7
|
-
|
|
8
|
-
class IconResolverFake(activity: Activity, imageLoader: ImageLoader = ImageLoaderMock.mock()) : IconResolver(activity, imageLoader)
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.mocks;
|
|
2
|
-
|
|
3
|
-
import android.graphics.Canvas;
|
|
4
|
-
import android.graphics.ColorFilter;
|
|
5
|
-
import android.graphics.drawable.Drawable;
|
|
6
|
-
|
|
7
|
-
import androidx.annotation.NonNull;
|
|
8
|
-
import androidx.annotation.Nullable;
|
|
9
|
-
|
|
10
|
-
public class BackDrawable extends Drawable {
|
|
11
|
-
@Override
|
|
12
|
-
public void draw(@NonNull Canvas canvas) {
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@Override
|
|
17
|
-
public void setAlpha(int alpha) {
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@Override
|
|
22
|
-
public void setColorFilter(@Nullable ColorFilter colorFilter) {
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@Override
|
|
27
|
-
public int getOpacity() {
|
|
28
|
-
return 0;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.mocks
|
|
2
|
-
|
|
3
|
-
import android.graphics.Canvas
|
|
4
|
-
import android.graphics.ColorFilter
|
|
5
|
-
import android.graphics.drawable.Drawable
|
|
6
|
-
|
|
7
|
-
import com.reactnativenavigation.utils.ImageLoader
|
|
8
|
-
import com.reactnativenavigation.utils.ImageLoader.ImagesLoadingListener
|
|
9
|
-
import org.mockito.Mockito.doAnswer
|
|
10
|
-
import org.mockito.kotlin.any
|
|
11
|
-
import org.mockito.kotlin.mock
|
|
12
|
-
import org.mockito.kotlin.whenever
|
|
13
|
-
import java.util.*
|
|
14
|
-
|
|
15
|
-
object ImageLoaderMock {
|
|
16
|
-
val mockDrawable: Drawable = object : Drawable() {
|
|
17
|
-
override fun draw(canvas: Canvas) {}
|
|
18
|
-
override fun setAlpha(alpha: Int) {}
|
|
19
|
-
override fun setColorFilter(colorFilter: ColorFilter?) {}
|
|
20
|
-
override fun getOpacity(): Int {
|
|
21
|
-
return 0
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
private val backIcon: Drawable = BackDrawable()
|
|
25
|
-
|
|
26
|
-
@JvmStatic
|
|
27
|
-
fun mock(): ImageLoader {
|
|
28
|
-
return this.mock(mockDrawable)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@JvmStatic
|
|
32
|
-
fun mock(returnDrawable: Drawable = mockDrawable): ImageLoader {
|
|
33
|
-
val imageLoader = mock<ImageLoader>()
|
|
34
|
-
doAnswer { invocation ->
|
|
35
|
-
val urlCount = (invocation.arguments[1] as Collection<*>).size
|
|
36
|
-
val drawables = Collections.nCopies(urlCount, returnDrawable)
|
|
37
|
-
(invocation.arguments[2] as ImagesLoadingListener).onComplete(drawables)
|
|
38
|
-
null
|
|
39
|
-
}.`when`(imageLoader).loadIcons(any(), any(), any())
|
|
40
|
-
|
|
41
|
-
doAnswer { invocation ->
|
|
42
|
-
(invocation.arguments[2] as ImagesLoadingListener).onComplete(returnDrawable)
|
|
43
|
-
null
|
|
44
|
-
}.`when`(imageLoader).loadIcon(any(), any(), any())
|
|
45
|
-
|
|
46
|
-
whenever(imageLoader.getBackButtonIcon(any())).thenReturn(backIcon)
|
|
47
|
-
return imageLoader
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.mocks
|
|
2
|
-
|
|
3
|
-
import android.view.ViewGroup
|
|
4
|
-
|
|
5
|
-
import com.reactnativenavigation.options.Options
|
|
6
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController
|
|
7
|
-
import org.mockito.kotlin.mock
|
|
8
|
-
import org.mockito.kotlin.whenever
|
|
9
|
-
|
|
10
|
-
object Mocks {
|
|
11
|
-
fun viewController(): ViewController<*> {
|
|
12
|
-
val mock = mock<ViewController<*>>()
|
|
13
|
-
whenever(mock.resolveCurrentOptions()).thenReturn(Options.EMPTY)
|
|
14
|
-
val view = mock<ViewGroup>()
|
|
15
|
-
whenever(mock.view).thenReturn(view)
|
|
16
|
-
return mock
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.mocks;
|
|
2
|
-
|
|
3
|
-
import android.app.*;
|
|
4
|
-
|
|
5
|
-
import com.reactnativenavigation.options.*;
|
|
6
|
-
import com.reactnativenavigation.viewcontrollers.component.ComponentPresenter;
|
|
7
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
|
|
8
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
9
|
-
import com.reactnativenavigation.viewcontrollers.component.ComponentViewController;
|
|
10
|
-
|
|
11
|
-
public class SimpleComponentViewController extends ComponentViewController {
|
|
12
|
-
public SimpleComponentViewController(Activity activity, ChildControllersRegistry childRegistry, String id, Options initialOptions) {
|
|
13
|
-
super(activity, childRegistry,id, "theComponentName", new TestComponentViewCreator(), initialOptions, new Presenter(activity, new Options()), new ComponentPresenter(Options.EMPTY));
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.mocks;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.view.MotionEvent;
|
|
5
|
-
import android.view.ViewGroup;
|
|
6
|
-
import android.widget.FrameLayout;
|
|
7
|
-
import android.widget.RelativeLayout;
|
|
8
|
-
|
|
9
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ScrollEventListener;
|
|
10
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.IReactView;
|
|
11
|
-
|
|
12
|
-
public class SimpleOverlay extends RelativeLayout implements IReactView {
|
|
13
|
-
public SimpleOverlay(Context context) {
|
|
14
|
-
super(context);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@Override
|
|
18
|
-
public boolean isReady() {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@Override
|
|
23
|
-
public ViewGroup asView() {
|
|
24
|
-
FrameLayout root = new FrameLayout(getContext());
|
|
25
|
-
FrameLayout overlay = new FrameLayout(getContext());
|
|
26
|
-
root.addView(overlay);
|
|
27
|
-
return root;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@Override
|
|
31
|
-
public void destroy() {
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@Override
|
|
36
|
-
public void sendOnNavigationButtonPressed(String buttonId) {
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@Override
|
|
41
|
-
public ScrollEventListener getScrollEventListener() {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@Override
|
|
46
|
-
public void dispatchTouchEventToJs(MotionEvent event) {
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@Override
|
|
51
|
-
public boolean isRendered() {
|
|
52
|
-
return getChildCount() >= 1;
|
|
53
|
-
}
|
|
54
|
-
}
|