Przeglądaj źródła

fix e2e, fixed indentation

Daniel Zlotin 7 lat temu
rodzic
commit
6cead57c5f
68 zmienionych plików z 2130 dodań i 2178 usunięć
  1. 124
    125
      AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ApplicationLifecycleTest.java
  2. 2
    2
      AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/BackHandlerTest.java
  3. 11
    11
      AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/BaseTest.java
  4. 9
    9
      AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/EnvironmentTest.java
  5. 107
    107
      AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ModalsTest.java
  6. 4
    7
      AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/NavigationOptionsTest.java
  7. 20
    20
      AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ScreenLifecycleTest.java
  8. 38
    38
      AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ScreenStackTest.java
  9. 21
    21
      AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/TopLevelApiTest.java
  10. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabsOptions.java
  11. 5
    5
      lib/android/app/src/main/java/com/reactnativenavigation/parse/Button.java
  12. 5
    5
      lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutFactory.java
  13. 7
    7
      lib/android/app/src/main/java/com/reactnativenavigation/parse/Options.java
  14. 16
    16
      lib/android/app/src/main/java/com/reactnativenavigation/parse/TopBarOptions.java
  15. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/presentation/NavigationOptionsListener.java
  16. 6
    6
      lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java
  17. 3
    3
      lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java
  18. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/BottomTabsController.java
  19. 5
    5
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ComponentViewController.java
  20. 5
    5
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/Navigator.java
  21. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ViewController.java
  22. 5
    5
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabController.java
  23. 5
    5
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsController.java
  24. 2
    4
      lib/android/app/src/main/java/com/reactnativenavigation/views/Component.java
  25. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/views/ComponentLayout.java
  26. 4
    4
      lib/android/app/src/main/java/com/reactnativenavigation/views/TitleBarButton.java
  27. 4
    4
      lib/android/app/src/main/java/com/reactnativenavigation/views/TopBar.java
  28. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/views/TopTabsLayout.java
  29. 27
    27
      lib/android/app/src/test/java/com/reactnativenavigation/BaseTest.java
  30. 35
    35
      lib/android/app/src/test/java/com/reactnativenavigation/EnvironmentTest.java
  31. 5
    5
      lib/android/app/src/test/java/com/reactnativenavigation/TestApplication.java
  32. 64
    67
      lib/android/app/src/test/java/com/reactnativenavigation/anim/ViewAnimationSetBuilderTest.java
  33. 20
    20
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/MockPromise.java
  34. 6
    6
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleComponentViewController.java
  35. 14
    14
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleViewController.java
  36. 8
    10
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentLayout.java
  37. 15
    16
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentView.java
  38. 7
    7
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentViewCreator.java
  39. 14
    14
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestNavigationAnimator.java
  40. 3
    3
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/TopTabLayoutMock.java
  41. 1
    1
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/TypefaceLoaderMock.java
  42. 55
    58
      lib/android/app/src/test/java/com/reactnativenavigation/parse/JSONParserTest.java
  43. 43
    43
      lib/android/app/src/test/java/com/reactnativenavigation/parse/LayoutNodeParserTest.java
  44. 23
    24
      lib/android/app/src/test/java/com/reactnativenavigation/parse/NavigationOptionsTest.java
  45. 37
    37
      lib/android/app/src/test/java/com/reactnativenavigation/parse/OverlayOptionsTest.java
  46. 32
    33
      lib/android/app/src/test/java/com/reactnativenavigation/react/NavigationReactNativeHostTest.java
  47. 9
    9
      lib/android/app/src/test/java/com/reactnativenavigation/utils/CompatUtilsTest.java
  48. 16
    16
      lib/android/app/src/test/java/com/reactnativenavigation/utils/ReflectionUtilsTest.java
  49. 12
    12
      lib/android/app/src/test/java/com/reactnativenavigation/utils/StringUtilsTest.java
  50. 36
    36
      lib/android/app/src/test/java/com/reactnativenavigation/utils/TypefaceLoaderTest.java
  51. 21
    24
      lib/android/app/src/test/java/com/reactnativenavigation/utils/UiThreadTest.java
  52. 9
    9
      lib/android/app/src/test/java/com/reactnativenavigation/utils/UiUtilsTest.java
  53. 106
    110
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/BottomTabsControllerTest.java
  54. 53
    56
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ComponentViewControllerTest.java
  55. 106
    106
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/IdStackTest.java
  56. 270
    276
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java
  57. 66
    67
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java
  58. 77
    82
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ParentControllerTest.java
  59. 277
    280
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/StackControllerTest.java
  60. 10
    12
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabControllerTest.java
  61. 4
    4
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsControllerMock.java
  62. 16
    22
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsViewControllerTest.java
  63. 182
    186
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java
  64. 10
    10
      lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java
  65. 1
    1
      playground/android/app/src/main/java/com/reactnativenavigation/playground/MainActivity.java
  66. 13
    13
      playground/android/app/src/main/java/com/reactnativenavigation/playground/MainApplication.java
  67. 1
    1
      playground/src/screens/ModalScreen.js
  68. 8
    2
      playground/src/screens/WelcomeScreen.js

+ 124
- 125
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ApplicationLifecycleTest.java Wyświetl plik

@@ -1,133 +1,132 @@
1 1
 package com.reactnativenavigation.e2e.androide2e;
2 2
 
3
-import android.content.Intent;
4
-import android.net.Uri;
5
-import android.provider.Settings;
6
-import android.support.test.uiautomator.By;
7
-import android.view.KeyEvent;
3
+import android.content.*;
4
+import android.net.*;
5
+import android.provider.*;
6
+import android.support.test.uiautomator.*;
7
+import android.view.*;
8 8
 
9
-import org.junit.Assume;
10
-import org.junit.Test;
9
+import org.junit.*;
11 10
 
12
-import static android.support.test.InstrumentationRegistry.getInstrumentation;
11
+import static android.support.test.InstrumentationRegistry.*;
13 12
 
14 13
 public class ApplicationLifecycleTest extends BaseTest {
15 14
 
16
-	@Test
17
-	public void relaunchFromBackground() throws Exception {
18
-		elementByText("PUSH").click();
19
-		assertExists(By.text("Pushed Screen"));
20
-
21
-		device().pressHome();
22
-		device().pressRecentApps();
23
-		elementByText("Playground").click();
24
-
25
-		assertExists(By.text("Pushed Screen"));
26
-	}
27
-
28
-	@Test
29
-	public void relaunchAfterClose() throws Exception {
30
-		elementByText("PUSH").click();
31
-		assertExists(By.text("Pushed Screen"));
32
-
33
-		device().pressBack();
34
-
35
-		launchTheApp();
36
-		assertMainShown();
37
-	}
38
-
39
-	@Test
40
-	public void deviceOrientationDoesNotDestroyActivity() throws Exception {
41
-		elementByText("PUSH").click();
42
-		assertExists(By.text("Pushed Screen"));
43
-
44
-		device().setOrientationLeft();
45
-		Thread.sleep(100);
46
-
47
-		assertExists(By.text("Pushed Screen"));
48
-	}
49
-
50
-	@Test
51
-	public void relaunchAfterActivityKilledBySystem() throws Exception {
52
-		elementByText("PUSH").click();
53
-		assertExists(By.text("Pushed Screen"));
54
-
55
-		killAppSaveInstanceState_ByTogglingPermissions();
56
-
57
-		device().pressRecentApps();
58
-		elementByText("Playground").click();
59
-		assertMainShown();
60
-	}
61
-
62
-	@Test
63
-	public void pressingMenuOpensDevMenu() throws Exception {
64
-		Assume.assumeTrue(isDebug());
65
-		device().pressKeyCode(KeyEvent.KEYCODE_MENU);
66
-		assertExists(By.text("Debug JS Remotely"));
67
-	}
68
-
69
-	@Test
70
-	public void pressingRTwiceInSuccessionReloadsReactNative() throws Exception {
71
-		Assume.assumeTrue(isDebug());
72
-
73
-		elementByText("PUSH").click();
74
-		assertExists(By.text("Pushed Screen"));
75
-
76
-		device().pressKeyCode(KeyEvent.KEYCODE_R);
77
-		device().pressKeyCode(KeyEvent.KEYCODE_R);
78
-		device().waitForIdle();
79
-		assertMainShown();
80
-	}
81
-
82
-	@Test
83
-	public void pressingRTwiceWithDelayDoesNothing() throws Exception {
84
-		Assume.assumeTrue(isDebug());
85
-
86
-		elementByText("PUSH").click();
87
-		assertExists(By.text("Pushed Screen"));
88
-
89
-		device().pressKeyCode(KeyEvent.KEYCODE_R);
90
-		Thread.sleep(1500);
91
-		device().pressKeyCode(KeyEvent.KEYCODE_R);
92
-		assertExists(By.text("Pushed Screen"));
93
-	}
94
-
95
-	@Test
96
-	public void sendingReloadBroadcastReloadsReactNative() throws Exception {
97
-		Assume.assumeTrue(isDebug());
98
-
99
-		elementByText("PUSH").click();
100
-		assertExists(By.text("Pushed Screen"));
101
-
102
-		device().executeShellCommand("am broadcast -a com.reactnativenavigation.broadcast.RELOAD");
103
-		device().waitForIdle();
104
-		assertMainShown();
105
-	}
106
-
107
-	private void killAppSaveInstanceState_ByTogglingPermissions() throws Exception {
108
-		device().pressHome();
109
-
110
-		device().waitForIdle();
111
-		launchAppInfoSettings();
112
-		device().waitForIdle();
113
-
114
-		elementByText("Permissions").click();
115
-		elementByText("Storage").click();
116
-		elementByText("Storage").click();
117
-		device().pressBack();
118
-		device().pressBack();
119
-		device().pressHome();
120
-		device().waitForIdle();
121
-	}
122
-
123
-	private void launchAppInfoSettings() {
124
-		Intent intent = new Intent();
125
-		intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
126
-		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
127
-		intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
128
-		intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
129
-		Uri uri = Uri.fromParts("package", PACKAGE_NAME, null);
130
-		intent.setData(uri);
131
-		getInstrumentation().getTargetContext().startActivity(intent);
132
-	}
15
+    @Test
16
+    public void relaunchFromBackground() throws Exception {
17
+        elementByText("PUSH").click();
18
+        assertExists(By.text("Pushed Screen"));
19
+
20
+        device().pressHome();
21
+        device().pressRecentApps();
22
+        elementByText("Playground").click();
23
+
24
+        assertExists(By.text("Pushed Screen"));
25
+    }
26
+
27
+    @Test
28
+    public void relaunchAfterClose() throws Exception {
29
+        elementByText("PUSH").click();
30
+        assertExists(By.text("Pushed Screen"));
31
+
32
+        device().pressBack();
33
+
34
+        launchTheApp();
35
+        assertMainShown();
36
+    }
37
+
38
+    @Test
39
+    public void deviceOrientationDoesNotDestroyActivity() throws Exception {
40
+        elementByText("PUSH").click();
41
+        assertExists(By.text("Pushed Screen"));
42
+
43
+        device().setOrientationLeft();
44
+        Thread.sleep(100);
45
+
46
+        assertExists(By.text("Pushed Screen"));
47
+    }
48
+
49
+    @Test
50
+    public void relaunchAfterActivityKilledBySystem() throws Exception {
51
+        elementByText("PUSH").click();
52
+        assertExists(By.text("Pushed Screen"));
53
+
54
+        killAppSaveInstanceState_ByTogglingPermissions();
55
+
56
+        device().pressRecentApps();
57
+        elementByText("Playground").click();
58
+        assertMainShown();
59
+    }
60
+
61
+    @Test
62
+    public void pressingMenuOpensDevMenu() throws Exception {
63
+        Assume.assumeTrue(isDebug());
64
+        device().pressKeyCode(KeyEvent.KEYCODE_MENU);
65
+        assertExists(By.text("Debug JS Remotely"));
66
+    }
67
+
68
+    @Test
69
+    public void pressingRTwiceInSuccessionReloadsReactNative() throws Exception {
70
+        Assume.assumeTrue(isDebug());
71
+
72
+        elementByText("PUSH").click();
73
+        assertExists(By.text("Pushed Screen"));
74
+
75
+        device().pressKeyCode(KeyEvent.KEYCODE_R);
76
+        device().pressKeyCode(KeyEvent.KEYCODE_R);
77
+        device().waitForIdle();
78
+        assertMainShown();
79
+    }
80
+
81
+    @Test
82
+    public void pressingRTwiceWithDelayDoesNothing() throws Exception {
83
+        Assume.assumeTrue(isDebug());
84
+
85
+        elementByText("PUSH").click();
86
+        assertExists(By.text("Pushed Screen"));
87
+
88
+        device().pressKeyCode(KeyEvent.KEYCODE_R);
89
+        Thread.sleep(1500);
90
+        device().pressKeyCode(KeyEvent.KEYCODE_R);
91
+        assertExists(By.text("Pushed Screen"));
92
+    }
93
+
94
+    @Test
95
+    public void sendingReloadBroadcastReloadsReactNative() throws Exception {
96
+        Assume.assumeTrue(isDebug());
97
+
98
+        elementByText("PUSH").click();
99
+        assertExists(By.text("Pushed Screen"));
100
+
101
+        device().executeShellCommand("am broadcast -a com.reactnativenavigation.broadcast.RELOAD");
102
+        device().waitForIdle();
103
+        assertMainShown();
104
+    }
105
+
106
+    private void killAppSaveInstanceState_ByTogglingPermissions() throws Exception {
107
+        device().pressHome();
108
+
109
+        device().waitForIdle();
110
+        launchAppInfoSettings();
111
+        device().waitForIdle();
112
+
113
+        elementByText("Permissions").click();
114
+        elementByText("Storage").click();
115
+        elementByText("Storage").click();
116
+        device().pressBack();
117
+        device().pressBack();
118
+        device().pressHome();
119
+        device().waitForIdle();
120
+    }
121
+
122
+    private void launchAppInfoSettings() {
123
+        Intent intent = new Intent();
124
+        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
125
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
126
+        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
127
+        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
128
+        Uri uri = Uri.fromParts("package", PACKAGE_NAME, null);
129
+        intent.setData(uri);
130
+        getInstrumentation().getTargetContext().startActivity(intent);
131
+    }
133 132
 }

+ 2
- 2
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/BackHandlerTest.java Wyświetl plik

@@ -1,8 +1,8 @@
1 1
 package com.reactnativenavigation.e2e.androide2e;
2 2
 
3
-import android.support.test.uiautomator.By;
3
+import android.support.test.uiautomator.*;
4 4
 
5
-import org.junit.Test;
5
+import org.junit.*;
6 6
 
7 7
 public class BackHandlerTest extends BaseTest {
8 8
     @Test

+ 11
- 11
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/BaseTest.java Wyświetl plik

@@ -89,17 +89,17 @@ public abstract class BaseTest {
89 89
         return bitmap;
90 90
     }
91 91
 
92
-	public void swipeOpenFromLeft() {
93
-		int w = device().getDisplayWidth();
94
-		int h = device().getDisplayHeight();
95
-		device().swipe(5, h / 2, w / 2, h / 2, 20);
96
-	}
97
-
98
-	public void swipeOpenFromRight() {
99
-		int w = device().getDisplayWidth();
100
-		int h = device().getDisplayHeight();
101
-		device().swipe(w - 5, h / 2, w / 2, h / 2, 20);
102
-	}
92
+    public void swipeOpenFromLeft() {
93
+        int w = device().getDisplayWidth();
94
+        int h = device().getDisplayHeight();
95
+        device().swipe(5, h / 2, w / 2, h / 2, 20);
96
+    }
97
+
98
+    public void swipeOpenFromRight() {
99
+        int w = device().getDisplayWidth();
100
+        int h = device().getDisplayHeight();
101
+        device().swipe(w - 5, h / 2, w / 2, h / 2, 20);
102
+    }
103 103
 
104 104
     public void swipeUp() {
105 105
         int w = device().getDisplayWidth();

+ 9
- 9
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/EnvironmentTest.java Wyświetl plik

@@ -1,17 +1,17 @@
1 1
 package com.reactnativenavigation.e2e.androide2e;
2 2
 
3
-import android.support.test.runner.AndroidJUnit4;
3
+import android.support.test.runner.*;
4 4
 
5
-import org.junit.Test;
6
-import org.junit.runner.RunWith;
5
+import org.junit.*;
6
+import org.junit.runner.*;
7 7
 
8
-import static android.support.test.InstrumentationRegistry.getInstrumentation;
9
-import static org.assertj.core.api.Java6Assertions.assertThat;
8
+import static android.support.test.InstrumentationRegistry.*;
9
+import static org.assertj.core.api.Java6Assertions.*;
10 10
 
11 11
 @RunWith(AndroidJUnit4.class)
12 12
 public class EnvironmentTest {
13
-	@Test
14
-	public void instrumentationAndAssertJ() throws Exception {
15
-		assertThat(getInstrumentation().getTargetContext().getPackageName()).isEqualTo("com.reactnativenavigation.e2e.androide2e");
16
-	}
13
+    @Test
14
+    public void instrumentationAndAssertJ() throws Exception {
15
+        assertThat(getInstrumentation().getTargetContext().getPackageName()).isEqualTo("com.reactnativenavigation.e2e.androide2e");
16
+    }
17 17
 }

+ 107
- 107
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ModalsTest.java Wyświetl plik

@@ -1,116 +1,116 @@
1 1
 package com.reactnativenavigation.e2e.androide2e;
2 2
 
3
-import android.support.test.uiautomator.By;
3
+import android.support.test.uiautomator.*;
4 4
 
5
-import org.junit.Test;
5
+import org.junit.*;
6 6
 
7 7
 public class ModalsTest extends BaseTest {
8 8
 
9
-	@Test
10
-	public void showModal() throws Exception {
11
-		elementByText("SHOW MODAL").click();
12
-		assertExists(By.text("Modal Screen"));
13
-	}
14
-
15
-	@Test
16
-	public void dismissModal() throws Exception {
17
-		elementByText("SHOW MODAL").click();
18
-		assertExists(By.text("Modal Screen"));
19
-
20
-		elementByText("DISMISS MODAL").click();
21
-		assertMainShown();
22
-
23
-	}
24
-
25
-	@Test
26
-	public void showMultipleModals() throws Exception {
27
-		elementByText("SHOW MODAL").click();
28
-		assertExists(By.text("Modal Stack Position: 1"));
29
-
30
-		elementByText("SHOW MODAL").click();
31
-		assertExists(By.text("Modal Stack Position: 2"));
32
-
33
-		elementByText("DISMISS MODAL").click();
34
-		assertExists(By.text("Modal Stack Position: 1"));
35
-
36
-		elementByText("DISMISS MODAL").click();
37
-		assertMainShown();
38
-	}
39
-
40
-	@Test
41
-	public void dismissUnknownContainerId() throws Exception {
42
-		elementByText("SHOW MODAL").click();
43
-		assertExists(By.text("Modal Stack Position: 1"));
44
-
45
-		elementByText("DISMISS UNKNOWN MODAL").click();
46
-		assertExists(By.text("Modal Stack Position: 1"));
47
-
48
-		elementByText("DISMISS MODAL").click();
49
-		assertMainShown();
50
-	}
51
-
52
-	@Test
53
-	public void dismissModalByContainerIdWhenNotOnTop() throws Exception {
54
-		elementByText("SHOW MODAL").click();
55
-		assertExists(By.text("Modal Stack Position: 1"));
56
-
57
-		elementByText("SHOW MODAL").click();
58
-		assertExists(By.text("Modal Stack Position: 2"));
59
-
60
-		elementByText("DISMISS PREVIOUS MODAL").click();
61
-		assertExists(By.text("Modal Stack Position: 2"));
62
-
63
-		elementByText("DISMISS MODAL").click();
64
-		assertMainShown();
65
-	}
66
-
67
-	@Test
68
-	public void dismissAllPreviousModalsByIdWhenTheyAreBelowTopPresented() throws Exception {
69
-		elementByText("SHOW MODAL").click();
70
-		assertExists(By.text("Modal Stack Position: 1"));
71
-		elementByText("SHOW MODAL").click();
72
-		assertExists(By.text("Modal Stack Position: 2"));
73
-		elementByText("SHOW MODAL").click();
74
-		assertExists(By.text("Modal Stack Position: 3"));
75
-
76
-		elementByText("DISMISS ALL PREVIOUS MODALS").click();
77
-		assertExists(By.text("Modal Stack Position: 3"));
78
-
79
-		elementByText("DISMISS MODAL").click();
80
-		assertMainShown();
81
-	}
82
-
83
-	@Test
84
-	public void dismissSomeModalByIdDeepInTheStack() throws Exception {
85
-		elementByText("SHOW MODAL").click();
86
-		assertExists(By.text("Modal Stack Position: 1"));
87
-		elementByText("SHOW MODAL").click();
88
-		assertExists(By.text("Modal Stack Position: 2"));
89
-		elementByText("SHOW MODAL").click();
90
-		assertExists(By.text("Modal Stack Position: 3"));
91
-
92
-		elementByText("DISMISS FIRST IN STACK").click();
93
-		assertExists(By.text("Modal Stack Position: 3"));
94
-
95
-		elementByText("DISMISS MODAL").click();
96
-		assertExists(By.text("Modal Stack Position: 2"));
97
-
98
-		elementByText("DISMISS MODAL").click();
99
-		assertMainShown();
100
-	}
101
-
102
-	@Test
103
-	public void dismissAllModals() throws Exception {
104
-		elementByText("SHOW MODAL").click();
105
-		assertExists(By.text("Modal Stack Position: 1"));
106
-		elementByText("SHOW MODAL").click();
107
-		assertExists(By.text("Modal Stack Position: 2"));
108
-
109
-		elementByText("DISMISS ALL MODALS").click();
110
-		assertMainShown();
111
-	}
112
-
113
-	@Test
9
+    @Test
10
+    public void showModal() throws Exception {
11
+        elementByText("SHOW MODAL").click();
12
+        assertExists(By.text("Modal Screen"));
13
+    }
14
+
15
+    @Test
16
+    public void dismissModal() throws Exception {
17
+        elementByText("SHOW MODAL").click();
18
+        assertExists(By.text("Modal Screen"));
19
+
20
+        elementByText("DISMISS MODAL").click();
21
+        assertMainShown();
22
+
23
+    }
24
+
25
+    @Test
26
+    public void showMultipleModals() throws Exception {
27
+        elementByText("SHOW MODAL").click();
28
+        assertExists(By.text("Modal Stack Position: 1"));
29
+
30
+        elementByText("SHOW MODAL").click();
31
+        assertExists(By.text("Modal Stack Position: 2"));
32
+
33
+        elementByText("DISMISS MODAL").click();
34
+        assertExists(By.text("Modal Stack Position: 1"));
35
+
36
+        elementByText("DISMISS MODAL").click();
37
+        assertMainShown();
38
+    }
39
+
40
+    @Test
41
+    public void dismissUnknownContainerId() throws Exception {
42
+        elementByText("SHOW MODAL").click();
43
+        assertExists(By.text("Modal Stack Position: 1"));
44
+
45
+        elementByText("DISMISS UNKNOWN MODAL").click();
46
+        assertExists(By.text("Modal Stack Position: 1"));
47
+
48
+        elementByText("DISMISS MODAL").click();
49
+        assertMainShown();
50
+    }
51
+
52
+    @Test
53
+    public void dismissModalByContainerIdWhenNotOnTop() throws Exception {
54
+        elementByText("SHOW MODAL").click();
55
+        assertExists(By.text("Modal Stack Position: 1"));
56
+
57
+        elementByText("SHOW MODAL").click();
58
+        assertExists(By.text("Modal Stack Position: 2"));
59
+
60
+        elementByText("DISMISS PREVIOUS MODAL").click();
61
+        assertExists(By.text("Modal Stack Position: 2"));
62
+
63
+        elementByText("DISMISS MODAL").click();
64
+        assertMainShown();
65
+    }
66
+
67
+    @Test
68
+    public void dismissAllPreviousModalsByIdWhenTheyAreBelowTopPresented() throws Exception {
69
+        elementByText("SHOW MODAL").click();
70
+        assertExists(By.text("Modal Stack Position: 1"));
71
+        elementByText("SHOW MODAL").click();
72
+        assertExists(By.text("Modal Stack Position: 2"));
73
+        elementByText("SHOW MODAL").click();
74
+        assertExists(By.text("Modal Stack Position: 3"));
75
+
76
+        elementByText("DISMISS ALL PREVIOUS MODALS").click();
77
+        assertExists(By.text("Modal Stack Position: 3"));
78
+
79
+        elementByText("DISMISS MODAL").click();
80
+        assertMainShown();
81
+    }
82
+
83
+    @Test
84
+    public void dismissSomeModalByIdDeepInTheStack() throws Exception {
85
+        elementByText("SHOW MODAL").click();
86
+        assertExists(By.text("Modal Stack Position: 1"));
87
+        elementByText("SHOW MODAL").click();
88
+        assertExists(By.text("Modal Stack Position: 2"));
89
+        elementByText("SHOW MODAL").click();
90
+        assertExists(By.text("Modal Stack Position: 3"));
91
+
92
+        elementByText("DISMISS FIRST IN STACK").click();
93
+        assertExists(By.text("Modal Stack Position: 3"));
94
+
95
+        elementByText("DISMISS MODAL").click();
96
+        assertExists(By.text("Modal Stack Position: 2"));
97
+
98
+        elementByText("DISMISS MODAL").click();
99
+        assertMainShown();
100
+    }
101
+
102
+    @Test
103
+    public void dismissAllModals() throws Exception {
104
+        elementByText("SHOW MODAL").click();
105
+        assertExists(By.text("Modal Stack Position: 1"));
106
+        elementByText("SHOW MODAL").click();
107
+        assertExists(By.text("Modal Stack Position: 2"));
108
+
109
+        elementByText("DISMISS ALL MODALS").click();
110
+        assertMainShown();
111
+    }
112
+
113
+    @Test
114 114
     public void pushIntoModal() throws Exception {
115 115
         elementByText("SHOW MODAL").click();
116 116
         elementByText("PUSH SCREEN").click();

+ 4
- 7
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/NavigationOptionsTest.java Wyświetl plik

@@ -1,11 +1,10 @@
1 1
 package com.reactnativenavigation.e2e.androide2e;
2 2
 
3
-import android.support.test.uiautomator.By;
4
-import android.support.test.uiautomator.Until;
3
+import android.support.test.uiautomator.*;
5 4
 
6
-import org.junit.Test;
5
+import org.junit.*;
7 6
 
8
-import static org.assertj.core.api.Java6Assertions.assertThat;
7
+import static org.assertj.core.api.Java6Assertions.*;
9 8
 
10 9
 public class NavigationOptionsTest extends BaseTest {
11 10
 
@@ -26,10 +25,8 @@ public class NavigationOptionsTest extends BaseTest {
26 25
     @Test
27 26
     public void testTopBarHidden() throws Exception {
28 27
         elementByText("PUSH OPTIONS SCREEN").click();
29
-        int topWithNavigation = elementByText("HIDE TOP BAR").getVisibleBounds().top;
30 28
         elementByText("HIDE TOP BAR").click();
31
-        int topWithoutNavigation = elementByText("HIDE TOP BAR").getVisibleBounds().top;
32
-        assertThat(topWithoutNavigation).isLessThan(topWithNavigation);
29
+        assertThat(elementByText("Static Title").exists()).isFalse();
33 30
         elementByText("SHOW TOP BAR").click();
34 31
         assertExists(By.text("Static Title"));
35 32
     }

+ 20
- 20
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ScreenLifecycleTest.java Wyświetl plik

@@ -1,30 +1,30 @@
1 1
 package com.reactnativenavigation.e2e.androide2e;
2 2
 
3
-import android.support.test.uiautomator.By;
3
+import android.support.test.uiautomator.*;
4 4
 
5
-import org.junit.Test;
5
+import org.junit.*;
6 6
 
7 7
 public class ScreenLifecycleTest extends BaseTest {
8 8
 
9
-	@Test
10
-	public void didAppearDidDisappear() throws Exception {
11
-		elementByText("PUSH LIFECYCLE SCREEN").click();
12
-		assertExists(By.text("didAppear"));
13
-		elementByText("PUSH TO TEST DIDDISAPPEAR").click();
14
-		assertExists(By.text("didDisappear"));
15
-	}
9
+    @Test
10
+    public void didAppearDidDisappear() throws Exception {
11
+        elementByText("PUSH LIFECYCLE SCREEN").click();
12
+        assertExists(By.text("didAppear"));
13
+        elementByText("PUSH TO TEST DIDDISAPPEAR").click();
14
+        assertExists(By.text("didDisappear"));
15
+    }
16 16
 
17
-	@Test
18
-	public void unmountIsCalledWhenPopped() throws Exception {
19
-		elementByText("PUSH LIFECYCLE SCREEN").click();
20
-		assertExists(By.text("didAppear"));
17
+    @Test
18
+    public void unmountIsCalledWhenPopped() throws Exception {
19
+        elementByText("PUSH LIFECYCLE SCREEN").click();
20
+        assertExists(By.text("didAppear"));
21 21
 
22
-		device().pressBack();
22
+        device().pressBack();
23 23
 
24
-		assertExists(By.text("componentWillUnmount"));
25
-		elementByText("OK").click();
26
-		assertExists(By.text("didDisappear"));
27
-		elementByText("OK").click();
28
-		assertMainShown();
29
-	}
24
+        assertExists(By.text("componentWillUnmount"));
25
+        elementByText("OK").click();
26
+        assertExists(By.text("didDisappear"));
27
+        elementByText("OK").click();
28
+        assertMainShown();
29
+    }
30 30
 }

+ 38
- 38
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ScreenStackTest.java Wyświetl plik

@@ -1,48 +1,48 @@
1 1
 package com.reactnativenavigation.e2e.androide2e;
2 2
 
3
-import android.support.test.uiautomator.By;
3
+import android.support.test.uiautomator.*;
4 4
 
5
-import org.junit.Test;
5
+import org.junit.*;
6 6
 
7 7
 public class ScreenStackTest extends BaseTest {
8 8
 
9
-	@Test
10
-	public void pushAndPopScreen() throws Exception {
11
-		elementByText("PUSH").click();
12
-		assertExists(By.text("Pushed Screen"));
13
-		elementByText("POP").click();
14
-		assertMainShown();
15
-	}
9
+    @Test
10
+    public void pushAndPopScreen() throws Exception {
11
+        elementByText("PUSH").click();
12
+        assertExists(By.text("Pushed Screen"));
13
+        elementByText("POP").click();
14
+        assertMainShown();
15
+    }
16 16
 
17
-	@Test
18
-	public void popScreenDeepInTheStack() throws Exception {
19
-		elementByText("PUSH").click();
20
-		assertExists(By.text("Pushed Screen"));
21
-		assertExists(By.text("Stack Position: 1"));
22
-		elementByText("PUSH").click();
23
-		assertExists(By.text("Stack Position: 2"));
24
-		elementByText("POP PREVIOUS").click();
25
-		assertExists(By.text("Stack Position: 2"));
26
-		elementByText("POP").click();
27
-		assertMainShown();
28
-	}
17
+    @Test
18
+    public void popScreenDeepInTheStack() throws Exception {
19
+        elementByText("PUSH").click();
20
+        assertExists(By.text("Pushed Screen"));
21
+        assertExists(By.text("Stack Position: 1"));
22
+        elementByText("PUSH").click();
23
+        assertExists(By.text("Stack Position: 2"));
24
+        elementByText("POP PREVIOUS").click();
25
+        assertExists(By.text("Stack Position: 2"));
26
+        elementByText("POP").click();
27
+        assertMainShown();
28
+    }
29 29
 
30
-	@Test
31
-	public void popToId() throws Exception {
32
-		elementByText("PUSH").click();
33
-		elementByText("PUSH").click();
34
-		elementByText("PUSH").click();
35
-		assertExists(By.text("Stack Position: 3"));
36
-		elementByText("POP TO STACK POSITION 1").click();
37
-		assertExists(By.text("Stack Position: 1"));
38
-	}
30
+    @Test
31
+    public void popToId() throws Exception {
32
+        elementByText("PUSH").click();
33
+        elementByText("PUSH").click();
34
+        elementByText("PUSH").click();
35
+        assertExists(By.text("Stack Position: 3"));
36
+        elementByText("POP TO STACK POSITION 1").click();
37
+        assertExists(By.text("Stack Position: 1"));
38
+    }
39 39
 
40
-	@Test
41
-	public void popToRoot() throws Exception {
42
-		elementByText("PUSH").click();
43
-		elementByText("PUSH").click();
44
-		elementByText("PUSH").click();
45
-		elementByText("POP TO ROOT").click();
46
-		assertMainShown();
47
-	}
40
+    @Test
41
+    public void popToRoot() throws Exception {
42
+        elementByText("PUSH").click();
43
+        elementByText("PUSH").click();
44
+        elementByText("PUSH").click();
45
+        elementByText("POP TO ROOT").click();
46
+        assertMainShown();
47
+    }
48 48
 }

+ 21
- 21
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/TopLevelApiTest.java Wyświetl plik

@@ -1,31 +1,31 @@
1 1
 package com.reactnativenavigation.e2e.androide2e;
2 2
 
3
-import android.support.test.uiautomator.By;
3
+import android.support.test.uiautomator.*;
4 4
 
5
-import org.junit.Test;
5
+import org.junit.*;
6 6
 
7 7
 public class TopLevelApiTest extends BaseTest {
8 8
 
9
-	@Test
10
-	public void switchToTabBasedApp_PassPropsFunction() throws Exception {
11
-		elementByText("SWITCH TO TAB BASED APP").click();
12
-		assertExists(By.text("This is tab 1"));
13
-		assertExists(By.text("Hello from a function!"));
14
-  }
15
-  
16
-  @Test
17
-	public void switchToTabBasedApp_SwitchTab() throws Exception {
18
-		elementByText("SWITCH TO TAB BASED APP").click();
19
-		assertExists(By.text("This is tab 1"));
9
+    @Test
10
+    public void switchToTabBasedApp_PassPropsFunction() throws Exception {
11
+        elementByText("SWITCH TO TAB BASED APP").click();
12
+        assertExists(By.text("This is tab 1"));
13
+        assertExists(By.text("Hello from a function!"));
14
+    }
15
+
16
+    @Test
17
+    public void switchToTabBasedApp_SwitchTab() throws Exception {
18
+        elementByText("SWITCH TO TAB BASED APP").click();
19
+        assertExists(By.text("This is tab 1"));
20 20
         elementByText("SWITCH TO TAB 2").click();
21 21
         assertExists(By.text("This is tab 2"));
22
-	}
22
+    }
23 23
 
24
-	@Test
25
-	public void switchToTabsWithSideMenu() throws Exception {
26
-		elementByText("SWITCH TO APP WITH SIDE MENUS").click();
27
-		assertExists(By.textStartsWith("This is a side menu center screen tab 1"));
28
-		swipeOpenFromLeft();
29
-		assertExists(By.text("This is a left side menu screen"));
30
-	}
24
+    @Test
25
+    public void switchToTabsWithSideMenu() throws Exception {
26
+        elementByText("SWITCH TO APP WITH SIDE MENUS").click();
27
+        assertExists(By.textStartsWith("This is a side menu center screen tab 1"));
28
+        swipeOpenFromLeft();
29
+        assertExists(By.text("This is a left side menu screen"));
30
+    }
31 31
 }

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabsOptions.java Wyświetl plik

@@ -1,7 +1,7 @@
1 1
 package com.reactnativenavigation.parse;
2 2
 
3 3
 
4
-import com.reactnativenavigation.parse.NavigationOptions.BooleanOptions;
4
+import com.reactnativenavigation.parse.Options.BooleanOptions;
5 5
 
6 6
 import org.json.JSONObject;
7 7
 

+ 5
- 5
lib/android/app/src/main/java/com/reactnativenavigation/parse/Button.java Wyświetl plik

@@ -9,13 +9,13 @@ import org.json.JSONObject;
9 9
 import java.util.ArrayList;
10 10
 
11 11
 import static com.reactnativenavigation.parse.DEFAULT_VALUES.NO_VALUE;
12
-import static com.reactnativenavigation.parse.NavigationOptions.NO_INT_VALUE;
12
+import static com.reactnativenavigation.parse.Options.NO_INT_VALUE;
13 13
 
14 14
 public class Button {
15 15
 	public String id;
16 16
 	public String title;
17
-	public NavigationOptions.BooleanOptions disabled;
18
-	public NavigationOptions.BooleanOptions disableIconTint;
17
+	public Options.BooleanOptions disabled;
18
+	public Options.BooleanOptions disableIconTint;
19 19
 	public int showAsAction;
20 20
 	@ColorInt public int buttonColor;
21 21
 	public int buttonFontSize;
@@ -26,8 +26,8 @@ public class Button {
26 26
 		Button button = new Button();
27 27
 		button.id = json.optString("id");
28 28
 		button.title = json.optString("title", NO_VALUE);
29
-		button.disabled = NavigationOptions.BooleanOptions.parse(json.optString("disabled", NO_VALUE));
30
-		button.disableIconTint = NavigationOptions.BooleanOptions.parse(json.optString("disableIconTint", NO_VALUE));
29
+		button.disabled = Options.BooleanOptions.parse(json.optString("disabled", NO_VALUE));
30
+		button.disableIconTint = Options.BooleanOptions.parse(json.optString("disableIconTint", NO_VALUE));
31 31
 		button.showAsAction = parseShowAsAction(json.optString("showAsAction", NO_VALUE));
32 32
 		button.buttonColor = json.optInt("buttonColor", NO_INT_VALUE);
33 33
 		button.buttonFontSize = json.optInt("buttonFontSize", NO_INT_VALUE);

+ 5
- 5
lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutFactory.java Wyświetl plik

@@ -23,10 +23,10 @@ public class LayoutFactory {
23 23
 
24 24
 	private final Activity activity;
25 25
 	private final ReactInstanceManager reactInstanceManager;
26
-    private NavigationOptions defaultOptions;
26
+    private Options defaultOptions;
27 27
     private final TypefaceLoader typefaceManager;
28 28
 
29
-    public LayoutFactory(Activity activity, final ReactInstanceManager reactInstanceManager, NavigationOptions defaultOptions) {
29
+    public LayoutFactory(Activity activity, final ReactInstanceManager reactInstanceManager, Options defaultOptions) {
30 30
 		this.activity = activity;
31 31
 		this.reactInstanceManager = reactInstanceManager;
32 32
         this.defaultOptions = defaultOptions;
@@ -96,7 +96,7 @@ public class LayoutFactory {
96 96
 	private ViewController createComponent(LayoutNode node) {
97 97
 		String id = node.id;
98 98
 		String name = node.data.optString("name");
99
-		NavigationOptions options = NavigationOptions.parse(typefaceManager, node.data.optJSONObject("options"), defaultOptions);
99
+		Options options = Options.parse(typefaceManager, node.data.optJSONObject("options"), defaultOptions);
100 100
 		return new ComponentViewController(activity,
101 101
                 id,
102 102
                 name,
@@ -137,14 +137,14 @@ public class LayoutFactory {
137 137
             tabController.setTabIndex(i);
138 138
             tabs.add(tabController);
139 139
         }
140
-        NavigationOptions options = NavigationOptions.parse(typefaceManager, node.getNavigationOptions(), defaultOptions);
140
+        Options options = Options.parse(typefaceManager, node.getNavigationOptions(), defaultOptions);
141 141
         return new TopTabsController(activity, node.id, tabs, new TopTabsLayoutCreator(activity, tabs), options);
142 142
     }
143 143
 
144 144
     private ViewController createTopTab(LayoutNode node) {
145 145
         String id = node.id;
146 146
         String name = node.data.optString("name");
147
-        NavigationOptions options = NavigationOptions.parse(typefaceManager, node.getNavigationOptions(), defaultOptions);
147
+        Options options = Options.parse(typefaceManager, node.getNavigationOptions(), defaultOptions);
148 148
         return new TopTabController(activity,
149 149
                 id,
150 150
                 name,

lib/android/app/src/main/java/com/reactnativenavigation/parse/NavigationOptions.java → lib/android/app/src/main/java/com/reactnativenavigation/parse/Options.java Wyświetl plik

@@ -6,7 +6,7 @@ import com.reactnativenavigation.utils.TypefaceLoader;
6 6
 
7 7
 import org.json.JSONObject;
8 8
 
9
-public class NavigationOptions implements DEFAULT_VALUES {
9
+public class Options implements DEFAULT_VALUES {
10 10
 
11 11
     public enum BooleanOptions {
12 12
 		True,
@@ -22,13 +22,13 @@ public class NavigationOptions implements DEFAULT_VALUES {
22 22
 	}
23 23
 
24 24
     @NonNull
25
-    public static NavigationOptions parse(TypefaceLoader typefaceManager, JSONObject json) {
26
-        return parse(typefaceManager, json, new NavigationOptions());
25
+    public static Options parse(TypefaceLoader typefaceManager, JSONObject json) {
26
+        return parse(typefaceManager, json, new Options());
27 27
     }
28 28
 
29 29
 	@NonNull
30
-	public static NavigationOptions parse(TypefaceLoader typefaceManager, JSONObject json, @NonNull NavigationOptions defaultOptions) {
31
-		NavigationOptions result = new NavigationOptions();
30
+	public static Options parse(TypefaceLoader typefaceManager, JSONObject json, @NonNull Options defaultOptions) {
31
+		Options result = new Options();
32 32
 		if (json == null) return result;
33 33
 
34 34
 		result.topBarOptions = TopBarOptions.parse(typefaceManager, json.optJSONObject("topBar"));
@@ -44,13 +44,13 @@ public class NavigationOptions implements DEFAULT_VALUES {
44 44
     @NonNull public TopTabOptions topTabOptions = new TopTabOptions();
45 45
     @NonNull public BottomTabsOptions bottomTabsOptions = new BottomTabsOptions();
46 46
 
47
-	public void mergeWith(final NavigationOptions other) {
47
+	public void mergeWith(final Options other) {
48 48
         topBarOptions.mergeWith(other.topBarOptions);
49 49
         topTabsOptions.mergeWith(other.topTabsOptions);
50 50
         bottomTabsOptions.mergeWith(other.bottomTabsOptions);
51 51
     }
52 52
 
53
-    NavigationOptions withDefaultOptions(final NavigationOptions other) {
53
+    Options withDefaultOptions(final Options other) {
54 54
         topBarOptions.mergeWithDefault(other.topBarOptions);
55 55
         topTabsOptions.mergeWithDefault(other.topTabsOptions);
56 56
         bottomTabsOptions.mergeWithDefault(other.bottomTabsOptions);

+ 16
- 16
lib/android/app/src/main/java/com/reactnativenavigation/parse/TopBarOptions.java Wyświetl plik

@@ -22,10 +22,10 @@ public class TopBarOptions implements DEFAULT_VALUES {
22 22
         options.textColor = json.optInt("textColor", NO_COLOR_VALUE);
23 23
         options.textFontSize = (float) json.optDouble("textFontSize", NO_FLOAT_VALUE);
24 24
         options.textFontFamily = typefaceManager.getTypeFace(json.optString("textFontFamily", NO_VALUE));
25
-        options.hidden = NavigationOptions.BooleanOptions.parse(json.optString("hidden"));
26
-        options.animateHide = NavigationOptions.BooleanOptions.parse(json.optString("animateHide"));
27
-        options.hideOnScroll = NavigationOptions.BooleanOptions.parse(json.optString("hideOnScroll"));
28
-        options.drawBehind = NavigationOptions.BooleanOptions.parse(json.optString("drawBehind"));
25
+        options.hidden = Options.BooleanOptions.parse(json.optString("hidden"));
26
+        options.animateHide = Options.BooleanOptions.parse(json.optString("animateHide"));
27
+        options.hideOnScroll = Options.BooleanOptions.parse(json.optString("hideOnScroll"));
28
+        options.drawBehind = Options.BooleanOptions.parse(json.optString("drawBehind"));
29 29
         options.rightButtons = Button.parseJsonArray(json.optJSONArray("rightButtons"));
30 30
         options.leftButtons = Button.parseJsonArray(json.optJSONArray("leftButtons"));
31 31
 
@@ -37,10 +37,10 @@ public class TopBarOptions implements DEFAULT_VALUES {
37 37
     @ColorInt public int textColor = NO_COLOR_VALUE;
38 38
     public float textFontSize = NO_FLOAT_VALUE;
39 39
     @Nullable public Typeface textFontFamily;
40
-    public NavigationOptions.BooleanOptions hidden = NavigationOptions.BooleanOptions.NoValue;
41
-    public NavigationOptions.BooleanOptions animateHide = NavigationOptions.BooleanOptions.NoValue;
42
-    public NavigationOptions.BooleanOptions hideOnScroll = NavigationOptions.BooleanOptions.NoValue;
43
-    public NavigationOptions.BooleanOptions drawBehind = NavigationOptions.BooleanOptions.NoValue;
40
+    public Options.BooleanOptions hidden = Options.BooleanOptions.NoValue;
41
+    public Options.BooleanOptions animateHide = Options.BooleanOptions.NoValue;
42
+    public Options.BooleanOptions hideOnScroll = Options.BooleanOptions.NoValue;
43
+    public Options.BooleanOptions drawBehind = Options.BooleanOptions.NoValue;
44 44
     public ArrayList<Button> leftButtons;
45 45
     public ArrayList<Button> rightButtons;
46 46
 
@@ -54,16 +54,16 @@ public class TopBarOptions implements DEFAULT_VALUES {
54 54
             textFontSize = other.textFontSize;
55 55
         if (other.textFontFamily != null)
56 56
             textFontFamily = other.textFontFamily;
57
-        if (other.hidden != NavigationOptions.BooleanOptions.NoValue) {
57
+        if (other.hidden != Options.BooleanOptions.NoValue) {
58 58
             hidden = other.hidden;
59 59
         }
60
-        if (other.animateHide != NavigationOptions.BooleanOptions.NoValue) {
60
+        if (other.animateHide != Options.BooleanOptions.NoValue) {
61 61
             animateHide = other.animateHide;
62 62
         }
63
-        if (other.hideOnScroll != NavigationOptions.BooleanOptions.NoValue) {
63
+        if (other.hideOnScroll != Options.BooleanOptions.NoValue) {
64 64
             hideOnScroll = other.hideOnScroll;
65 65
         }
66
-        if (other.drawBehind != NavigationOptions.BooleanOptions.NoValue) {
66
+        if (other.drawBehind != Options.BooleanOptions.NoValue) {
67 67
             drawBehind = other.drawBehind;
68 68
         }
69 69
         if (other.leftButtons != null)
@@ -83,13 +83,13 @@ public class TopBarOptions implements DEFAULT_VALUES {
83 83
             textFontSize = defaultOptions.textFontSize;
84 84
         if (textFontFamily == null)
85 85
             textFontFamily = defaultOptions.textFontFamily;
86
-        if (hidden == NavigationOptions.BooleanOptions.NoValue)
86
+        if (hidden == Options.BooleanOptions.NoValue)
87 87
             hidden = defaultOptions.hidden;
88
-        if (animateHide == NavigationOptions.BooleanOptions.NoValue)
88
+        if (animateHide == Options.BooleanOptions.NoValue)
89 89
             animateHide = defaultOptions.animateHide;
90
-        if (hideOnScroll == NavigationOptions.BooleanOptions.NoValue)
90
+        if (hideOnScroll == Options.BooleanOptions.NoValue)
91 91
             hideOnScroll = defaultOptions.hideOnScroll;
92
-        if (drawBehind == NavigationOptions.BooleanOptions.NoValue)
92
+        if (drawBehind == Options.BooleanOptions.NoValue)
93 93
             drawBehind = defaultOptions.drawBehind;
94 94
         if (leftButtons == null)
95 95
             leftButtons = defaultOptions.leftButtons;

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/presentation/NavigationOptionsListener.java Wyświetl plik

@@ -1,8 +1,8 @@
1 1
 package com.reactnativenavigation.presentation;
2 2
 
3 3
 
4
-import com.reactnativenavigation.parse.NavigationOptions;
4
+import com.reactnativenavigation.parse.Options;
5 5
 
6 6
 public interface NavigationOptionsListener {
7
-	void mergeNavigationOptions(NavigationOptions options);
7
+	void mergeNavigationOptions(Options options);
8 8
 }

+ 6
- 6
lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java Wyświetl plik

@@ -1,7 +1,7 @@
1 1
 package com.reactnativenavigation.presentation;
2 2
 
3 3
 import com.reactnativenavigation.parse.Button;
4
-import com.reactnativenavigation.parse.NavigationOptions;
4
+import com.reactnativenavigation.parse.Options;
5 5
 import com.reactnativenavigation.parse.TopBarOptions;
6 6
 import com.reactnativenavigation.parse.TopTabOptions;
7 7
 import com.reactnativenavigation.parse.TopTabsOptions;
@@ -10,8 +10,8 @@ import com.reactnativenavigation.views.TopBar;
10 10
 
11 11
 import java.util.ArrayList;
12 12
 
13
-import static com.reactnativenavigation.parse.NavigationOptions.BooleanOptions.False;
14
-import static com.reactnativenavigation.parse.NavigationOptions.BooleanOptions.True;
13
+import static com.reactnativenavigation.parse.Options.BooleanOptions.False;
14
+import static com.reactnativenavigation.parse.Options.BooleanOptions.True;
15 15
 
16 16
 public class OptionsPresenter {
17 17
 
@@ -23,7 +23,7 @@ public class OptionsPresenter {
23 23
         this.topBar = reactComponent.getTopBar();
24 24
     }
25 25
 
26
-    public void applyOptions(NavigationOptions options) {
26
+    public void applyOptions(Options options) {
27 27
         applyTopBarOptions(options.topBarOptions);
28 28
         applyButtons(options.topBarOptions.leftButtons, options.topBarOptions.rightButtons);
29 29
         applyTopTabsOptions(options.topTabsOptions);
@@ -37,10 +37,10 @@ public class OptionsPresenter {
37 37
         topBar.setTitleFontSize(options.textFontSize);
38 38
 
39 39
         topBar.setTitleTypeface(options.textFontFamily);
40
-        if (options.hidden == NavigationOptions.BooleanOptions.True) {
40
+        if (options.hidden == Options.BooleanOptions.True) {
41 41
             topBar.hide(options.animateHide);
42 42
         }
43
-        if (options.hidden == NavigationOptions.BooleanOptions.False) {
43
+        if (options.hidden == Options.BooleanOptions.False) {
44 44
             topBar.show(options.animateHide);
45 45
         }
46 46
         if (options.drawBehind == True) {

+ 3
- 3
lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java Wyświetl plik

@@ -13,7 +13,7 @@ import com.reactnativenavigation.parse.JSONParser;
13 13
 import com.reactnativenavigation.parse.LayoutFactory;
14 14
 import com.reactnativenavigation.parse.LayoutNode;
15 15
 import com.reactnativenavigation.parse.LayoutNodeParser;
16
-import com.reactnativenavigation.parse.NavigationOptions;
16
+import com.reactnativenavigation.parse.Options;
17 17
 import com.reactnativenavigation.parse.OverlayOptions;
18 18
 import com.reactnativenavigation.utils.TypefaceLoader;
19 19
 import com.reactnativenavigation.utils.UiThread;
@@ -47,13 +47,13 @@ public class NavigationModule extends ReactContextBaseJavaModule {
47 47
 
48 48
 	@ReactMethod
49 49
 	public void setDefaultOptions(final ReadableMap options) {
50
-        final NavigationOptions defaultOptions = NavigationOptions.parse(new TypefaceLoader(activity()), JSONParser.parse(options));
50
+        final Options defaultOptions = Options.parse(new TypefaceLoader(activity()), JSONParser.parse(options));
51 51
         handle(() -> navigator().setDefaultOptions(defaultOptions));
52 52
     }
53 53
 
54 54
 	@ReactMethod
55 55
 	public void setOptions(final String onComponentId, final ReadableMap options) {
56
-		final NavigationOptions navOptions = NavigationOptions.parse(new TypefaceLoader(activity()), JSONParser.parse(options));
56
+		final Options navOptions = Options.parse(new TypefaceLoader(activity()), JSONParser.parse(options));
57 57
 		handle(() -> navigator().setOptions(onComponentId, navOptions));
58 58
 	}
59 59
 

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/BottomTabsController.java Wyświetl plik

@@ -10,7 +10,7 @@ import android.view.View;
10 10
 import android.view.ViewGroup;
11 11
 import android.widget.RelativeLayout;
12 12
 
13
-import com.reactnativenavigation.parse.NavigationOptions;
13
+import com.reactnativenavigation.parse.Options;
14 14
 import com.reactnativenavigation.presentation.NavigationOptionsListener;
15 15
 import com.reactnativenavigation.utils.CompatUtils;
16 16
 
@@ -98,7 +98,7 @@ public class BottomTabsController extends ParentController
98 98
 	}
99 99
 
100 100
 	@Override
101
-	public void mergeNavigationOptions(NavigationOptions options) {
101
+	public void mergeNavigationOptions(Options options) {
102 102
 		if (options.bottomTabsOptions != null) {
103 103
 			if (options.bottomTabsOptions.currentTabIndex != NO_INT_VALUE) {
104 104
 				selectTabAtIndex(options.bottomTabsOptions.currentTabIndex);

+ 5
- 5
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ComponentViewController.java Wyświetl plik

@@ -33,14 +33,14 @@ public class ComponentViewController extends ViewController implements Navigatio
33 33
     private final String componentName;
34 34
 
35 35
     private final ReactViewCreator viewCreator;
36
-    private NavigationOptions options;
36
+    private Options options;
37 37
     private ReactComponent component;
38 38
 
39 39
     public ComponentViewController(final Activity activity,
40 40
                                    final String id,
41 41
                                    final String componentName,
42 42
                                    final ReactViewCreator viewCreator,
43
-                                   final NavigationOptions initialNavigationOptions) {
43
+                                   final Options initialNavigationOptions) {
44 44
         super(activity, id);
45 45
         this.componentName = componentName;
46 46
         this.viewCreator = viewCreator;
@@ -86,12 +86,12 @@ public class ComponentViewController extends ViewController implements Navigatio
86 86
     }
87 87
 
88 88
     @Override
89
-    public void mergeNavigationOptions(NavigationOptions options) {
89
+    public void mergeNavigationOptions(Options options) {
90 90
         this.options.mergeWith(options);
91
-        component.applyOptions(options);
91
+        component.applyOptions(this.options);
92 92
     }
93 93
 
94
-    NavigationOptions getOptions() {
94
+    Options getOptions() {
95 95
         return options;
96 96
     }
97 97
 

+ 5
- 5
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/Navigator.java Wyświetl plik

@@ -7,7 +7,7 @@ import android.view.ViewGroup;
7 7
 import android.widget.FrameLayout;
8 8
 
9 9
 import com.facebook.react.bridge.Promise;
10
-import com.reactnativenavigation.parse.NavigationOptions;
10
+import com.reactnativenavigation.parse.Options;
11 11
 import com.reactnativenavigation.parse.OverlayOptions;
12 12
 import com.reactnativenavigation.presentation.NavigationOptionsListener;
13 13
 import com.reactnativenavigation.presentation.OverlayPresenter;
@@ -21,7 +21,7 @@ public class Navigator extends ParentController {
21 21
 	private final ModalStack modalStack = new ModalStack();
22 22
 	private ViewController root;
23 23
 	private OverlayPresenter overlayPresenter;
24
-    private NavigationOptions defaultOptions = new NavigationOptions();
24
+    private Options defaultOptions = new Options();
25 25
 
26 26
     public Navigator(final Activity activity) {
27 27
 		super(activity, "navigator" + CompatUtils.generateViewId());
@@ -70,15 +70,15 @@ public class Navigator extends ParentController {
70 70
 		}
71 71
 	}
72 72
 
73
-    public void setDefaultOptions(NavigationOptions defaultOptions) {
73
+    public void setDefaultOptions(Options defaultOptions) {
74 74
         this.defaultOptions = defaultOptions;
75 75
     }
76 76
 
77
-    public NavigationOptions getDefaultOptions() {
77
+    public Options getDefaultOptions() {
78 78
         return defaultOptions;
79 79
     }
80 80
 
81
-	public void setOptions(final String componentId, NavigationOptions options) {
81
+	public void setOptions(final String componentId, Options options) {
82 82
 		ViewController target = findControllerById(componentId);
83 83
 		if (target instanceof NavigationOptionsListener) {
84 84
 			((NavigationOptionsListener) target).mergeNavigationOptions(options);

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ViewController.java Wyświetl plik

@@ -9,7 +9,7 @@ import android.view.ViewGroup;
9 9
 import android.view.ViewManager;
10 10
 import android.view.ViewTreeObserver;
11 11
 
12
-import com.reactnativenavigation.parse.NavigationOptions;
12
+import com.reactnativenavigation.parse.Options;
13 13
 import com.reactnativenavigation.utils.CompatUtils;
14 14
 import com.reactnativenavigation.utils.StringUtils;
15 15
 import com.reactnativenavigation.utils.Task;
@@ -105,7 +105,7 @@ public abstract class ViewController implements ViewTreeObserver.OnGlobalLayoutL
105 105
         isShown = false;
106 106
     }
107 107
 
108
-    public void applyOptions(NavigationOptions options) {
108
+    public void applyOptions(Options options) {
109 109
 
110 110
     }
111 111
 

+ 5
- 5
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabController.java Wyświetl plik

@@ -3,7 +3,7 @@ package com.reactnativenavigation.viewcontrollers.toptabs;
3 3
 import android.app.Activity;
4 4
 import android.view.View;
5 5
 
6
-import com.reactnativenavigation.parse.NavigationOptions;
6
+import com.reactnativenavigation.parse.Options;
7 7
 import com.reactnativenavigation.presentation.NavigationOptionsListener;
8 8
 import com.reactnativenavigation.viewcontrollers.ComponentViewController;
9 9
 import com.reactnativenavigation.viewcontrollers.ViewController;
@@ -13,11 +13,11 @@ public class TopTabController extends ViewController implements NavigationOption
13 13
 
14 14
     private final String componentName;
15 15
     private ComponentViewController.ReactViewCreator viewCreator;
16
-    private final NavigationOptions options;
16
+    private final Options options;
17 17
     private TopTab topTab;
18 18
     private boolean isSelectedTab;
19 19
 
20
-    public TopTabController(Activity activity, String id, String name, ComponentViewController.ReactViewCreator viewCreator, NavigationOptions initialOptions) {
20
+    public TopTabController(Activity activity, String id, String name, ComponentViewController.ReactViewCreator viewCreator, Options initialOptions) {
21 21
         super(activity, id);
22 22
         this.componentName = name;
23 23
         this.viewCreator = viewCreator;
@@ -33,7 +33,7 @@ public class TopTabController extends ViewController implements NavigationOption
33 33
     }
34 34
 
35 35
     @Override
36
-    public void applyOptions(NavigationOptions options) {
36
+    public void applyOptions(Options options) {
37 37
         getParentController().applyOptions(options);
38 38
     }
39 39
 
@@ -66,7 +66,7 @@ public class TopTabController extends ViewController implements NavigationOption
66 66
     }
67 67
 
68 68
     @Override
69
-    public void mergeNavigationOptions(NavigationOptions options) {
69
+    public void mergeNavigationOptions(Options options) {
70 70
         this.options.mergeWith(options);
71 71
         applyOptions(this.options);
72 72
     }

+ 5
- 5
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsController.java Wyświetl plik

@@ -4,7 +4,7 @@ import android.app.Activity;
4 4
 import android.support.annotation.NonNull;
5 5
 import android.view.ViewGroup;
6 6
 
7
-import com.reactnativenavigation.parse.NavigationOptions;
7
+import com.reactnativenavigation.parse.Options;
8 8
 import com.reactnativenavigation.presentation.NavigationOptionsListener;
9 9
 import com.reactnativenavigation.utils.Task;
10 10
 import com.reactnativenavigation.viewcontrollers.ParentController;
@@ -20,9 +20,9 @@ public class TopTabsController extends ParentController implements NavigationOpt
20 20
     private List<TopTabController> tabs;
21 21
     private TopTabsLayout topTabsLayout;
22 22
     private TopTabsLayoutCreator viewCreator;
23
-    private NavigationOptions options;
23
+    private Options options;
24 24
 
25
-    public TopTabsController(Activity activity, String id, List<TopTabController> tabs, TopTabsLayoutCreator viewCreator, NavigationOptions options) {
25
+    public TopTabsController(Activity activity, String id, List<TopTabController> tabs, TopTabsLayoutCreator viewCreator, Options options) {
26 26
         super(activity, id);
27 27
         this.viewCreator = viewCreator;
28 28
         this.options = options;
@@ -57,12 +57,12 @@ public class TopTabsController extends ParentController implements NavigationOpt
57 57
     }
58 58
 
59 59
     @Override
60
-    public void applyOptions(NavigationOptions options) {
60
+    public void applyOptions(Options options) {
61 61
         topTabsLayout.applyOptions(options);
62 62
     }
63 63
 
64 64
     @Override
65
-    public void mergeNavigationOptions(NavigationOptions options) {
65
+    public void mergeNavigationOptions(Options options) {
66 66
 
67 67
     }
68 68
 

+ 2
- 4
lib/android/app/src/main/java/com/reactnativenavigation/views/Component.java Wyświetl plik

@@ -1,13 +1,11 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3
-import android.support.annotation.RestrictTo;
4 3
 import android.view.View;
5 4
 
6
-import com.reactnativenavigation.parse.NavigationOptions;
7
-import com.reactnativenavigation.viewcontrollers.ComponentViewController;
5
+import com.reactnativenavigation.parse.Options;
8 6
 
9 7
 public interface Component {
10
-    void applyOptions(NavigationOptions options);
8
+    void applyOptions(Options options);
11 9
 
12 10
     void sendOnNavigationButtonPressed(String id);
13 11
 

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/views/ComponentLayout.java Wyświetl plik

@@ -21,8 +21,8 @@ public class ComponentLayout extends RelativeLayout implements ReactComponent {
21 21
 
22 22
 	public ComponentLayout(Context context, IReactView reactView, EventDispatcher eventDispatcher) {
23 23
 		super(context);
24
-		this.topBar = new TopBar(context, this, eventDispatcher);
25 24
 		this.reactView = reactView;
25
+		this.topBar = new TopBar(context, this, eventDispatcher);
26 26
         optionsPresenter = new OptionsPresenter(this);
27 27
         initViews();
28 28
     }
@@ -60,7 +60,7 @@ public class ComponentLayout extends RelativeLayout implements ReactComponent {
60 60
 	}
61 61
 
62 62
     @Override
63
-    public void applyOptions(NavigationOptions options) {
63
+    public void applyOptions(Options options) {
64 64
         optionsPresenter.applyOptions(options);
65 65
     }
66 66
 

+ 4
- 4
lib/android/app/src/main/java/com/reactnativenavigation/views/TitleBarButton.java Wyświetl plik

@@ -15,7 +15,7 @@ import android.view.View;
15 15
 import android.widget.TextView;
16 16
 
17 17
 import com.reactnativenavigation.parse.Button;
18
-import com.reactnativenavigation.parse.NavigationOptions;
18
+import com.reactnativenavigation.parse.Options;
19 19
 import com.reactnativenavigation.utils.ImageUtils;
20 20
 import com.reactnativenavigation.utils.UiUtils;
21 21
 
@@ -36,7 +36,7 @@ public class TitleBarButton implements MenuItem.OnMenuItemClickListener {
36 36
 	void addToMenu(Context context, final Menu menu) {
37 37
 		MenuItem menuItem = menu.add(button.title);
38 38
 		menuItem.setShowAsAction(button.showAsAction);
39
-		menuItem.setEnabled(button.disabled != NavigationOptions.BooleanOptions.True);
39
+		menuItem.setEnabled(button.disabled != Options.BooleanOptions.True);
40 40
 		menuItem.setOnMenuItemClickListener(this);
41 41
 
42 42
 		if (hasIcon()) {
@@ -92,12 +92,12 @@ public class TitleBarButton implements MenuItem.OnMenuItemClickListener {
92 92
 	}
93 93
 
94 94
 	private void setIconColor() {
95
-		if (button.disabled == NavigationOptions.BooleanOptions.False || button.disabled == NavigationOptions.BooleanOptions.NoValue) {
95
+		if (button.disabled == Options.BooleanOptions.False || button.disabled == Options.BooleanOptions.NoValue) {
96 96
 			UiUtils.tintDrawable(icon, button.buttonColor);
97 97
 			return;
98 98
 		}
99 99
 
100
-		if (button.disableIconTint == NavigationOptions.BooleanOptions.True) {
100
+		if (button.disableIconTint == Options.BooleanOptions.True) {
101 101
 			UiUtils.tintDrawable(icon, button.buttonColor);
102 102
 		} else {
103 103
 			UiUtils.tintDrawable(icon, Color.LTGRAY);

+ 4
- 4
lib/android/app/src/main/java/com/reactnativenavigation/views/TopBar.java Wyświetl plik

@@ -160,22 +160,22 @@ public class TopBar extends AppBarLayout {
160 160
         collapsingBehavior.disableCollapse();
161 161
     }
162 162
 
163
-    public void show(NavigationOptions.BooleanOptions animated) {
163
+    public void show(Options.BooleanOptions animated) {
164 164
         if (getVisibility() == View.VISIBLE) {
165 165
             return;
166 166
         }
167
-        if (animated == NavigationOptions.BooleanOptions.True) {
167
+        if (animated == Options.BooleanOptions.True) {
168 168
             animator.show();
169 169
         } else {
170 170
             setVisibility(View.VISIBLE);
171 171
         }
172 172
     }
173 173
 
174
-    public void hide(NavigationOptions.BooleanOptions animated) {
174
+    public void hide(Options.BooleanOptions animated) {
175 175
         if (getVisibility() == View.GONE) {
176 176
             return;
177 177
         }
178
-        if (animated == NavigationOptions.BooleanOptions.True) {
178
+        if (animated == Options.BooleanOptions.True) {
179 179
             animator.hide();
180 180
         } else {
181 181
             setVisibility(View.GONE);

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/views/TopTabsLayout.java Wyświetl plik

@@ -41,7 +41,7 @@ public class TopTabsLayout extends RelativeLayout implements Component {
41 41
     }
42 42
 
43 43
     @Override
44
-    public void applyOptions(NavigationOptions options) {
44
+    public void applyOptions(Options options) {
45 45
         optionsPresenter.applyOptions(options);
46 46
     }
47 47
 

+ 27
- 27
lib/android/app/src/test/java/com/reactnativenavigation/BaseTest.java Wyświetl plik

@@ -14,31 +14,31 @@ import static org.assertj.core.api.Java6Assertions.*;
14 14
 @RunWith(RobolectricTestRunner.class)
15 15
 @Config(sdk = 27, application = TestApplication.class)
16 16
 public abstract class BaseTest {
17
-	@Before
18
-	public void beforeEach() {
19
-		//
20
-	}
21
-
22
-	@After
23
-	public void afterEach() {
24
-		//
25
-	}
26
-
27
-	public Activity newActivity() {
28
-		return Robolectric.setupActivity(AppCompatActivity.class);
29
-	}
30
-
31
-	public void assertIsChildById(ViewGroup parent, View child) {
32
-		assertThat(parent).isNotNull();
33
-		assertThat(child).isNotNull();
34
-		assertThat(child.getId()).isNotZero().isPositive();
35
-		assertThat(parent.findViewById(child.getId())).isNotNull().isEqualTo(child);
36
-	}
37
-
38
-	public void assertNotChildOf(ViewGroup parent, View child) {
39
-		assertThat(parent).isNotNull();
40
-		assertThat(child).isNotNull();
41
-		assertThat(child.getId()).isNotZero().isPositive();
42
-		assertThat(parent.findViewById(child.getId())).isNull();
43
-	}
17
+    @Before
18
+    public void beforeEach() {
19
+        //
20
+    }
21
+
22
+    @After
23
+    public void afterEach() {
24
+        //
25
+    }
26
+
27
+    public Activity newActivity() {
28
+        return Robolectric.setupActivity(AppCompatActivity.class);
29
+    }
30
+
31
+    public void assertIsChildById(ViewGroup parent, View child) {
32
+        assertThat(parent).isNotNull();
33
+        assertThat(child).isNotNull();
34
+        assertThat(child.getId()).isNotZero().isPositive();
35
+        assertThat(parent.findViewById(child.getId())).isNotNull().isEqualTo(child);
36
+    }
37
+
38
+    public void assertNotChildOf(ViewGroup parent, View child) {
39
+        assertThat(parent).isNotNull();
40
+        assertThat(child).isNotNull();
41
+        assertThat(child.getId()).isNotZero().isPositive();
42
+        assertThat(parent.findViewById(child.getId())).isNull();
43
+    }
44 44
 }

+ 35
- 35
lib/android/app/src/test/java/com/reactnativenavigation/EnvironmentTest.java Wyświetl plik

@@ -1,43 +1,43 @@
1 1
 package com.reactnativenavigation;
2 2
 
3
-import android.support.design.widget.FloatingActionButton;
4
-import android.support.v7.app.AppCompatActivity;
3
+import android.support.design.widget.*;
4
+import android.support.v7.app.*;
5 5
 
6
-import com.facebook.react.common.ReactConstants;
6
+import com.facebook.react.common.*;
7 7
 
8
-import org.junit.Test;
9
-import org.robolectric.RuntimeEnvironment;
8
+import org.junit.*;
9
+import org.robolectric.*;
10 10
 
11
-import static org.assertj.core.api.Java6Assertions.assertThat;
11
+import static org.assertj.core.api.Java6Assertions.*;
12 12
 
13 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
-	}
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 43
 }

+ 5
- 5
lib/android/app/src/test/java/com/reactnativenavigation/TestApplication.java Wyświetl plik

@@ -3,9 +3,9 @@ package com.reactnativenavigation;
3 3
 import android.app.*;
4 4
 
5 5
 public class TestApplication extends Application {
6
-	@Override
7
-	public void onCreate() {
8
-		super.onCreate();
9
-		setTheme(R.style.Theme_AppCompat);
10
-	}
6
+    @Override
7
+    public void onCreate() {
8
+        super.onCreate();
9
+        setTheme(R.style.Theme_AppCompat);
10
+    }
11 11
 }

+ 64
- 67
lib/android/app/src/test/java/com/reactnativenavigation/anim/ViewAnimationSetBuilderTest.java Wyświetl plik

@@ -1,84 +1,81 @@
1 1
 package com.reactnativenavigation.anim;
2 2
 
3
-import android.view.View;
4
-import android.view.animation.AlphaAnimation;
5
-import android.view.animation.Animation;
3
+import android.view.*;
4
+import android.view.animation.*;
6 5
 
7
-import com.reactnativenavigation.BaseTest;
6
+import com.reactnativenavigation.*;
8 7
 
9
-import org.junit.Test;
10
-import org.robolectric.shadow.api.Shadow;
8
+import org.junit.*;
9
+import org.robolectric.shadow.api.*;
11 10
 
12
-import static org.assertj.core.api.Java6Assertions.assertThat;
13
-import static org.mockito.Mockito.mock;
14
-import static org.mockito.Mockito.times;
15
-import static org.mockito.Mockito.verify;
11
+import static org.assertj.core.api.Java6Assertions.*;
12
+import static org.mockito.Mockito.*;
16 13
 
17 14
 public class ViewAnimationSetBuilderTest extends BaseTest {
18 15
 
19
-	private Runnable mockListener;
16
+    private Runnable mockListener;
20 17
 
21
-	@Override
22
-	public void beforeEach() {
23
-		super.beforeEach();
24
-		mockListener = mock(Runnable.class);
25
-	}
18
+    @Override
19
+    public void beforeEach() {
20
+        super.beforeEach();
21
+        mockListener = mock(Runnable.class);
22
+    }
26 23
 
27
-	@Test
28
-	public void implementsViewAnimationListener() throws Exception {
29
-		assertThat(new ViewAnimationSetBuilder()).isInstanceOf(Animation.AnimationListener.class);
30
-	}
24
+    @Test
25
+    public void implementsViewAnimationListener() throws Exception {
26
+        assertThat(new ViewAnimationSetBuilder()).isInstanceOf(Animation.AnimationListener.class);
27
+    }
31 28
 
32
-	@Test
33
-	public void optionalCompletionListener() throws Exception {
34
-		new ViewAnimationSetBuilder()
35
-				.add(someView(), someAnimation())
36
-				.start();
37
-		verify(mockListener, times(0)).run();
38
-	}
29
+    @Test
30
+    public void optionalCompletionListener() throws Exception {
31
+        new ViewAnimationSetBuilder()
32
+                .add(someView(), someAnimation())
33
+                .start();
34
+        verify(mockListener, times(0)).run();
35
+    }
39 36
 
40
-	@Test
41
-	public void startsAllAnimations() throws Exception {
42
-		Animation anim1 = someAnimation();
43
-		Animation anim2 = someAnimation();
44
-		new ViewAnimationSetBuilder()
45
-				.withEndListener(mockListener)
46
-				.add(someView(), anim1)
47
-				.add(someView(), anim2)
48
-				.start();
49
-		assertThat(anim1.hasStarted()).isTrue();
50
-		assertThat(anim2.hasStarted()).isTrue();
51
-	}
37
+    @Test
38
+    public void startsAllAnimations() throws Exception {
39
+        Animation anim1 = someAnimation();
40
+        Animation anim2 = someAnimation();
41
+        new ViewAnimationSetBuilder()
42
+                .withEndListener(mockListener)
43
+                .add(someView(), anim1)
44
+                .add(someView(), anim2)
45
+                .start();
46
+        assertThat(anim1.hasStarted()).isTrue();
47
+        assertThat(anim2.hasStarted()).isTrue();
48
+    }
52 49
 
53
-	@Test
54
-	public void callsEndListenerOnlyAfterAllAnimationsFinish() throws Exception {
55
-		Animation anim1 = someAnimation();
56
-		Animation anim2 = someAnimation();
57
-		ViewAnimationSetBuilder uut = new ViewAnimationSetBuilder();
58
-		uut.withEndListener(mockListener)
59
-				.add(someView(), anim1)
60
-				.add(someView(), anim2)
61
-				.start();
62
-		verify(mockListener, times(1)).run();
63
-	}
50
+    @Test
51
+    public void callsEndListenerOnlyAfterAllAnimationsFinish() throws Exception {
52
+        Animation anim1 = someAnimation();
53
+        Animation anim2 = someAnimation();
54
+        ViewAnimationSetBuilder uut = new ViewAnimationSetBuilder();
55
+        uut.withEndListener(mockListener)
56
+           .add(someView(), anim1)
57
+           .add(someView(), anim2)
58
+           .start();
59
+        verify(mockListener, times(1)).run();
60
+    }
64 61
 
65
-	@Test
66
-	public void clearsAnimationFromViewsAfterFinished() throws Exception {
67
-		View v1 = someView();
68
-		View v2 = someView();
69
-		new ViewAnimationSetBuilder()
70
-				.withEndListener(mockListener)
71
-				.add(v1, someAnimation())
72
-				.start();
73
-		assertThat(v1.getAnimation()).isNull();
74
-		assertThat(v2.getAnimation()).isNull();
75
-	}
62
+    @Test
63
+    public void clearsAnimationFromViewsAfterFinished() throws Exception {
64
+        View v1 = someView();
65
+        View v2 = someView();
66
+        new ViewAnimationSetBuilder()
67
+                .withEndListener(mockListener)
68
+                .add(v1, someAnimation())
69
+                .start();
70
+        assertThat(v1.getAnimation()).isNull();
71
+        assertThat(v2.getAnimation()).isNull();
72
+    }
76 73
 
77
-	private Animation someAnimation() {
78
-		return Shadow.newInstanceOf(AlphaAnimation.class);
79
-	}
74
+    private Animation someAnimation() {
75
+        return Shadow.newInstanceOf(AlphaAnimation.class);
76
+    }
80 77
 
81
-	private View someView() {
82
-		return Shadow.newInstanceOf(View.class);
83
-	}
78
+    private View someView() {
79
+        return Shadow.newInstanceOf(View.class);
80
+    }
84 81
 }

+ 20
- 20
lib/android/app/src/test/java/com/reactnativenavigation/mocks/MockPromise.java Wyświetl plik

@@ -1,39 +1,39 @@
1 1
 package com.reactnativenavigation.mocks;
2 2
 
3
-import com.facebook.react.bridge.Promise;
3
+import com.facebook.react.bridge.*;
4 4
 
5
-import javax.annotation.Nullable;
5
+import javax.annotation.*;
6 6
 
7 7
 
8 8
 public class MockPromise implements Promise {
9 9
 
10
-	@Override
11
-	public void resolve(@Nullable Object value) {
10
+    @Override
11
+    public void resolve(@Nullable Object value) {
12 12
 
13
-	}
13
+    }
14 14
 
15
-	@Override
16
-	public void reject(String code, String message) {
15
+    @Override
16
+    public void reject(String code, String message) {
17 17
 
18
-	}
18
+    }
19 19
 
20
-	@Override
21
-	public void reject(String code, Throwable e) {
20
+    @Override
21
+    public void reject(String code, Throwable e) {
22 22
 
23
-	}
23
+    }
24 24
 
25
-	@Override
26
-	public void reject(String code, String message, Throwable e) {
25
+    @Override
26
+    public void reject(String code, String message, Throwable e) {
27 27
 
28
-	}
28
+    }
29 29
 
30
-	@Override
31
-	public void reject(String message) {
30
+    @Override
31
+    public void reject(String message) {
32 32
 
33
-	}
33
+    }
34 34
 
35
-	@Override
36
-	public void reject(Throwable reason) {
35
+    @Override
36
+    public void reject(Throwable reason) {
37 37
 
38
-	}
38
+    }
39 39
 }

+ 6
- 6
lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleComponentViewController.java Wyświetl plik

@@ -1,12 +1,12 @@
1 1
 package com.reactnativenavigation.mocks;
2 2
 
3
-import android.app.Activity;
3
+import android.app.*;
4 4
 
5
-import com.reactnativenavigation.parse.NavigationOptions;
6
-import com.reactnativenavigation.viewcontrollers.ComponentViewController;
5
+import com.reactnativenavigation.parse.*;
6
+import com.reactnativenavigation.viewcontrollers.*;
7 7
 
8 8
 public class SimpleComponentViewController extends ComponentViewController {
9
-	public SimpleComponentViewController(final Activity activity, final String id) {
10
-		super(activity, id, "theComponentName", new TestComponentViewCreator(), new NavigationOptions());
11
-	}
9
+    public SimpleComponentViewController(final Activity activity, final String id) {
10
+        super(activity, id, "theComponentName", new TestComponentViewCreator(), new Options());
11
+    }
12 12
 }

+ 14
- 14
lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleViewController.java Wyświetl plik

@@ -1,23 +1,23 @@
1 1
 package com.reactnativenavigation.mocks;
2 2
 
3
-import android.app.Activity;
4
-import android.view.View;
3
+import android.app.*;
4
+import android.view.*;
5 5
 
6
-import com.reactnativenavigation.viewcontrollers.ViewController;
6
+import com.reactnativenavigation.viewcontrollers.*;
7 7
 
8 8
 public class SimpleViewController extends ViewController {
9 9
 
10
-	public SimpleViewController(final Activity activity, String id) {
11
-		super(activity, id);
12
-	}
10
+    public SimpleViewController(final Activity activity, String id) {
11
+        super(activity, id);
12
+    }
13 13
 
14
-	@Override
15
-	protected View createView() {
16
-		return new View(getActivity());
17
-	}
14
+    @Override
15
+    protected View createView() {
16
+        return new View(getActivity());
17
+    }
18 18
 
19
-	@Override
20
-	public String toString() {
21
-		return "SimpleViewController " + getId();
22
-	}
19
+    @Override
20
+    public String toString() {
21
+        return "SimpleViewController " + getId();
22
+    }
23 23
 }

+ 8
- 10
lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentLayout.java Wyświetl plik

@@ -1,14 +1,12 @@
1 1
 package com.reactnativenavigation.mocks;
2 2
 
3
-import android.content.Context;
4
-import android.view.View;
5
-import android.view.ViewGroup;
6
-import android.widget.RelativeLayout;
3
+import android.content.*;
4
+import android.view.*;
5
+import android.widget.*;
7 6
 
8
-import com.reactnativenavigation.parse.NavigationOptions;
9
-import com.reactnativenavigation.presentation.OptionsPresenter;
10
-import com.reactnativenavigation.views.ReactComponent;
11
-import com.reactnativenavigation.views.TopBar;
7
+import com.reactnativenavigation.parse.*;
8
+import com.reactnativenavigation.presentation.*;
9
+import com.reactnativenavigation.views.*;
12 10
 
13 11
 public class TestComponentLayout extends RelativeLayout implements ReactComponent {
14 12
 
@@ -17,7 +15,7 @@ public class TestComponentLayout extends RelativeLayout implements ReactComponen
17 15
     private final OptionsPresenter optionsPresenter;
18 16
 
19 17
     public TestComponentLayout(final Context context) {
20
-		super(context);
18
+        super(context);
21 19
         topBar = new TopBar(context, this, null);
22 20
         contentView = new View(context);
23 21
         addView(topBar);
@@ -71,7 +69,7 @@ public class TestComponentLayout extends RelativeLayout implements ReactComponen
71 69
     }
72 70
 
73 71
     @Override
74
-    public void applyOptions(NavigationOptions options) {
72
+    public void applyOptions(Options options) {
75 73
         optionsPresenter.applyOptions(options);
76 74
     }
77 75
 

+ 15
- 16
lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentView.java Wyświetl plik

@@ -1,21 +1,20 @@
1 1
 package com.reactnativenavigation.mocks;
2 2
 
3
-import android.content.Context;
4
-import android.view.View;
3
+import android.content.*;
4
+import android.view.*;
5 5
 
6
-import com.reactnativenavigation.parse.NavigationOptions;
7
-import com.reactnativenavigation.views.ReactComponent;
8
-import com.reactnativenavigation.views.TopBar;
6
+import com.reactnativenavigation.parse.*;
7
+import com.reactnativenavigation.views.*;
9 8
 
10 9
 public class TestComponentView extends View implements ReactComponent {
11 10
 
12 11
     private TopBar topBar;
13 12
 
14
-	public TestComponentView(final Context context) {
15
-		super(context);
16
-		topBar = new TopBar(context, this, null);
13
+    public TestComponentView(final Context context) {
14
+        super(context);
15
+        topBar = new TopBar(context, this, null);
17 16
 
18
-	}
17
+    }
19 18
 
20 19
     @Override
21 20
     public boolean isReady() {
@@ -31,16 +30,16 @@ public class TestComponentView extends View implements ReactComponent {
31 30
     public void destroy() {
32 31
     }
33 32
 
34
-	@Override
35
-	public void sendComponentStart() {
36
-	}
33
+    @Override
34
+    public void sendComponentStart() {
35
+    }
37 36
 
38
-	@Override
39
-	public void sendComponentStop() {
40
-	}
37
+    @Override
38
+    public void sendComponentStop() {
39
+    }
41 40
 
42 41
     @Override
43
-    public void applyOptions(NavigationOptions options) {
42
+    public void applyOptions(Options options) {
44 43
 
45 44
     }
46 45
 

+ 7
- 7
lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentViewCreator.java Wyświetl plik

@@ -1,13 +1,13 @@
1 1
 package com.reactnativenavigation.mocks;
2 2
 
3
-import android.app.Activity;
3
+import android.app.*;
4 4
 
5
-import com.reactnativenavigation.viewcontrollers.ComponentViewController;
6
-import com.reactnativenavigation.viewcontrollers.ComponentViewController.ReactViewCreator;
5
+import com.reactnativenavigation.viewcontrollers.*;
6
+import com.reactnativenavigation.viewcontrollers.ComponentViewController.*;
7 7
 
8 8
 public class TestComponentViewCreator implements ReactViewCreator {
9
-	@Override
10
-	public ComponentViewController.IReactView create(final Activity activity, final String componentId, final String componentName) {
11
-		return new TestComponentLayout(activity);
12
-	}
9
+    @Override
10
+    public ComponentViewController.IReactView create(final Activity activity, final String componentId, final String componentName) {
11
+        return new TestComponentLayout(activity);
12
+    }
13 13
 }

+ 14
- 14
lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestNavigationAnimator.java Wyświetl plik

@@ -1,24 +1,24 @@
1 1
 package com.reactnativenavigation.mocks;
2 2
 
3
-import android.view.View;
3
+import android.view.*;
4 4
 
5
-import com.reactnativenavigation.anim.NavigationAnimator;
5
+import com.reactnativenavigation.anim.*;
6 6
 
7
-import org.robolectric.RuntimeEnvironment;
7
+import org.robolectric.*;
8 8
 
9 9
 public class TestNavigationAnimator extends NavigationAnimator {
10 10
 
11
-	public TestNavigationAnimator() {
12
-		super(RuntimeEnvironment.application);
13
-	}
11
+    public TestNavigationAnimator() {
12
+        super(RuntimeEnvironment.application);
13
+    }
14 14
 
15
-	@Override
16
-	public void animatePush(final View enteringView, NavigationAnimationListener animationListener) {
17
-		if (animationListener != null) animationListener.onAnimationEnd();
18
-	}
15
+    @Override
16
+    public void animatePush(final View enteringView, NavigationAnimationListener animationListener) {
17
+        if (animationListener != null) animationListener.onAnimationEnd();
18
+    }
19 19
 
20
-	@Override
21
-	public void animatePop(final View enteringView, NavigationAnimationListener animationListener) {
22
-		if (animationListener != null) animationListener.onAnimationEnd();
23
-	}
20
+    @Override
21
+    public void animatePop(final View enteringView, NavigationAnimationListener animationListener) {
22
+        if (animationListener != null) animationListener.onAnimationEnd();
23
+    }
24 24
 }

+ 3
- 3
lib/android/app/src/test/java/com/reactnativenavigation/mocks/TopTabLayoutMock.java Wyświetl plik

@@ -1,9 +1,9 @@
1 1
 package com.reactnativenavigation.mocks;
2 2
 
3
-import android.content.Context;
4
-import android.view.View;
3
+import android.content.*;
4
+import android.view.*;
5 5
 
6
-import com.reactnativenavigation.viewcontrollers.ComponentViewController;
6
+import com.reactnativenavigation.viewcontrollers.*;
7 7
 
8 8
 public class TopTabLayoutMock extends View implements ComponentViewController.IReactView {
9 9
 

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/mocks/TypefaceLoaderMock.java Wyświetl plik

@@ -1,6 +1,6 @@
1 1
 package com.reactnativenavigation.mocks;
2 2
 
3
-import com.reactnativenavigation.utils.TypefaceLoader;
3
+import com.reactnativenavigation.utils.*;
4 4
 
5 5
 public class TypefaceLoaderMock extends TypefaceLoader {
6 6
 

+ 55
- 58
lib/android/app/src/test/java/com/reactnativenavigation/parse/JSONParserTest.java Wyświetl plik

@@ -1,65 +1,62 @@
1 1
 package com.reactnativenavigation.parse;
2 2
 
3
-import com.facebook.react.bridge.JavaOnlyArray;
4
-import com.facebook.react.bridge.JavaOnlyMap;
5
-import com.reactnativenavigation.BaseTest;
6
-import com.reactnativenavigation.parse.JSONParser;
3
+import com.facebook.react.bridge.*;
4
+import com.reactnativenavigation.*;
7 5
 
8
-import org.json.JSONArray;
9
-import org.json.JSONObject;
10
-import org.junit.Test;
6
+import org.json.*;
7
+import org.junit.*;
11 8
 
12
-import static org.assertj.core.api.Java6Assertions.assertThat;
9
+import static org.assertj.core.api.Java6Assertions.*;
13 10
 
14 11
 public class JSONParserTest extends BaseTest {
15
-	@Test
16
-	public void parsesMap() throws Exception {
17
-		JavaOnlyMap input = new JavaOnlyMap();
18
-		input.putString("keyString", "stringValue");
19
-		input.putInt("keyInt", 123);
20
-		input.putDouble("keyDouble", 123.456);
21
-		input.putBoolean("keyBoolean", true);
22
-		input.putArray("keyArray", new JavaOnlyArray());
23
-		input.putMap("keyMap", new JavaOnlyMap());
24
-		input.putNull("bla");
25
-
26
-		JSONObject result = JSONParser.parse(input);
27
-
28
-
29
-		assertThat(result.keys()).containsOnly(
30
-				"keyString",
31
-				"keyInt",
32
-				"keyDouble",
33
-				"keyBoolean",
34
-				"keyMap",
35
-				"keyArray");
36
-
37
-		assertThat(result.get("keyString")).isEqualTo("stringValue");
38
-		assertThat(result.get("keyInt")).isEqualTo(123);
39
-		assertThat(result.get("keyDouble")).isEqualTo(123.456);
40
-		assertThat(result.get("keyBoolean")).isEqualTo(true);
41
-		assertThat(result.getJSONObject("keyMap").keys()).isEmpty();
42
-		assertThat(result.getJSONArray("keyArray").length()).isZero();
43
-	}
44
-
45
-	@Test
46
-	public void parsesArrays() throws Exception {
47
-		JavaOnlyArray input = new JavaOnlyArray();
48
-		input.pushString("Hello");
49
-		input.pushInt(123);
50
-		input.pushDouble(123.456);
51
-		input.pushBoolean(true);
52
-		input.pushArray(new JavaOnlyArray());
53
-		input.pushMap(new JavaOnlyMap());
54
-		input.pushNull();
55
-
56
-		JSONArray result = JSONParser.parse(input);
57
-		assertThat(result.length()).isEqualTo(6);
58
-		assertThat(result.get(0)).isEqualTo("Hello");
59
-		assertThat(result.get(1)).isEqualTo(123);
60
-		assertThat(result.get(2)).isEqualTo(123.456);
61
-		assertThat(result.get(3)).isEqualTo(true);
62
-		assertThat(result.getJSONArray(4).length()).isZero();
63
-		assertThat(result.getJSONObject(5).keys()).isEmpty();
64
-	}
12
+    @Test
13
+    public void parsesMap() throws Exception {
14
+        JavaOnlyMap input = new JavaOnlyMap();
15
+        input.putString("keyString", "stringValue");
16
+        input.putInt("keyInt", 123);
17
+        input.putDouble("keyDouble", 123.456);
18
+        input.putBoolean("keyBoolean", true);
19
+        input.putArray("keyArray", new JavaOnlyArray());
20
+        input.putMap("keyMap", new JavaOnlyMap());
21
+        input.putNull("bla");
22
+
23
+        JSONObject result = JSONParser.parse(input);
24
+
25
+
26
+        assertThat(result.keys()).containsOnly(
27
+                "keyString",
28
+                "keyInt",
29
+                "keyDouble",
30
+                "keyBoolean",
31
+                "keyMap",
32
+                "keyArray");
33
+
34
+        assertThat(result.get("keyString")).isEqualTo("stringValue");
35
+        assertThat(result.get("keyInt")).isEqualTo(123);
36
+        assertThat(result.get("keyDouble")).isEqualTo(123.456);
37
+        assertThat(result.get("keyBoolean")).isEqualTo(true);
38
+        assertThat(result.getJSONObject("keyMap").keys()).isEmpty();
39
+        assertThat(result.getJSONArray("keyArray").length()).isZero();
40
+    }
41
+
42
+    @Test
43
+    public void parsesArrays() throws Exception {
44
+        JavaOnlyArray input = new JavaOnlyArray();
45
+        input.pushString("Hello");
46
+        input.pushInt(123);
47
+        input.pushDouble(123.456);
48
+        input.pushBoolean(true);
49
+        input.pushArray(new JavaOnlyArray());
50
+        input.pushMap(new JavaOnlyMap());
51
+        input.pushNull();
52
+
53
+        JSONArray result = JSONParser.parse(input);
54
+        assertThat(result.length()).isEqualTo(6);
55
+        assertThat(result.get(0)).isEqualTo("Hello");
56
+        assertThat(result.get(1)).isEqualTo(123);
57
+        assertThat(result.get(2)).isEqualTo(123.456);
58
+        assertThat(result.get(3)).isEqualTo(true);
59
+        assertThat(result.getJSONArray(4).length()).isZero();
60
+        assertThat(result.getJSONObject(5).keys()).isEmpty();
61
+    }
65 62
 }

+ 43
- 43
lib/android/app/src/test/java/com/reactnativenavigation/parse/LayoutNodeParserTest.java Wyświetl plik

@@ -1,50 +1,50 @@
1 1
 package com.reactnativenavigation.parse;
2 2
 
3
-import com.reactnativenavigation.BaseTest;
3
+import com.reactnativenavigation.*;
4 4
 
5
-import org.json.JSONObject;
6
-import org.junit.Test;
5
+import org.json.*;
6
+import org.junit.*;
7 7
 
8
-import static org.assertj.core.api.Java6Assertions.assertThat;
8
+import static org.assertj.core.api.Java6Assertions.*;
9 9
 
10 10
 public class LayoutNodeParserTest extends BaseTest {
11
-	@Test
12
-	public void dto() throws Exception {
13
-		LayoutNode node = new LayoutNode("the id", LayoutNode.Type.Component);
14
-		assertThat(node.id).isEqualTo("the id");
15
-		assertThat(node.type).isEqualTo(LayoutNode.Type.Component);
16
-		assertThat(node.data.keys()).isEmpty();
17
-		assertThat(node.children).isEmpty();
18
-	}
19
-
20
-	@Test
21
-	public void parseType() throws Exception {
22
-		assertThat(LayoutNode.Type.valueOf("Component")).isEqualTo(LayoutNode.Type.Component);
23
-	}
24
-
25
-	@Test(expected = RuntimeException.class)
26
-	public void invalidType() throws Exception {
27
-		LayoutNode.Type.valueOf("some type");
28
-	}
29
-
30
-	@Test
31
-	public void parseFromTree() throws Exception {
32
-		JSONObject tree = new JSONObject("{id: node1, " +
33
-				"type: Stack, " +
34
-				"data: {dataKey: dataValue}, " +
35
-				"children: [{id: childId1, type: Component}]}");
36
-
37
-		LayoutNode result = LayoutNodeParser.parse(tree);
38
-
39
-		assertThat(result).isNotNull();
40
-		assertThat(result.id).isEqualTo("node1");
41
-		assertThat(result.type).isEqualTo(LayoutNode.Type.Stack);
42
-		assertThat(result.data.length()).isEqualTo(1);
43
-		assertThat(result.data.getString("dataKey")).isEqualTo("dataValue");
44
-		assertThat(result.children).hasSize(1);
45
-		assertThat(result.children.get(0).id).isEqualTo("childId1");
46
-		assertThat(result.children.get(0).type).isEqualTo(LayoutNode.Type.Component);
47
-		assertThat(result.children.get(0).data.keys()).isEmpty();
48
-		assertThat(result.children.get(0).children).isEmpty();
49
-	}
11
+    @Test
12
+    public void dto() throws Exception {
13
+        LayoutNode node = new LayoutNode("the id", LayoutNode.Type.Component);
14
+        assertThat(node.id).isEqualTo("the id");
15
+        assertThat(node.type).isEqualTo(LayoutNode.Type.Component);
16
+        assertThat(node.data.keys()).isEmpty();
17
+        assertThat(node.children).isEmpty();
18
+    }
19
+
20
+    @Test
21
+    public void parseType() throws Exception {
22
+        assertThat(LayoutNode.Type.valueOf("Component")).isEqualTo(LayoutNode.Type.Component);
23
+    }
24
+
25
+    @Test(expected = RuntimeException.class)
26
+    public void invalidType() throws Exception {
27
+        LayoutNode.Type.valueOf("some type");
28
+    }
29
+
30
+    @Test
31
+    public void parseFromTree() throws Exception {
32
+        JSONObject tree = new JSONObject("{id: node1, " +
33
+                "type: Stack, " +
34
+                "data: {dataKey: dataValue}, " +
35
+                "children: [{id: childId1, type: Component}]}");
36
+
37
+        LayoutNode result = LayoutNodeParser.parse(tree);
38
+
39
+        assertThat(result).isNotNull();
40
+        assertThat(result.id).isEqualTo("node1");
41
+        assertThat(result.type).isEqualTo(LayoutNode.Type.Stack);
42
+        assertThat(result.data.length()).isEqualTo(1);
43
+        assertThat(result.data.getString("dataKey")).isEqualTo("dataValue");
44
+        assertThat(result.children).hasSize(1);
45
+        assertThat(result.children.get(0).id).isEqualTo("childId1");
46
+        assertThat(result.children.get(0).type).isEqualTo(LayoutNode.Type.Component);
47
+        assertThat(result.children.get(0).data.keys()).isEmpty();
48
+        assertThat(result.children.get(0).children).isEmpty();
49
+    }
50 50
 }

+ 23
- 24
lib/android/app/src/test/java/com/reactnativenavigation/parse/NavigationOptionsTest.java Wyświetl plik

@@ -1,19 +1,18 @@
1 1
 package com.reactnativenavigation.parse;
2 2
 
3
-import android.graphics.Typeface;
4
-import android.support.annotation.NonNull;
3
+import android.graphics.*;
4
+import android.support.annotation.*;
5 5
 
6
-import com.reactnativenavigation.BaseTest;
7
-import com.reactnativenavigation.mocks.TypefaceLoaderMock;
8
-import com.reactnativenavigation.utils.TypefaceLoader;
6
+import com.reactnativenavigation.*;
7
+import com.reactnativenavigation.mocks.*;
8
+import com.reactnativenavigation.utils.*;
9 9
 
10
-import org.json.JSONException;
11
-import org.json.JSONObject;
12
-import org.junit.Test;
13
-import org.mockito.Mockito;
10
+import org.json.*;
11
+import org.junit.*;
12
+import org.mockito.*;
14 13
 
15
-import static com.reactnativenavigation.parse.NavigationOptions.BooleanOptions.True;
16
-import static org.assertj.core.api.Java6Assertions.assertThat;
14
+import static com.reactnativenavigation.parse.Options.BooleanOptions.*;
15
+import static org.assertj.core.api.Java6Assertions.*;
17 16
 
18 17
 public class NavigationOptionsTest extends BaseTest {
19 18
 
@@ -23,11 +22,11 @@ public class NavigationOptionsTest extends BaseTest {
23 22
     private static final int TOP_BAR_FONT_SIZE = 18;
24 23
     private static final String TOP_BAR_FONT_FAMILY = "HelveticaNeue-CondensedBold";
25 24
     private static final Typeface TOP_BAR_TYPEFACE = Typeface.create("HelveticaNeue-CondensedBold", Typeface.BOLD);
26
-    private static final NavigationOptions.BooleanOptions TOP_BAR_HIDDEN = True;
27
-    private static final NavigationOptions.BooleanOptions TOP_BAR_DRAW_BEHIND = True;
28
-    private static final NavigationOptions.BooleanOptions TOP_BAR_HIDE_ON_SCROLL = True;
29
-    private static final NavigationOptions.BooleanOptions BOTTOM_TABS_ANIMATE_HIDE = True;
30
-    private static final NavigationOptions.BooleanOptions BOTTOM_TABS_HIDDEN = True;
25
+    private static final Options.BooleanOptions TOP_BAR_HIDDEN = True;
26
+    private static final Options.BooleanOptions TOP_BAR_DRAW_BEHIND = True;
27
+    private static final Options.BooleanOptions TOP_BAR_HIDE_ON_SCROLL = True;
28
+    private static final Options.BooleanOptions BOTTOM_TABS_ANIMATE_HIDE = True;
29
+    private static final Options.BooleanOptions BOTTOM_TABS_HIDDEN = True;
31 30
     private static final int BOTTOM_TABS_BADGE = 3;
32 31
     private static final String BOTTOM_TABS_CURRENT_TAB_ID = "ComponentId";
33 32
     private static final int BOTTOM_TABS_CURRENT_TAB_INDEX = 1;
@@ -41,7 +40,7 @@ public class NavigationOptionsTest extends BaseTest {
41 40
 
42 41
     @Test
43 42
     public void parsesNullAsDefaultEmptyOptions() throws Exception {
44
-        assertThat(NavigationOptions.parse(mockLoader, null)).isNotNull();
43
+        assertThat(Options.parse(mockLoader, null)).isNotNull();
45 44
     }
46 45
 
47 46
     @Test
@@ -49,11 +48,11 @@ public class NavigationOptionsTest extends BaseTest {
49 48
         JSONObject json = new JSONObject()
50 49
                 .put("topBar", createTopBar())
51 50
                 .put("bottomTabs", createTabBar());
52
-        NavigationOptions result = NavigationOptions.parse(mockLoader, json);
51
+        Options result = Options.parse(mockLoader, json);
53 52
         assertResult(result);
54 53
     }
55 54
 
56
-    private void assertResult(NavigationOptions result) {
55
+    private void assertResult(Options result) {
57 56
         assertThat(result.topBarOptions.title).isEqualTo(TITLE);
58 57
         assertThat(result.topBarOptions.backgroundColor).isEqualTo(TOP_BAR_BACKGROUND_COLOR);
59 58
         assertThat(result.topBarOptions.textColor).isEqualTo(TOP_BAR_TEXT_COLOR);
@@ -118,8 +117,8 @@ public class NavigationOptionsTest extends BaseTest {
118 117
         JSONObject json = new JSONObject();
119 118
         json.put("topBar", createTopBar());
120 119
         json.put("bottomTabs", createTabBar());
121
-        NavigationOptions defaultOptions = NavigationOptions.parse(mockLoader, json);
122
-        NavigationOptions options = new NavigationOptions();
120
+        Options defaultOptions = Options.parse(mockLoader, json);
121
+        Options options = new Options();
123 122
 
124 123
         options.mergeWith(defaultOptions);
125 124
         assertResult(options);
@@ -130,19 +129,19 @@ public class NavigationOptionsTest extends BaseTest {
130 129
         JSONObject defaultJson = new JSONObject()
131 130
                 .put("topBar", createOtherTopBar())
132 131
                 .put("bottomTabs", createOtherTabBar());
133
-        NavigationOptions defaultOptions = NavigationOptions.parse(mockLoader, defaultJson);
132
+        Options defaultOptions = Options.parse(mockLoader, defaultJson);
134 133
 
135 134
         JSONObject json = new JSONObject()
136 135
                 .put("topBar", createTopBar())
137 136
                 .put("bottomTabs", createTabBar());
138
-        NavigationOptions options = NavigationOptions.parse(mockLoader, json);
137
+        Options options = Options.parse(mockLoader, json);
139 138
         options.withDefaultOptions(defaultOptions);
140 139
         assertResult(options);
141 140
     }
142 141
 
143 142
     @Test
144 143
     public void defaultEmptyOptions() throws Exception {
145
-        NavigationOptions uut = new NavigationOptions();
144
+        Options uut = new Options();
146 145
         assertThat(uut.topBarOptions.title).isEmpty();
147 146
     }
148 147
 }

+ 37
- 37
lib/android/app/src/test/java/com/reactnativenavigation/parse/OverlayOptionsTest.java Wyświetl plik

@@ -2,46 +2,46 @@ package com.reactnativenavigation.parse;
2 2
 
3 3
 import android.graphics.Color;
4 4
 
5
-import com.reactnativenavigation.BaseTest;
5
+import com.reactnativenavigation.*;
6 6
 
7
-import org.json.JSONObject;
8
-import org.junit.Test;
7
+import org.json.*;
8
+import org.junit.*;
9 9
 
10
-import static org.assertj.core.api.Java6Assertions.assertThat;
10
+import static org.assertj.core.api.Java6Assertions.*;
11 11
 
12 12
 public class OverlayOptionsTest extends BaseTest {
13 13
 
14
-	@Test
15
-	public void parsesNullAsDefaultEmptyOptions() throws Exception {
16
-		assertThat(OverlayOptions.parse(null)).isNotNull();
17
-	}
18
-
19
-	@Test
20
-	public void parsesJson() throws Exception {
21
-		JSONObject json = new JSONObject();
22
-		json.put("title", "the title");
23
-		json.put("text", "the text");
24
-		JSONObject nestedButton = new JSONObject();
25
-		nestedButton.put("text", "OK");
26
-		nestedButton.put("action", "action");
27
-		json.put("positiveButton", nestedButton);
28
-		json.put("textColor", Color.RED);
29
-		json.put("duration", "short");
30
-		json.put("backgroundColor", Color.RED);
31
-
32
-		OverlayOptions result = OverlayOptions.parse(json);
33
-		assertThat(result.getTitle()).isEqualTo("the title");
34
-		assertThat(result.getText()).isEqualTo("the text");
35
-		assertThat(result.getPositiveButton().getText()).isEqualTo("OK");
36
-		assertThat(result.getPositiveButton().getAction()).isEqualTo("action");
37
-		assertThat(result.getTextColor()).isEqualTo(Color.RED);
38
-		assertThat(result.getDuration()).isEqualTo("short");
39
-		assertThat(result.getBackgroundColor()).isEqualTo(Color.RED);
40
-	}
41
-
42
-	@Test
43
-	public void defaultEmptyOptions() throws Exception {
44
-		OverlayOptions uut = new OverlayOptions();
45
-		assertThat(uut.getTitle()).isEmpty();
46
-	}
14
+    @Test
15
+    public void parsesNullAsDefaultEmptyOptions() throws Exception {
16
+        assertThat(OverlayOptions.parse(null)).isNotNull();
17
+    }
18
+
19
+    @Test
20
+    public void parsesJson() throws Exception {
21
+        JSONObject json = new JSONObject();
22
+        json.put("title", "the title");
23
+        json.put("text", "the text");
24
+        JSONObject nestedButton = new JSONObject();
25
+        nestedButton.put("text", "OK");
26
+        nestedButton.put("action", "action");
27
+        json.put("positiveButton", nestedButton);
28
+        json.put("textColor", Color.RED);
29
+        json.put("duration", "short");
30
+        json.put("backgroundColor", Color.RED);
31
+
32
+        OverlayOptions result = OverlayOptions.parse(json);
33
+        assertThat(result.getTitle()).isEqualTo("the title");
34
+        assertThat(result.getText()).isEqualTo("the text");
35
+        assertThat(result.getPositiveButton().getText()).isEqualTo("OK");
36
+        assertThat(result.getPositiveButton().getAction()).isEqualTo("action");
37
+        assertThat(result.getTextColor()).isEqualTo(Color.RED);
38
+        assertThat(result.getDuration()).isEqualTo("short");
39
+        assertThat(result.getBackgroundColor()).isEqualTo(Color.RED);
40
+    }
41
+
42
+    @Test
43
+    public void defaultEmptyOptions() throws Exception {
44
+        OverlayOptions uut = new OverlayOptions();
45
+        assertThat(uut.getTitle()).isEmpty();
46
+    }
47 47
 }

+ 32
- 33
lib/android/app/src/test/java/com/reactnativenavigation/react/NavigationReactNativeHostTest.java Wyświetl plik

@@ -1,42 +1,41 @@
1 1
 package com.reactnativenavigation.react;
2 2
 
3
-import com.facebook.react.ReactPackage;
4
-import com.facebook.react.shell.MainReactPackage;
5
-import com.reactnativenavigation.BaseTest;
3
+import com.facebook.react.*;
4
+import com.facebook.react.shell.*;
5
+import com.reactnativenavigation.*;
6 6
 
7
-import org.junit.Test;
8
-import org.robolectric.RuntimeEnvironment;
7
+import org.junit.*;
8
+import org.robolectric.*;
9 9
 
10
-import java.util.Arrays;
11
-import java.util.Collections;
10
+import java.util.*;
12 11
 
13
-import static org.assertj.core.api.Java6Assertions.assertThat;
14
-import static org.mockito.Mockito.mock;
12
+import static org.assertj.core.api.Java6Assertions.*;
13
+import static org.mockito.Mockito.*;
15 14
 
16 15
 public class NavigationReactNativeHostTest extends BaseTest {
17 16
 
18
-	@Test
19
-	public void getPackagesDefaults() throws Exception {
20
-		NavigationReactNativeHost uut = new NavigationReactNativeHost(RuntimeEnvironment.application, false, null);
21
-		assertThat(uut.getPackages()).hasSize(2).extracting("class").containsOnly(MainReactPackage.class, NavigationPackage.class);
22
-	}
23
-
24
-	@Test
25
-	public void getPackagesAddsAdditionalPackages() throws Exception {
26
-		ReactPackage myPackage = mock(ReactPackage.class);
27
-		NavigationReactNativeHost uut = new NavigationReactNativeHost(RuntimeEnvironment.application, false, Collections.singletonList(myPackage));
28
-		assertThat(uut.getPackages()).hasSize(3).containsOnlyOnce(myPackage);
29
-	}
30
-
31
-	@Test
32
-	public void getPackages_DoesNotAddDefaultTwice() throws Exception {
33
-		NavigationReactNativeHost uut = new NavigationReactNativeHost(
34
-				RuntimeEnvironment.application,
35
-				false,
36
-				Arrays.<ReactPackage>asList(
37
-						new MainReactPackage(),
38
-						new MainReactPackage(),
39
-						new MainReactPackage()));
40
-		assertThat(uut.getPackages()).hasSize(2).extracting("class").containsOnly(MainReactPackage.class, NavigationPackage.class);
41
-	}
17
+    @Test
18
+    public void getPackagesDefaults() throws Exception {
19
+        NavigationReactNativeHost uut = new NavigationReactNativeHost(RuntimeEnvironment.application, false, null);
20
+        assertThat(uut.getPackages()).hasSize(2).extracting("class").containsOnly(MainReactPackage.class, NavigationPackage.class);
21
+    }
22
+
23
+    @Test
24
+    public void getPackagesAddsAdditionalPackages() throws Exception {
25
+        ReactPackage myPackage = mock(ReactPackage.class);
26
+        NavigationReactNativeHost uut = new NavigationReactNativeHost(RuntimeEnvironment.application, false, Collections.singletonList(myPackage));
27
+        assertThat(uut.getPackages()).hasSize(3).containsOnlyOnce(myPackage);
28
+    }
29
+
30
+    @Test
31
+    public void getPackages_DoesNotAddDefaultTwice() throws Exception {
32
+        NavigationReactNativeHost uut = new NavigationReactNativeHost(
33
+                RuntimeEnvironment.application,
34
+                false,
35
+                Arrays.<ReactPackage>asList(
36
+                        new MainReactPackage(),
37
+                        new MainReactPackage(),
38
+                        new MainReactPackage()));
39
+        assertThat(uut.getPackages()).hasSize(2).extracting("class").containsOnly(MainReactPackage.class, NavigationPackage.class);
40
+    }
42 41
 }

+ 9
- 9
lib/android/app/src/test/java/com/reactnativenavigation/utils/CompatUtilsTest.java Wyświetl plik

@@ -1,17 +1,17 @@
1 1
 package com.reactnativenavigation.utils;
2 2
 
3
-import com.reactnativenavigation.BaseTest;
3
+import com.reactnativenavigation.*;
4 4
 
5
-import org.junit.Test;
5
+import org.junit.*;
6 6
 
7
-import static org.assertj.core.api.Java6Assertions.assertThat;
7
+import static org.assertj.core.api.Java6Assertions.*;
8 8
 
9 9
 public class CompatUtilsTest extends BaseTest {
10 10
 
11
-	@Test
12
-	public void generateViewId() throws Exception {
13
-		assertThat(CompatUtils.generateViewId())
14
-				.isPositive()
15
-				.isNotEqualTo(CompatUtils.generateViewId());
16
-	}
11
+    @Test
12
+    public void generateViewId() throws Exception {
13
+        assertThat(CompatUtils.generateViewId())
14
+                .isPositive()
15
+                .isNotEqualTo(CompatUtils.generateViewId());
16
+    }
17 17
 }

+ 16
- 16
lib/android/app/src/test/java/com/reactnativenavigation/utils/ReflectionUtilsTest.java Wyświetl plik

@@ -1,26 +1,26 @@
1 1
 package com.reactnativenavigation.utils;
2 2
 
3
-import com.reactnativenavigation.BaseTest;
3
+import com.reactnativenavigation.*;
4 4
 
5
-import org.junit.Test;
5
+import org.junit.*;
6 6
 
7
-import static org.assertj.core.api.Java6Assertions.assertThat;
7
+import static org.assertj.core.api.Java6Assertions.*;
8 8
 
9 9
 public class ReflectionUtilsTest extends BaseTest {
10 10
 
11
-	static class Foo {
12
-		private String bar = "old value";
13
-	}
11
+    static class Foo {
12
+        private String bar = "old value";
13
+    }
14 14
 
15
-	@Test
16
-	public void setField() throws Exception {
17
-		Foo target = new Foo();
18
-		ReflectionUtils.setField(target, "bar", "a new value");
19
-		assertThat(target.bar).isEqualTo("a new value");
20
-	}
15
+    @Test
16
+    public void setField() throws Exception {
17
+        Foo target = new Foo();
18
+        ReflectionUtils.setField(target, "bar", "a new value");
19
+        assertThat(target.bar).isEqualTo("a new value");
20
+    }
21 21
 
22
-	@Test
23
-	public void getDeclaredField() throws Exception {
24
-		assertThat(ReflectionUtils.getDeclaredField(new Foo(), "bar")).isEqualTo("old value");
25
-	}
22
+    @Test
23
+    public void getDeclaredField() throws Exception {
24
+        assertThat(ReflectionUtils.getDeclaredField(new Foo(), "bar")).isEqualTo("old value");
25
+    }
26 26
 }

+ 12
- 12
lib/android/app/src/test/java/com/reactnativenavigation/utils/StringUtilsTest.java Wyświetl plik

@@ -1,19 +1,19 @@
1 1
 package com.reactnativenavigation.utils;
2 2
 
3
-import com.reactnativenavigation.BaseTest;
3
+import com.reactnativenavigation.*;
4 4
 
5
-import org.junit.Test;
5
+import org.junit.*;
6 6
 
7
-import static org.assertj.core.api.Java6Assertions.assertThat;
7
+import static org.assertj.core.api.Java6Assertions.*;
8 8
 
9 9
 public class StringUtilsTest extends BaseTest {
10
-	@Test
11
-	public void isEqual() throws Exception {
12
-		assertThat(StringUtils.isEqual(null, "a")).isFalse();
13
-		assertThat(StringUtils.isEqual("a", null)).isFalse();
14
-		assertThat(StringUtils.isEqual("a", "b")).isFalse();
15
-		assertThat(StringUtils.isEqual("a", "A")).isFalse();
16
-		assertThat(StringUtils.isEqual("a", "a")).isTrue();
17
-		assertThat(StringUtils.isEqual("", "")).isTrue();
18
-	}
10
+    @Test
11
+    public void isEqual() throws Exception {
12
+        assertThat(StringUtils.isEqual(null, "a")).isFalse();
13
+        assertThat(StringUtils.isEqual("a", null)).isFalse();
14
+        assertThat(StringUtils.isEqual("a", "b")).isFalse();
15
+        assertThat(StringUtils.isEqual("a", "A")).isFalse();
16
+        assertThat(StringUtils.isEqual("a", "a")).isTrue();
17
+        assertThat(StringUtils.isEqual("", "")).isTrue();
18
+    }
19 19
 }

+ 36
- 36
lib/android/app/src/test/java/com/reactnativenavigation/utils/TypefaceLoaderTest.java Wyświetl plik

@@ -1,60 +1,60 @@
1 1
 package com.reactnativenavigation.utils;
2 2
 
3
-import android.content.Context;
4
-import android.graphics.Typeface;
5
-import android.test.mock.MockContext;
3
+import android.content.*;
4
+import android.graphics.*;
5
+import android.test.mock.*;
6 6
 
7
-import com.reactnativenavigation.BaseTest;
7
+import com.reactnativenavigation.*;
8 8
 
9
-import org.junit.Test;
10
-import org.mockito.Mockito;
9
+import org.junit.*;
10
+import org.mockito.*;
11 11
 
12
-import static org.assertj.core.api.Java6Assertions.assertThat;
12
+import static org.assertj.core.api.Java6Assertions.*;
13 13
 
14 14
 public class TypefaceLoaderTest extends BaseTest {
15 15
 
16
-	@Test
17
-	public void loadTypefaceNoAssets() {
18
-		Context context = new MockContext();
19
-		TypefaceLoader mockedLoader = Mockito.spy(new TypefaceLoader(context));
20
-		Mockito.doReturn(null).when(mockedLoader).getTypefaceFromAssets("Helvetica-Bold");
16
+    @Test
17
+    public void loadTypefaceNoAssets() {
18
+        Context context = new MockContext();
19
+        TypefaceLoader mockedLoader = Mockito.spy(new TypefaceLoader(context));
20
+        Mockito.doReturn(null).when(mockedLoader).getTypefaceFromAssets("Helvetica-Bold");
21 21
 
22
-		Typeface typeface = mockedLoader.getTypeFace("Helvetica-Bold");
23
-		assertThat(typeface).isNotNull();
24
-		assertThat(typeface.getStyle()).isEqualTo(Typeface.BOLD);
25
-	}
22
+        Typeface typeface = mockedLoader.getTypeFace("Helvetica-Bold");
23
+        assertThat(typeface).isNotNull();
24
+        assertThat(typeface.getStyle()).isEqualTo(Typeface.BOLD);
25
+    }
26 26
 
27
-	@Test
28
-	public void loadTypefaceWithAssets() {
27
+    @Test
28
+    public void loadTypefaceWithAssets() {
29 29
         Context context = new MockContext();
30 30
         TypefaceLoader mockedLoader = Mockito.spy(new TypefaceLoader(context));
31
-		Mockito.doReturn(Typeface.create("Helvetica-Italic", Typeface.ITALIC)).when(mockedLoader).getTypefaceFromAssets("Helvetica-Italic");
31
+        Mockito.doReturn(Typeface.create("Helvetica-Italic", Typeface.ITALIC)).when(mockedLoader).getTypefaceFromAssets("Helvetica-Italic");
32 32
 
33
-		Typeface typeface = mockedLoader.getTypeFace("Helvetica-Italic");
34
-		assertThat(typeface).isNotNull();
35
-		assertThat(typeface.getStyle()).isEqualTo(Typeface.ITALIC);
36
-	}
33
+        Typeface typeface = mockedLoader.getTypeFace("Helvetica-Italic");
34
+        assertThat(typeface).isNotNull();
35
+        assertThat(typeface.getStyle()).isEqualTo(Typeface.ITALIC);
36
+    }
37 37
 
38
-	@Test
39
-	public void loadTypefaceWrongName() {
38
+    @Test
39
+    public void loadTypefaceWrongName() {
40 40
         Context context = new MockContext();
41 41
         TypefaceLoader mockedLoader = Mockito.spy(new TypefaceLoader(context));
42
-		Mockito.doReturn(null).when(mockedLoader).getTypefaceFromAssets("Some-name");
42
+        Mockito.doReturn(null).when(mockedLoader).getTypefaceFromAssets("Some-name");
43 43
 
44
-		Typeface typeface = mockedLoader.getTypeFace("Some-name");
45
-		assertThat(typeface).isNotNull();
46
-		assertThat(typeface.getStyle()).isEqualTo(Typeface.NORMAL);
47
-	}
44
+        Typeface typeface = mockedLoader.getTypeFace("Some-name");
45
+        assertThat(typeface).isNotNull();
46
+        assertThat(typeface.getStyle()).isEqualTo(Typeface.NORMAL);
47
+    }
48 48
 
49
-	@Test
50
-	public void loadTypefaceNull() {
49
+    @Test
50
+    public void loadTypefaceNull() {
51 51
         Context context = new MockContext();
52 52
         TypefaceLoader mockedLoader = Mockito.spy(new TypefaceLoader(context));
53
-		Mockito.doReturn(null).when(mockedLoader).getTypefaceFromAssets(null);
53
+        Mockito.doReturn(null).when(mockedLoader).getTypefaceFromAssets(null);
54 54
 
55
-		Typeface typeface = mockedLoader.getTypeFace(null);
56
-		assertThat(typeface).isNull();
57
-	}
55
+        Typeface typeface = mockedLoader.getTypeFace(null);
56
+        assertThat(typeface).isNull();
57
+    }
58 58
 }
59 59
 
60 60
 

+ 21
- 24
lib/android/app/src/test/java/com/reactnativenavigation/utils/UiThreadTest.java Wyświetl plik

@@ -1,32 +1,29 @@
1 1
 package com.reactnativenavigation.utils;
2 2
 
3
-import com.reactnativenavigation.BaseTest;
3
+import com.reactnativenavigation.*;
4 4
 
5
-import org.junit.Test;
6
-import org.robolectric.shadows.ShadowLooper;
5
+import org.junit.*;
6
+import org.robolectric.shadows.*;
7 7
 
8
-import static org.mockito.Mockito.mock;
9
-import static org.mockito.Mockito.times;
10
-import static org.mockito.Mockito.verify;
11
-import static org.mockito.Mockito.verifyZeroInteractions;
8
+import static org.mockito.Mockito.*;
12 9
 
13 10
 public class UiThreadTest extends BaseTest {
14
-	@Test
15
-	public void postOnUiThread() throws Exception {
16
-		Runnable task = mock(Runnable.class);
17
-		ShadowLooper.pauseMainLooper();
18
-		UiThread.post(task);
19
-		verifyZeroInteractions(task);
20
-		ShadowLooper.runUiThreadTasks();
21
-		verify(task, times(1)).run();
22
-	}
11
+    @Test
12
+    public void postOnUiThread() throws Exception {
13
+        Runnable task = mock(Runnable.class);
14
+        ShadowLooper.pauseMainLooper();
15
+        UiThread.post(task);
16
+        verifyZeroInteractions(task);
17
+        ShadowLooper.runUiThreadTasks();
18
+        verify(task, times(1)).run();
19
+    }
23 20
 
24
-	@Test
25
-	public void postDelayedOnUiThread() throws Exception {
26
-		Runnable task = mock(Runnable.class);
27
-		UiThread.postDelayed(task, 1000);
28
-		verifyZeroInteractions(task);
29
-		ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
30
-		verify(task, times(1)).run();
31
-	}
21
+    @Test
22
+    public void postDelayedOnUiThread() throws Exception {
23
+        Runnable task = mock(Runnable.class);
24
+        UiThread.postDelayed(task, 1000);
25
+        verifyZeroInteractions(task);
26
+        ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
27
+        verify(task, times(1)).run();
28
+    }
32 29
 }

+ 9
- 9
lib/android/app/src/test/java/com/reactnativenavigation/utils/UiUtilsTest.java Wyświetl plik

@@ -9,14 +9,14 @@ import org.junit.*;
9 9
 import static org.mockito.Mockito.*;
10 10
 
11 11
 public class UiUtilsTest extends BaseTest {
12
-	@Test
13
-	public void runOnPreDrawOnce() throws Exception {
14
-		View view = new View(newActivity());
15
-		Runnable task = mock(Runnable.class);
16
-		verifyZeroInteractions(task);
12
+    @Test
13
+    public void runOnPreDrawOnce() throws Exception {
14
+        View view = new View(newActivity());
15
+        Runnable task = mock(Runnable.class);
16
+        verifyZeroInteractions(task);
17 17
 
18
-		UiUtils.runOnPreDrawOnce(view, task);
19
-		view.getViewTreeObserver().dispatchOnPreDraw();
20
-		verify(task, times(1)).run();
21
-	}
18
+        UiUtils.runOnPreDrawOnce(view, task);
19
+        view.getViewTreeObserver().dispatchOnPreDraw();
20
+        verify(task, times(1)).run();
21
+    }
22 22
 }

+ 106
- 110
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/BottomTabsControllerTest.java Wyświetl plik

@@ -1,120 +1,116 @@
1 1
 package com.reactnativenavigation.viewcontrollers;
2 2
 
3
-import android.app.Activity;
4
-import android.support.annotation.NonNull;
5
-import android.support.design.widget.BottomNavigationView;
6
-import android.view.View;
7
-import android.widget.RelativeLayout;
3
+import android.app.*;
4
+import android.support.annotation.*;
5
+import android.support.design.widget.*;
6
+import android.view.*;
7
+import android.widget.*;
8 8
 
9
-import com.reactnativenavigation.BaseTest;
10
-import com.reactnativenavigation.mocks.SimpleViewController;
9
+import com.reactnativenavigation.*;
10
+import com.reactnativenavigation.mocks.*;
11 11
 
12
-import org.assertj.core.api.iterable.Extractor;
13
-import org.junit.Test;
12
+import org.assertj.core.api.iterable.*;
13
+import org.junit.*;
14 14
 
15
-import java.util.Arrays;
16
-import java.util.List;
15
+import java.util.*;
17 16
 
18
-import static org.assertj.core.api.Java6Assertions.assertThat;
19
-import static org.mockito.Mockito.spy;
20
-import static org.mockito.Mockito.times;
21
-import static org.mockito.Mockito.verify;
22
-import static org.mockito.Mockito.when;
17
+import static org.assertj.core.api.Java6Assertions.*;
18
+import static org.mockito.Mockito.*;
23 19
 
24 20
 public class BottomTabsControllerTest extends BaseTest {
25 21
 
26
-	private Activity activity;
27
-	private BottomTabsController uut;
28
-	private ViewController child1;
29
-	private ViewController child2;
30
-	private ViewController child3;
31
-	private ViewController child4;
32
-	private ViewController child5;
33
-
34
-	@Override
35
-	public void beforeEach() {
36
-		super.beforeEach();
37
-		activity = newActivity();
38
-		uut = new BottomTabsController(activity, "uut");
39
-		child1 = new SimpleViewController(activity, "child1");
40
-		child2 = new SimpleViewController(activity, "child2");
41
-		child3 = new SimpleViewController(activity, "child3");
42
-		child4 = new SimpleViewController(activity, "child4");
43
-		child5 = new SimpleViewController(activity, "child5");
44
-	}
45
-
46
-	@Test
47
-	public void containsRelativeLayoutView() throws Exception {
48
-		assertThat(uut.getView()).isInstanceOf(RelativeLayout.class);
49
-		assertThat(uut.getView().getChildAt(0)).isInstanceOf(BottomNavigationView.class);
50
-	}
51
-
52
-	@Test(expected = RuntimeException.class)
53
-	public void setTabs_ThrowWhenMoreThan5() throws Exception {
54
-		List<ViewController> tabs = createTabs();
55
-		tabs.add(new SimpleViewController(activity, "6"));
56
-		uut.setTabs(tabs);
57
-	}
58
-
59
-	@Test
60
-	public void setTabs_AddAllViewsAsGoneExceptFirst() throws Exception {
61
-		List<ViewController> tabs = createTabs();
62
-		uut.setTabs(tabs);
63
-		assertThat(uut.getView().getChildCount()).isEqualTo(6);
64
-		assertThat(uut.getChildControllers()).extracting(new Extractor<ViewController, Integer>() {
65
-			@Override
66
-			public Integer extract(final ViewController input) {
67
-				return input.getView().getVisibility();
68
-			}
69
-		}).containsExactly(View.VISIBLE, View.GONE, View.GONE, View.GONE, View.GONE);
70
-	}
71
-
72
-	@Test
73
-	public void selectTabAtIndex() throws Exception {
74
-		uut.setTabs(createTabs());
75
-		assertThat(uut.getSelectedIndex()).isZero();
76
-
77
-		uut.selectTabAtIndex(3);
78
-
79
-		assertThat(uut.getSelectedIndex()).isEqualTo(3);
80
-		assertThat(uut.getChildControllers()).extracting(new Extractor<ViewController, Integer>() {
81
-			@Override
82
-			public Integer extract(final ViewController input) {
83
-				return input.getView().getVisibility();
84
-			}
85
-		}).containsExactly(View.GONE, View.GONE, View.GONE, View.VISIBLE, View.GONE);
86
-	}
87
-
88
-	@Test
89
-	public void findControllerById_ReturnsSelfOrChildren() throws Exception {
90
-		assertThat(uut.findControllerById("123")).isNull();
91
-		assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
92
-		StackController inner = new StackController(activity, "inner");
93
-		inner.push(child1);
94
-		assertThat(uut.findControllerById(child1.getId())).isNull();
95
-		uut.setTabs(Arrays.<ViewController>asList(inner));
96
-		assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);
97
-	}
98
-
99
-	@Test
100
-	public void handleBack_DelegatesToSelectedChild() throws Exception {
101
-		assertThat(uut.handleBack()).isFalse();
102
-
103
-		List<ViewController> tabs = createTabs();
104
-		ViewController spy = spy(tabs.get(2));
105
-		tabs.set(2, spy);
106
-		when(spy.handleBack()).thenReturn(true);
107
-		uut.setTabs(tabs);
108
-
109
-		assertThat(uut.handleBack()).isFalse();
110
-		uut.selectTabAtIndex(2);
111
-		assertThat(uut.handleBack()).isTrue();
112
-
113
-		verify(spy, times(1)).handleBack();
114
-	}
115
-
116
-	@NonNull
117
-	private List<ViewController> createTabs() {
118
-		return Arrays.asList(child1, child2, child3, child4, child5);
119
-	}
22
+    private Activity activity;
23
+    private BottomTabsController uut;
24
+    private ViewController child1;
25
+    private ViewController child2;
26
+    private ViewController child3;
27
+    private ViewController child4;
28
+    private ViewController child5;
29
+
30
+    @Override
31
+    public void beforeEach() {
32
+        super.beforeEach();
33
+        activity = newActivity();
34
+        uut = new BottomTabsController(activity, "uut");
35
+        child1 = new SimpleViewController(activity, "child1");
36
+        child2 = new SimpleViewController(activity, "child2");
37
+        child3 = new SimpleViewController(activity, "child3");
38
+        child4 = new SimpleViewController(activity, "child4");
39
+        child5 = new SimpleViewController(activity, "child5");
40
+    }
41
+
42
+    @Test
43
+    public void containsRelativeLayoutView() throws Exception {
44
+        assertThat(uut.getView()).isInstanceOf(RelativeLayout.class);
45
+        assertThat(uut.getView().getChildAt(0)).isInstanceOf(BottomNavigationView.class);
46
+    }
47
+
48
+    @Test(expected = RuntimeException.class)
49
+    public void setTabs_ThrowWhenMoreThan5() throws Exception {
50
+        List<ViewController> tabs = createTabs();
51
+        tabs.add(new SimpleViewController(activity, "6"));
52
+        uut.setTabs(tabs);
53
+    }
54
+
55
+    @Test
56
+    public void setTabs_AddAllViewsAsGoneExceptFirst() throws Exception {
57
+        List<ViewController> tabs = createTabs();
58
+        uut.setTabs(tabs);
59
+        assertThat(uut.getView().getChildCount()).isEqualTo(6);
60
+        assertThat(uut.getChildControllers()).extracting(new Extractor<ViewController, Integer>() {
61
+            @Override
62
+            public Integer extract(final ViewController input) {
63
+                return input.getView().getVisibility();
64
+            }
65
+        }).containsExactly(View.VISIBLE, View.GONE, View.GONE, View.GONE, View.GONE);
66
+    }
67
+
68
+    @Test
69
+    public void selectTabAtIndex() throws Exception {
70
+        uut.setTabs(createTabs());
71
+        assertThat(uut.getSelectedIndex()).isZero();
72
+
73
+        uut.selectTabAtIndex(3);
74
+
75
+        assertThat(uut.getSelectedIndex()).isEqualTo(3);
76
+        assertThat(uut.getChildControllers()).extracting(new Extractor<ViewController, Integer>() {
77
+            @Override
78
+            public Integer extract(final ViewController input) {
79
+                return input.getView().getVisibility();
80
+            }
81
+        }).containsExactly(View.GONE, View.GONE, View.GONE, View.VISIBLE, View.GONE);
82
+    }
83
+
84
+    @Test
85
+    public void findControllerById_ReturnsSelfOrChildren() throws Exception {
86
+        assertThat(uut.findControllerById("123")).isNull();
87
+        assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
88
+        StackController inner = new StackController(activity, "inner");
89
+        inner.push(child1);
90
+        assertThat(uut.findControllerById(child1.getId())).isNull();
91
+        uut.setTabs(Arrays.<ViewController>asList(inner));
92
+        assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);
93
+    }
94
+
95
+    @Test
96
+    public void handleBack_DelegatesToSelectedChild() throws Exception {
97
+        assertThat(uut.handleBack()).isFalse();
98
+
99
+        List<ViewController> tabs = createTabs();
100
+        ViewController spy = spy(tabs.get(2));
101
+        tabs.set(2, spy);
102
+        when(spy.handleBack()).thenReturn(true);
103
+        uut.setTabs(tabs);
104
+
105
+        assertThat(uut.handleBack()).isFalse();
106
+        uut.selectTabAtIndex(2);
107
+        assertThat(uut.handleBack()).isTrue();
108
+
109
+        verify(spy, times(1)).handleBack();
110
+    }
111
+
112
+    @NonNull
113
+    private List<ViewController> createTabs() {
114
+        return Arrays.asList(child1, child2, child3, child4, child5);
115
+    }
120 116
 }

+ 53
- 56
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ComponentViewControllerTest.java Wyświetl plik

@@ -1,69 +1,66 @@
1 1
 package com.reactnativenavigation.viewcontrollers;
2 2
 
3
-import android.app.Activity;
3
+import android.app.*;
4 4
 
5
-import com.reactnativenavigation.BaseTest;
6
-import com.reactnativenavigation.mocks.TestComponentLayout;
7
-import com.reactnativenavigation.parse.NavigationOptions;
5
+import com.reactnativenavigation.*;
6
+import com.reactnativenavigation.mocks.*;
7
+import com.reactnativenavigation.parse.*;
8 8
 
9
-import org.junit.Test;
9
+import org.junit.*;
10 10
 
11
-import static org.assertj.core.api.Java6Assertions.assertThat;
12
-import static org.mockito.Mockito.spy;
13
-import static org.mockito.Mockito.times;
14
-import static org.mockito.Mockito.verify;
15
-import static org.mockito.Mockito.when;
11
+import static org.assertj.core.api.Java6Assertions.*;
12
+import static org.mockito.Mockito.*;
16 13
 
17 14
 public class ComponentViewControllerTest extends BaseTest {
18
-	private ComponentViewController uut;
19
-	private ComponentViewController.IReactView view;
15
+    private ComponentViewController uut;
16
+    private ComponentViewController.IReactView view;
20 17
 
21
-	@Override
22
-	public void beforeEach() {
23
-		super.beforeEach();
24
-		Activity activity = newActivity();
25
-		view = spy(new TestComponentLayout(activity));
26
-		uut = new ComponentViewController(activity, "componentId1", "componentName", new ComponentViewController.ReactViewCreator() {
27
-			@Override
28
-			public ComponentViewController.IReactView create(final Activity activity1, final String componentId, final String componentName) {
29
-				return view;
30
-			}
31
-		}, new NavigationOptions());
32
-	}
18
+    @Override
19
+    public void beforeEach() {
20
+        super.beforeEach();
21
+        Activity activity = newActivity();
22
+        view = spy(new TestComponentLayout(activity));
23
+        uut = new ComponentViewController(activity, "componentId1", "componentName", new ComponentViewController.ReactViewCreator() {
24
+            @Override
25
+            public ComponentViewController.IReactView create(final Activity activity1, final String componentId, final String componentName) {
26
+                return view;
27
+            }
28
+        }, new Options());
29
+    }
33 30
 
34
-	@Test
35
-	public void createsViewFromComponentViewCreator() throws Exception {
36
-		assertThat(uut.getView()).isSameAs(view);
37
-	}
31
+    @Test
32
+    public void createsViewFromComponentViewCreator() throws Exception {
33
+        assertThat(uut.getView()).isSameAs(view);
34
+    }
38 35
 
39
-	@Test
40
-	public void componentViewDestroyedOnDestroy() throws Exception {
41
-		uut.ensureViewIsCreated();
42
-		verify(view, times(0)).destroy();
43
-		uut.destroy();
44
-		verify(view, times(1)).destroy();
45
-	}
36
+    @Test
37
+    public void componentViewDestroyedOnDestroy() throws Exception {
38
+        uut.ensureViewIsCreated();
39
+        verify(view, times(0)).destroy();
40
+        uut.destroy();
41
+        verify(view, times(1)).destroy();
42
+    }
46 43
 
47
-	@Test
48
-	public void lifecycleMethodsSentToComponentView() throws Exception {
49
-		uut.ensureViewIsCreated();
50
-		verify(view, times(0)).sendComponentStart();
51
-		verify(view, times(0)).sendComponentStop();
52
-		uut.onViewAppeared();
53
-		verify(view, times(1)).sendComponentStart();
54
-		verify(view, times(0)).sendComponentStop();
55
-		uut.onViewDisappear();
56
-		verify(view, times(1)).sendComponentStart();
57
-		verify(view, times(1)).sendComponentStop();
58
-	}
44
+    @Test
45
+    public void lifecycleMethodsSentToComponentView() throws Exception {
46
+        uut.ensureViewIsCreated();
47
+        verify(view, times(0)).sendComponentStart();
48
+        verify(view, times(0)).sendComponentStop();
49
+        uut.onViewAppeared();
50
+        verify(view, times(1)).sendComponentStart();
51
+        verify(view, times(0)).sendComponentStop();
52
+        uut.onViewDisappear();
53
+        verify(view, times(1)).sendComponentStart();
54
+        verify(view, times(1)).sendComponentStop();
55
+    }
59 56
 
60
-	@Test
61
-	public void isViewShownOnlyIfComponentViewIsReady() throws Exception {
62
-		assertThat(uut.isViewShown()).isFalse();
63
-		uut.ensureViewIsCreated();
64
-		when(view.asView().isShown()).thenReturn(true);
65
-		assertThat(uut.isViewShown()).isFalse();
66
-		when(view.isReady()).thenReturn(true);
67
-		assertThat(uut.isViewShown()).isTrue();
68
-	}
57
+    @Test
58
+    public void isViewShownOnlyIfComponentViewIsReady() throws Exception {
59
+        assertThat(uut.isViewShown()).isFalse();
60
+        uut.ensureViewIsCreated();
61
+        when(view.asView().isShown()).thenReturn(true);
62
+        assertThat(uut.isViewShown()).isFalse();
63
+        when(view.isReady()).thenReturn(true);
64
+        assertThat(uut.isViewShown()).isTrue();
65
+    }
69 66
 }

+ 106
- 106
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/IdStackTest.java Wyświetl plik

@@ -1,114 +1,114 @@
1 1
 package com.reactnativenavigation.viewcontrollers;
2 2
 
3
-import com.reactnativenavigation.BaseTest;
3
+import com.reactnativenavigation.*;
4 4
 
5
-import org.junit.Test;
5
+import org.junit.*;
6 6
 
7
-import static org.assertj.core.api.Java6Assertions.assertThat;
7
+import static org.assertj.core.api.Java6Assertions.*;
8 8
 
9 9
 public class IdStackTest extends BaseTest {
10 10
 
11
-	private IdStack<Integer> uut;
12
-
13
-	@Override
14
-	public void beforeEach() {
15
-		super.beforeEach();
16
-		uut = new IdStack<>();
17
-	}
18
-
19
-	@Test
20
-	public void isEmpty() throws Exception {
21
-		assertThat(uut.isEmpty()).isTrue();
22
-		uut.push("123", 123);
23
-		assertThat(uut.isEmpty()).isFalse();
24
-	}
25
-
26
-	@Test
27
-	public void size() throws Exception {
28
-		assertThat(uut.size()).isEqualTo(0);
29
-		uut.push("123", 123);
30
-		assertThat(uut.size()).isEqualTo(1);
31
-	}
32
-
33
-	@Test
34
-	public void peek() throws Exception {
35
-		assertThat(uut.peek()).isNull();
36
-		uut.push("123", 123);
37
-		uut.push("456", 456);
38
-		assertThat(uut.peek()).isEqualTo(456);
39
-	}
40
-
41
-	@Test
42
-	public void pop() throws Exception {
43
-		assertThat(uut.pop()).isNull();
44
-		uut.push("123", 123);
45
-		uut.push("456", 456);
46
-		assertThat(uut.pop()).isEqualTo(456);
47
-	}
48
-
49
-	@Test
50
-	public void peekId() throws Exception {
51
-		assertThat(uut.peekId()).isNull();
52
-		uut.push("123", 123);
53
-		assertThat(uut.peekId()).isEqualTo("123");
54
-	}
55
-
56
-	@Test
57
-	public void clear() throws Exception {
58
-		uut.push("123", 123);
59
-		uut.push("456", 456);
60
-		uut.clear();
61
-		assertThat(uut.isEmpty()).isTrue();
62
-	}
63
-
64
-	@Test
65
-	public void getById() throws Exception {
66
-		assertThat(uut.get("123")).isNull();
67
-		uut.push("123", 123);
68
-		uut.push("456", 456);
69
-		assertThat(uut.get("123")).isEqualTo(123);
70
-	}
71
-
72
-	@Test
73
-	public void containsId() throws Exception {
74
-		assertThat(uut.containsId("123")).isFalse();
75
-		uut.push("123", 123);
76
-		assertThat(uut.containsId("123")).isTrue();
77
-	}
78
-
79
-	@Test
80
-	public void remove() throws Exception {
81
-		assertThat(uut.remove("123")).isNull();
82
-
83
-		uut.push("123", 123);
84
-		uut.push("456", 456);
85
-
86
-		assertThat(uut.remove("123")).isEqualTo(123);
87
-	}
88
-
89
-	@Test
90
-	public void iterableIds() throws Exception {
91
-		assertThat(uut).isInstanceOf(Iterable.class);
92
-		assertThat(uut).isEmpty();
93
-		uut.push("123", 123);
94
-		uut.push("456", 456);
95
-		assertThat(uut).containsExactly("456", "123");
96
-	}
97
-
98
-	@Test
99
-	public void isTop() throws Exception {
100
-		assertThat(uut.isTop("123")).isFalse();
101
-		uut.push("123", 123);
102
-		assertThat(uut.isTop("123")).isTrue();
103
-		uut.push("456", 456);
104
-		assertThat(uut.isTop("123")).isFalse();
105
-	}
106
-
107
-	@Test
108
-	public void values() throws Exception {
109
-		assertThat(uut.values()).isNotNull().isEmpty();
110
-		uut.push("123", 123);
111
-		uut.push("456", 456);
112
-		assertThat(uut.values()).isNotNull().containsExactlyInAnyOrder(123, 456);
113
-	}
11
+    private IdStack<Integer> uut;
12
+
13
+    @Override
14
+    public void beforeEach() {
15
+        super.beforeEach();
16
+        uut = new IdStack<>();
17
+    }
18
+
19
+    @Test
20
+    public void isEmpty() throws Exception {
21
+        assertThat(uut.isEmpty()).isTrue();
22
+        uut.push("123", 123);
23
+        assertThat(uut.isEmpty()).isFalse();
24
+    }
25
+
26
+    @Test
27
+    public void size() throws Exception {
28
+        assertThat(uut.size()).isEqualTo(0);
29
+        uut.push("123", 123);
30
+        assertThat(uut.size()).isEqualTo(1);
31
+    }
32
+
33
+    @Test
34
+    public void peek() throws Exception {
35
+        assertThat(uut.peek()).isNull();
36
+        uut.push("123", 123);
37
+        uut.push("456", 456);
38
+        assertThat(uut.peek()).isEqualTo(456);
39
+    }
40
+
41
+    @Test
42
+    public void pop() throws Exception {
43
+        assertThat(uut.pop()).isNull();
44
+        uut.push("123", 123);
45
+        uut.push("456", 456);
46
+        assertThat(uut.pop()).isEqualTo(456);
47
+    }
48
+
49
+    @Test
50
+    public void peekId() throws Exception {
51
+        assertThat(uut.peekId()).isNull();
52
+        uut.push("123", 123);
53
+        assertThat(uut.peekId()).isEqualTo("123");
54
+    }
55
+
56
+    @Test
57
+    public void clear() throws Exception {
58
+        uut.push("123", 123);
59
+        uut.push("456", 456);
60
+        uut.clear();
61
+        assertThat(uut.isEmpty()).isTrue();
62
+    }
63
+
64
+    @Test
65
+    public void getById() throws Exception {
66
+        assertThat(uut.get("123")).isNull();
67
+        uut.push("123", 123);
68
+        uut.push("456", 456);
69
+        assertThat(uut.get("123")).isEqualTo(123);
70
+    }
71
+
72
+    @Test
73
+    public void containsId() throws Exception {
74
+        assertThat(uut.containsId("123")).isFalse();
75
+        uut.push("123", 123);
76
+        assertThat(uut.containsId("123")).isTrue();
77
+    }
78
+
79
+    @Test
80
+    public void remove() throws Exception {
81
+        assertThat(uut.remove("123")).isNull();
82
+
83
+        uut.push("123", 123);
84
+        uut.push("456", 456);
85
+
86
+        assertThat(uut.remove("123")).isEqualTo(123);
87
+    }
88
+
89
+    @Test
90
+    public void iterableIds() throws Exception {
91
+        assertThat(uut).isInstanceOf(Iterable.class);
92
+        assertThat(uut).isEmpty();
93
+        uut.push("123", 123);
94
+        uut.push("456", 456);
95
+        assertThat(uut).containsExactly("456", "123");
96
+    }
97
+
98
+    @Test
99
+    public void isTop() throws Exception {
100
+        assertThat(uut.isTop("123")).isFalse();
101
+        uut.push("123", 123);
102
+        assertThat(uut.isTop("123")).isTrue();
103
+        uut.push("456", 456);
104
+        assertThat(uut.isTop("123")).isFalse();
105
+    }
106
+
107
+    @Test
108
+    public void values() throws Exception {
109
+        assertThat(uut.values()).isNotNull().isEmpty();
110
+        uut.push("123", 123);
111
+        uut.push("456", 456);
112
+        assertThat(uut.values()).isNotNull().containsExactlyInAnyOrder(123, 456);
113
+    }
114 114
 }

+ 270
- 276
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java Wyświetl plik

@@ -1,289 +1,283 @@
1 1
 package com.reactnativenavigation.viewcontrollers;
2 2
 
3
-import android.app.Activity;
4
-import android.support.annotation.NonNull;
3
+import android.app.*;
4
+import android.support.annotation.*;
5 5
 
6
-import com.reactnativenavigation.BaseTest;
7
-import com.reactnativenavigation.mocks.MockPromise;
8
-import com.reactnativenavigation.mocks.SimpleComponentViewController;
9
-import com.reactnativenavigation.mocks.SimpleViewController;
10
-import com.reactnativenavigation.mocks.TestNavigationAnimator;
11
-import com.reactnativenavigation.parse.NavigationOptions;
12
-import com.reactnativenavigation.utils.CompatUtils;
6
+import com.reactnativenavigation.*;
7
+import com.reactnativenavigation.mocks.*;
8
+import com.reactnativenavigation.parse.*;
9
+import com.reactnativenavigation.utils.*;
13 10
 
14
-import org.junit.Test;
11
+import org.junit.*;
15 12
 
16
-import java.util.Arrays;
13
+import java.util.*;
17 14
 
18 15
 import javax.annotation.Nullable;
19 16
 
20
-import static org.assertj.core.api.Java6Assertions.assertThat;
21
-import static org.mockito.Mockito.spy;
22
-import static org.mockito.Mockito.times;
23
-import static org.mockito.Mockito.verify;
24
-import static org.mockito.Mockito.when;
17
+import static org.assertj.core.api.Java6Assertions.*;
18
+import static org.mockito.Mockito.*;
25 19
 
26 20
 public class NavigatorTest extends BaseTest {
27
-	private Activity activity;
28
-	private Navigator uut;
29
-	private SimpleViewController child1;
30
-	private ViewController child2;
31
-	private ViewController child3;
32
-	private ViewController child4;
33
-	private ViewController child5;
34
-
35
-
36
-	@Override
37
-	public void beforeEach() {
38
-		super.beforeEach();
39
-		activity = newActivity();
40
-		uut = new Navigator(activity);
41
-		child1 = new SimpleViewController(activity, "child1");
42
-		child2 = new SimpleViewController(activity, "child2");
43
-		child3 = new SimpleViewController(activity, "child3");
44
-		child4 = new SimpleViewController(activity, "child4");
45
-		child5 = new SimpleViewController(activity, "child5");
46
-	}
47
-
48
-	@Test
49
-	public void setRoot_AddsChildControllerView() throws Exception {
50
-		assertThat(uut.getView().getChildCount()).isZero();
51
-		uut.setRoot(child1);
52
-		assertIsChildById(uut.getView(), child1.getView());
53
-	}
54
-
55
-	@Test
56
-	public void setRoot_ReplacesExistingChildControllerViews() throws Exception {
57
-		uut.setRoot(child1);
58
-		uut.setRoot(child2);
59
-		assertIsChildById(uut.getView(), child2.getView());
60
-	}
61
-
62
-	@Test
63
-	public void hasUniqueId() throws Exception {
64
-		assertThat(uut.getId()).startsWith("navigator");
65
-		assertThat(new Navigator(activity).getId()).isNotEqualTo(uut.getId());
66
-	}
67
-
68
-	@Test
69
-	public void push() throws Exception {
70
-		StackController stackController = newStack();
71
-		stackController.push(child1);
72
-		uut.setRoot(stackController);
73
-
74
-		assertIsChildById(uut.getView(), stackController.getView());
75
-		assertIsChildById(stackController.getView(), child1.getView());
76
-
77
-		uut.push(child1.getId(), child2);
78
-
79
-		assertIsChildById(uut.getView(), stackController.getView());
80
-		assertIsChildById(stackController.getView(), child2.getView());
81
-	}
82
-
83
-	@Test
84
-	public void push_InvalidPushWithoutAStack_DoesNothing() throws Exception {
85
-		uut.setRoot(child1);
86
-		uut.push(child1.getId(), child2);
87
-		assertIsChildById(uut.getView(), child1.getView());
88
-	}
89
-
90
-	@Test
91
-	public void push_OnCorrectStackByFindingChildId() throws Exception {
92
-		BottomTabsController bottomTabsController = newTabs();
93
-		StackController stack1 = newStack();
94
-		StackController stack2 = newStack();
95
-		stack1.push(child1);
96
-		stack2.push(child2);
97
-		bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
98
-		uut.setRoot(bottomTabsController);
99
-
100
-		SimpleViewController newChild = new SimpleViewController(activity, "new child");
101
-		uut.push(child2.getId(), newChild);
102
-
103
-		assertThat(stack1.getChildControllers()).doesNotContain(newChild);
104
-		assertThat(stack2.getChildControllers()).contains(newChild);
105
-	}
106
-
107
-	@Test
108
-	public void pop_InvalidDoesNothing() throws Exception {
109
-		uut.pop("123");
110
-		uut.setRoot(child1);
111
-		uut.pop(child1.getId());
112
-		assertThat(uut.getChildControllers()).hasSize(1);
113
-	}
114
-
115
-	@Test
116
-	public void pop_FromCorrectStackByFindingChildId() throws Exception {
117
-		BottomTabsController bottomTabsController = newTabs();
118
-		StackController stack1 = newStack();
119
-		StackController stack2 = newStack();
120
-		stack1.push(child1);
121
-		stack2.push(child2);
122
-		stack2.push(child3);
123
-		stack2.push(child4);
124
-		bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
125
-		uut.setRoot(bottomTabsController);
126
-
127
-		uut.pop("child4");
128
-
129
-		assertThat(stack2.getChildControllers()).containsOnly(child2, child3);
130
-	}
131
-
132
-	@Test
133
-	public void popSpecific() throws Exception {
134
-		BottomTabsController bottomTabsController = newTabs();
135
-		StackController stack1 = newStack();
136
-		StackController stack2 = newStack();
137
-		stack1.push(child1);
138
-		stack2.push(child2);
139
-		stack2.push(child3);
140
-		stack2.push(child4);
141
-		bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
142
-		uut.setRoot(bottomTabsController);
143
-
144
-		uut.popSpecific(child2.getId());
145
-
146
-		assertThat(stack2.getChildControllers()).containsOnly(child4, child3);
147
-	}
148
-
149
-	@Test
150
-	public void popTo_FromCorrectStackUpToChild() throws Exception {
151
-		BottomTabsController bottomTabsController = newTabs();
152
-		StackController stack1 = newStack();
153
-		StackController stack2 = newStack();
154
-		stack1.push(child1);
155
-		stack2.push(child2);
156
-		stack2.push(child3);
157
-		stack2.push(child4);
158
-		stack2.push(child5);
159
-		bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
160
-		uut.setRoot(bottomTabsController);
161
-
162
-		uut.popTo(child2.getId());
163
-
164
-		assertThat(stack2.getChildControllers()).containsOnly(child2);
165
-	}
166
-
167
-	@Test
168
-	public void popToRoot() throws Exception {
169
-		BottomTabsController bottomTabsController = newTabs();
170
-		StackController stack1 = newStack();
171
-		StackController stack2 = newStack();
172
-		stack1.push(child1);
173
-		stack2.push(child2);
174
-		stack2.push(child3);
175
-		stack2.push(child4);
176
-		stack2.push(child5);
177
-
178
-		bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
179
-		uut.setRoot(bottomTabsController);
180
-
181
-		uut.popToRoot(child3.getId());
182
-
183
-		assertThat(stack2.getChildControllers()).containsOnly(child2);
184
-	}
185
-
186
-	@Test
187
-	public void handleBack_DelegatesToRoot() throws Exception {
188
-		assertThat(uut.handleBack()).isFalse();
189
-		ViewController spy = spy(child1);
190
-		uut.setRoot(spy);
191
-		when(spy.handleBack()).thenReturn(true);
192
-		assertThat(uut.handleBack()).isTrue();
193
-		verify(spy, times(1)).handleBack();
194
-	}
195
-
196
-	@Test
197
-	public void setOptions_CallsApplyNavigationOptions() {
198
-		ComponentViewController componentVc = new SimpleComponentViewController(activity, "theId");
199
-		uut.setRoot(componentVc);
200
-		assertThat(componentVc.getOptions().topBarOptions.title).isEmpty();
201
-
202
-		NavigationOptions options = new NavigationOptions();
203
-		options.topBarOptions.title = "new title";
204
-
205
-		uut.setOptions("theId", options);
206
-		assertThat(componentVc.getOptions().topBarOptions.title).isEqualTo("new title");
207
-	}
208
-
209
-	@Test
210
-	public void setOptions_AffectsOnlyComponentViewControllers() {
211
-		uut.setOptions("some unknown child id", new NavigationOptions());
212
-	}
213
-
214
-	@NonNull
215
-	private BottomTabsController newTabs() {
216
-		return new BottomTabsController(activity, "tabsController");
217
-	}
218
-
219
-	@NonNull
220
-	private StackController newStack() {
221
-		return new StackController(activity, "stack" + CompatUtils.generateViewId(), new TestNavigationAnimator());
222
-	}
223
-
224
-	@Test
225
-	public void push_Promise() throws Exception {
226
-		final StackController stackController = newStack();
227
-		stackController.push(child1);
228
-		uut.setRoot(stackController);
229
-
230
-		assertIsChildById(uut.getView(), stackController.getView());
231
-		assertIsChildById(stackController.getView(), child1.getView());
232
-
233
-		uut.push(child1.getId(), child2, new MockPromise() {
234
-			@Override
235
-			public void resolve(@Nullable Object value) {
236
-				assertIsChildById(uut.getView(), stackController.getView());
237
-				assertIsChildById(stackController.getView(), child2.getView());
238
-			}
239
-		});
240
-	}
241
-
242
-	@Test
243
-	public void push_InvalidPushWithoutAStack_DoesNothing_Promise() throws Exception {
244
-		uut.setRoot(child1);
245
-		uut.push(child1.getId(), child2, new MockPromise() {
246
-			@Override
247
-			public void reject(String code, Throwable e) {
248
-				assertIsChildById(uut.getView(), child1.getView());
249
-			}
250
-		});
251
-
252
-	}
253
-
254
-	@Test
255
-	public void pop_InvalidDoesNothing_Promise() throws Exception {
256
-		uut.pop("123");
257
-		uut.setRoot(child1);
258
-		uut.pop(child1.getId(), new MockPromise() {
259
-			@Override
260
-			public void reject(Throwable reason) {
261
-				assertThat(uut.getChildControllers()).hasSize(1);
262
-			}
263
-		});
264
-	}
265
-
266
-	@Test
267
-	public void pop_FromCorrectStackByFindingChildId_Promise() throws Exception {
268
-		BottomTabsController bottomTabsController = newTabs();
269
-		StackController stack1 = newStack();
270
-		final StackController stack2 = newStack();
271
-		stack1.push(child1);
272
-		stack2.push(child2);
273
-		stack2.push(child3);
274
-		stack2.push(child4);
275
-		bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
276
-		uut.setRoot(bottomTabsController);
277
-
278
-		uut.pop("child4", new MockPromise() {
279
-			@Override
280
-			public void resolve(@Nullable Object value) {
281
-				assertThat(stack2.getChildControllers()).containsOnly(child2, child3);
282
-			}
283
-		});
284
-	}
285
-
286
-	@Test
21
+    private Activity activity;
22
+    private Navigator uut;
23
+    private SimpleViewController child1;
24
+    private ViewController child2;
25
+    private ViewController child3;
26
+    private ViewController child4;
27
+    private ViewController child5;
28
+
29
+
30
+    @Override
31
+    public void beforeEach() {
32
+        super.beforeEach();
33
+        activity = newActivity();
34
+        uut = new Navigator(activity);
35
+        child1 = new SimpleViewController(activity, "child1");
36
+        child2 = new SimpleViewController(activity, "child2");
37
+        child3 = new SimpleViewController(activity, "child3");
38
+        child4 = new SimpleViewController(activity, "child4");
39
+        child5 = new SimpleViewController(activity, "child5");
40
+    }
41
+
42
+    @Test
43
+    public void setRoot_AddsChildControllerView() throws Exception {
44
+        assertThat(uut.getView().getChildCount()).isZero();
45
+        uut.setRoot(child1);
46
+        assertIsChildById(uut.getView(), child1.getView());
47
+    }
48
+
49
+    @Test
50
+    public void setRoot_ReplacesExistingChildControllerViews() throws Exception {
51
+        uut.setRoot(child1);
52
+        uut.setRoot(child2);
53
+        assertIsChildById(uut.getView(), child2.getView());
54
+    }
55
+
56
+    @Test
57
+    public void hasUniqueId() throws Exception {
58
+        assertThat(uut.getId()).startsWith("navigator");
59
+        assertThat(new Navigator(activity).getId()).isNotEqualTo(uut.getId());
60
+    }
61
+
62
+    @Test
63
+    public void push() throws Exception {
64
+        StackController stackController = newStack();
65
+        stackController.push(child1);
66
+        uut.setRoot(stackController);
67
+
68
+        assertIsChildById(uut.getView(), stackController.getView());
69
+        assertIsChildById(stackController.getView(), child1.getView());
70
+
71
+        uut.push(child1.getId(), child2);
72
+
73
+        assertIsChildById(uut.getView(), stackController.getView());
74
+        assertIsChildById(stackController.getView(), child2.getView());
75
+    }
76
+
77
+    @Test
78
+    public void push_InvalidPushWithoutAStack_DoesNothing() throws Exception {
79
+        uut.setRoot(child1);
80
+        uut.push(child1.getId(), child2);
81
+        assertIsChildById(uut.getView(), child1.getView());
82
+    }
83
+
84
+    @Test
85
+    public void push_OnCorrectStackByFindingChildId() throws Exception {
86
+        BottomTabsController bottomTabsController = newTabs();
87
+        StackController stack1 = newStack();
88
+        StackController stack2 = newStack();
89
+        stack1.push(child1);
90
+        stack2.push(child2);
91
+        bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
92
+        uut.setRoot(bottomTabsController);
93
+
94
+        SimpleViewController newChild = new SimpleViewController(activity, "new child");
95
+        uut.push(child2.getId(), newChild);
96
+
97
+        assertThat(stack1.getChildControllers()).doesNotContain(newChild);
98
+        assertThat(stack2.getChildControllers()).contains(newChild);
99
+    }
100
+
101
+    @Test
102
+    public void pop_InvalidDoesNothing() throws Exception {
103
+        uut.pop("123");
104
+        uut.setRoot(child1);
105
+        uut.pop(child1.getId());
106
+        assertThat(uut.getChildControllers()).hasSize(1);
107
+    }
108
+
109
+    @Test
110
+    public void pop_FromCorrectStackByFindingChildId() throws Exception {
111
+        BottomTabsController bottomTabsController = newTabs();
112
+        StackController stack1 = newStack();
113
+        StackController stack2 = newStack();
114
+        stack1.push(child1);
115
+        stack2.push(child2);
116
+        stack2.push(child3);
117
+        stack2.push(child4);
118
+        bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
119
+        uut.setRoot(bottomTabsController);
120
+
121
+        uut.pop("child4");
122
+
123
+        assertThat(stack2.getChildControllers()).containsOnly(child2, child3);
124
+    }
125
+
126
+    @Test
127
+    public void popSpecific() throws Exception {
128
+        BottomTabsController bottomTabsController = newTabs();
129
+        StackController stack1 = newStack();
130
+        StackController stack2 = newStack();
131
+        stack1.push(child1);
132
+        stack2.push(child2);
133
+        stack2.push(child3);
134
+        stack2.push(child4);
135
+        bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
136
+        uut.setRoot(bottomTabsController);
137
+
138
+        uut.popSpecific(child2.getId());
139
+
140
+        assertThat(stack2.getChildControllers()).containsOnly(child4, child3);
141
+    }
142
+
143
+    @Test
144
+    public void popTo_FromCorrectStackUpToChild() throws Exception {
145
+        BottomTabsController bottomTabsController = newTabs();
146
+        StackController stack1 = newStack();
147
+        StackController stack2 = newStack();
148
+        stack1.push(child1);
149
+        stack2.push(child2);
150
+        stack2.push(child3);
151
+        stack2.push(child4);
152
+        stack2.push(child5);
153
+        bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
154
+        uut.setRoot(bottomTabsController);
155
+
156
+        uut.popTo(child2.getId());
157
+
158
+        assertThat(stack2.getChildControllers()).containsOnly(child2);
159
+    }
160
+
161
+    @Test
162
+    public void popToRoot() throws Exception {
163
+        BottomTabsController bottomTabsController = newTabs();
164
+        StackController stack1 = newStack();
165
+        StackController stack2 = newStack();
166
+        stack1.push(child1);
167
+        stack2.push(child2);
168
+        stack2.push(child3);
169
+        stack2.push(child4);
170
+        stack2.push(child5);
171
+
172
+        bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
173
+        uut.setRoot(bottomTabsController);
174
+
175
+        uut.popToRoot(child3.getId());
176
+
177
+        assertThat(stack2.getChildControllers()).containsOnly(child2);
178
+    }
179
+
180
+    @Test
181
+    public void handleBack_DelegatesToRoot() throws Exception {
182
+        assertThat(uut.handleBack()).isFalse();
183
+        ViewController spy = spy(child1);
184
+        uut.setRoot(spy);
185
+        when(spy.handleBack()).thenReturn(true);
186
+        assertThat(uut.handleBack()).isTrue();
187
+        verify(spy, times(1)).handleBack();
188
+    }
189
+
190
+    @Test
191
+    public void setOptions_CallsApplyNavigationOptions() {
192
+        ComponentViewController componentVc = new SimpleComponentViewController(activity, "theId");
193
+        uut.setRoot(componentVc);
194
+        assertThat(componentVc.getOptions().topBarOptions.title).isEmpty();
195
+
196
+        Options options = new Options();
197
+        options.topBarOptions.title = "new title";
198
+
199
+        uut.setOptions("theId", options);
200
+        assertThat(componentVc.getOptions().topBarOptions.title).isEqualTo("new title");
201
+    }
202
+
203
+    @Test
204
+    public void setOptions_AffectsOnlyComponentViewControllers() {
205
+        uut.setOptions("some unknown child id", new Options());
206
+    }
207
+
208
+    @NonNull
209
+    private BottomTabsController newTabs() {
210
+        return new BottomTabsController(activity, "tabsController");
211
+    }
212
+
213
+    @NonNull
214
+    private StackController newStack() {
215
+        return new StackController(activity, "stack" + CompatUtils.generateViewId(), new TestNavigationAnimator());
216
+    }
217
+
218
+    @Test
219
+    public void push_Promise() throws Exception {
220
+        final StackController stackController = newStack();
221
+        stackController.push(child1);
222
+        uut.setRoot(stackController);
223
+
224
+        assertIsChildById(uut.getView(), stackController.getView());
225
+        assertIsChildById(stackController.getView(), child1.getView());
226
+
227
+        uut.push(child1.getId(), child2, new MockPromise() {
228
+            @Override
229
+            public void resolve(@Nullable Object value) {
230
+                assertIsChildById(uut.getView(), stackController.getView());
231
+                assertIsChildById(stackController.getView(), child2.getView());
232
+            }
233
+        });
234
+    }
235
+
236
+    @Test
237
+    public void push_InvalidPushWithoutAStack_DoesNothing_Promise() throws Exception {
238
+        uut.setRoot(child1);
239
+        uut.push(child1.getId(), child2, new MockPromise() {
240
+            @Override
241
+            public void reject(String code, Throwable e) {
242
+                assertIsChildById(uut.getView(), child1.getView());
243
+            }
244
+        });
245
+
246
+    }
247
+
248
+    @Test
249
+    public void pop_InvalidDoesNothing_Promise() throws Exception {
250
+        uut.pop("123");
251
+        uut.setRoot(child1);
252
+        uut.pop(child1.getId(), new MockPromise() {
253
+            @Override
254
+            public void reject(Throwable reason) {
255
+                assertThat(uut.getChildControllers()).hasSize(1);
256
+            }
257
+        });
258
+    }
259
+
260
+    @Test
261
+    public void pop_FromCorrectStackByFindingChildId_Promise() throws Exception {
262
+        BottomTabsController bottomTabsController = newTabs();
263
+        StackController stack1 = newStack();
264
+        final StackController stack2 = newStack();
265
+        stack1.push(child1);
266
+        stack2.push(child2);
267
+        stack2.push(child3);
268
+        stack2.push(child4);
269
+        bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
270
+        uut.setRoot(bottomTabsController);
271
+
272
+        uut.pop("child4", new MockPromise() {
273
+            @Override
274
+            public void resolve(@Nullable Object value) {
275
+                assertThat(stack2.getChildControllers()).containsOnly(child2, child3);
276
+            }
277
+        });
278
+    }
279
+
280
+    @Test
287 281
     public void pushIntoModal() throws Exception {
288 282
         StackController stackController = newStack();
289 283
         stackController.push(child1);

+ 66
- 67
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java Wyświetl plik

@@ -1,35 +1,34 @@
1 1
 package com.reactnativenavigation.viewcontrollers;
2 2
 
3
-import android.app.Activity;
3
+import android.app.*;
4 4
 import android.graphics.Color;
5
-import android.graphics.drawable.ColorDrawable;
6
-import android.view.View;
7
-import android.view.ViewGroup;
8
-import android.widget.RelativeLayout;
5
+import android.graphics.drawable.*;
6
+import android.view.*;
7
+import android.widget.*;
9 8
 
10
-import com.reactnativenavigation.BaseTest;
11
-import com.reactnativenavigation.mocks.TestComponentLayout;
12
-import com.reactnativenavigation.parse.NavigationOptions;
9
+import com.reactnativenavigation.*;
10
+import com.reactnativenavigation.mocks.*;
11
+import com.reactnativenavigation.parse.*;
13 12
 
14
-import org.junit.Test;
13
+import org.junit.*;
15 14
 
16
-import static android.widget.RelativeLayout.BELOW;
17
-import static org.assertj.core.api.Java6Assertions.assertThat;
18
-import static org.mockito.Mockito.spy;
15
+import static android.widget.RelativeLayout.*;
16
+import static org.assertj.core.api.Java6Assertions.*;
17
+import static org.mockito.Mockito.*;
19 18
 
20 19
 public class OptionsApplyingTest extends BaseTest {
21
-	private Activity activity;
22
-	private ComponentViewController uut;
23
-	private ComponentViewController.IReactView view;
24
-	private NavigationOptions initialNavigationOptions;
25
-
26
-	@Override
27
-	public void beforeEach() {
28
-		super.beforeEach();
29
-		activity = newActivity();
30
-		initialNavigationOptions = new NavigationOptions();
31
-		view = spy(new TestComponentLayout(activity));
32
-		uut = new ComponentViewController(activity,
20
+    private Activity activity;
21
+    private ComponentViewController uut;
22
+    private ComponentViewController.IReactView view;
23
+    private Options initialNavigationOptions;
24
+
25
+    @Override
26
+    public void beforeEach() {
27
+        super.beforeEach();
28
+        activity = newActivity();
29
+        initialNavigationOptions = new Options();
30
+        view = spy(new TestComponentLayout(activity));
31
+        uut = new ComponentViewController(activity,
33 32
                 "componentId1",
34 33
                 "componentName",
35 34
                 (activity1, componentId, componentName) -> view,
@@ -45,34 +44,34 @@ public class OptionsApplyingTest extends BaseTest {
45 44
         assertThat(uut.getParentStackController()).isNull();
46 45
     }
47 46
 
48
-	@Test
49
-	public void initialOptionsAppliedOnAppear() throws Exception {
50
-		assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
51
-		initialNavigationOptions.topBarOptions.title = "the title";
52
-		StackController stackController = new StackController(activity, "stackId");
53
-		stackController.push(uut);
54
-		assertThat(uut.getTopBar().getTitle()).isEmpty();
47
+    @Test
48
+    public void initialOptionsAppliedOnAppear() throws Exception {
49
+        assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
50
+        initialNavigationOptions.topBarOptions.title = "the title";
51
+        StackController stackController = new StackController(activity, "stackId");
52
+        stackController.push(uut);
53
+        assertThat(uut.getTopBar().getTitle()).isEmpty();
55 54
 
56 55
         uut.onViewAppeared();
57 56
         assertThat(uut.getTopBar().getTitle()).isEqualTo("the title");
58 57
     }
59 58
 
60
-	@Test
61
-	public void mergeNavigationOptionsUpdatesCurrentOptions() throws Exception {
62
-		assertThat(uut.getOptions().topBarOptions.title).isEmpty();
63
-		NavigationOptions options = new NavigationOptions();
64
-		options.topBarOptions.title = "new title";
65
-		uut.mergeNavigationOptions(options);
66
-		assertThat(uut.getOptions().topBarOptions.title).isEqualTo("new title");
67
-		assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
68
-	}
59
+    @Test
60
+    public void mergeNavigationOptionsUpdatesCurrentOptions() throws Exception {
61
+        assertThat(uut.getOptions().topBarOptions.title).isEmpty();
62
+        Options options = new Options();
63
+        options.topBarOptions.title = "new title";
64
+        uut.mergeNavigationOptions(options);
65
+        assertThat(uut.getOptions().topBarOptions.title).isEqualTo("new title");
66
+        assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
67
+    }
69 68
 
70 69
     @Test
71 70
     public void reappliesOptionsOnMerge() throws Exception {
72 71
         uut.onViewAppeared();
73 72
         assertThat(uut.getTopBar().getTitle()).isEmpty();
74 73
 
75
-        NavigationOptions opts = new NavigationOptions();
74
+        Options opts = new Options();
76 75
         opts.topBarOptions.title = "the new title";
77 76
         uut.mergeNavigationOptions(opts);
78 77
 
@@ -85,21 +84,21 @@ public class OptionsApplyingTest extends BaseTest {
85 84
         //TODO: FIX TEST
86 85
         assertThat(((ColorDrawable) uut.getTopBar().getTitleBar().getBackground()).getColor()).isNotEqualTo(Color.RED);
87 86
 
88
-        NavigationOptions opts = new NavigationOptions();
87
+        Options opts = new Options();
89 88
         opts.topBarOptions.backgroundColor = Color.RED;
90 89
         uut.mergeNavigationOptions(opts);
91 90
 
92 91
         assertThat(((ColorDrawable) uut.getTopBar().getTitleBar().getBackground()).getColor()).isEqualTo(Color.RED);
93 92
     }
94 93
 
95
-	@Test
96
-	public void appliesTopBarTextColor() throws Exception {
97
-		assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
98
-		initialNavigationOptions.topBarOptions.title = "the title";
99
-		uut.onViewAppeared();
100
-		assertThat(uut.getTopBar().getTitleTextView().getCurrentTextColor()).isNotEqualTo(Color.RED);
94
+    @Test
95
+    public void appliesTopBarTextColor() throws Exception {
96
+        assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
97
+        initialNavigationOptions.topBarOptions.title = "the title";
98
+        uut.onViewAppeared();
99
+        assertThat(uut.getTopBar().getTitleTextView().getCurrentTextColor()).isNotEqualTo(Color.RED);
101 100
 
102
-        NavigationOptions opts = new NavigationOptions();
101
+        Options opts = new Options();
103 102
         opts.topBarOptions.title = "the title";
104 103
         opts.topBarOptions.textColor = Color.RED;
105 104
         uut.mergeNavigationOptions(opts);
@@ -108,14 +107,14 @@ public class OptionsApplyingTest extends BaseTest {
108 107
         assertThat(uut.getTopBar().getTitleTextView().getCurrentTextColor()).isEqualTo(Color.RED);
109 108
     }
110 109
 
111
-	@Test
112
-	public void appliesTopBarTextSize() throws Exception {
113
-		assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
114
-		initialNavigationOptions.topBarOptions.title = "the title";
115
-		uut.onViewAppeared();
116
-		assertThat(uut.getTopBar().getTitleTextView().getTextSize()).isNotEqualTo(18);
110
+    @Test
111
+    public void appliesTopBarTextSize() throws Exception {
112
+        assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
113
+        initialNavigationOptions.topBarOptions.title = "the title";
114
+        uut.onViewAppeared();
115
+        assertThat(uut.getTopBar().getTitleTextView().getTextSize()).isNotEqualTo(18);
117 116
 
118
-        NavigationOptions opts = new NavigationOptions();
117
+        Options opts = new Options();
119 118
         opts.topBarOptions.title = "the title";
120 119
         opts.topBarOptions.textFontSize = 18;
121 120
         uut.mergeNavigationOptions(opts);
@@ -124,15 +123,15 @@ public class OptionsApplyingTest extends BaseTest {
124 123
         assertThat(uut.getTopBar().getTitleTextView().getTextSize()).isEqualTo(18);
125 124
     }
126 125
 
127
-	@Test
128
-	public void appliesTopBarHidden() throws Exception {
129
-		assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
130
-		initialNavigationOptions.topBarOptions.title = "the title";
131
-		uut.onViewAppeared();
132
-		assertThat(uut.getTopBar().getVisibility()).isNotEqualTo(View.GONE);
126
+    @Test
127
+    public void appliesTopBarHidden() throws Exception {
128
+        assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
129
+        initialNavigationOptions.topBarOptions.title = "the title";
130
+        uut.onViewAppeared();
131
+        assertThat(uut.getTopBar().getVisibility()).isNotEqualTo(View.GONE);
133 132
 
134
-        NavigationOptions opts = new NavigationOptions();
135
-        opts.topBarOptions.hidden = NavigationOptions.BooleanOptions.True;
133
+        Options opts = new Options();
134
+        opts.topBarOptions.hidden = Options.BooleanOptions.True;
136 135
         uut.mergeNavigationOptions(opts);
137 136
 
138 137
         assertThat(uut.getTopBar().getVisibility()).isEqualTo(View.GONE);
@@ -142,13 +141,13 @@ public class OptionsApplyingTest extends BaseTest {
142 141
     public void appliesDrawUnder() throws Exception {
143 142
         assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
144 143
         initialNavigationOptions.topBarOptions.title = "the title";
145
-        initialNavigationOptions.topBarOptions.drawBehind = NavigationOptions.BooleanOptions.False;
144
+        initialNavigationOptions.topBarOptions.drawBehind = Options.BooleanOptions.False;
146 145
         uut.onViewAppeared();
147 146
         RelativeLayout.LayoutParams uutLayoutParams = (RelativeLayout.LayoutParams) ((ViewGroup) uut.getComponent().asView()).getChildAt(1).getLayoutParams();
148 147
         assertThat(uutLayoutParams.getRule(BELOW)).isNotEqualTo(0);
149 148
 
150
-        NavigationOptions opts = new NavigationOptions();
151
-        opts.topBarOptions.drawBehind = NavigationOptions.BooleanOptions.True;
149
+        Options opts = new Options();
150
+        opts.topBarOptions.drawBehind = Options.BooleanOptions.True;
152 151
         uut.mergeNavigationOptions(opts);
153 152
 
154 153
         uutLayoutParams = (RelativeLayout.LayoutParams) ((ViewGroup) uut.getComponent().asView()).getChildAt(1).getLayoutParams();

+ 77
- 82
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ParentControllerTest.java Wyświetl plik

@@ -1,92 +1,87 @@
1 1
 package com.reactnativenavigation.viewcontrollers;
2 2
 
3
-import android.app.Activity;
4
-import android.support.annotation.NonNull;
5
-import android.view.ViewGroup;
6
-import android.widget.FrameLayout;
3
+import android.app.*;
4
+import android.support.annotation.*;
5
+import android.view.*;
6
+import android.widget.*;
7 7
 
8
-import com.reactnativenavigation.BaseTest;
9
-import com.reactnativenavigation.mocks.SimpleViewController;
10
-import com.reactnativenavigation.mocks.TestNavigationAnimator;
8
+import com.reactnativenavigation.*;
9
+import com.reactnativenavigation.mocks.*;
11 10
 
12
-import org.junit.Test;
11
+import org.junit.*;
13 12
 
14
-import java.util.ArrayList;
15
-import java.util.Collection;
16
-import java.util.List;
13
+import java.util.*;
17 14
 
18
-import static org.assertj.core.api.Java6Assertions.assertThat;
19
-import static org.mockito.Mockito.spy;
20
-import static org.mockito.Mockito.times;
21
-import static org.mockito.Mockito.verify;
15
+import static org.assertj.core.api.Java6Assertions.*;
16
+import static org.mockito.Mockito.*;
22 17
 
23 18
 public class ParentControllerTest extends BaseTest {
24 19
 
25
-	private Activity activity;
26
-	private List<ViewController> children;
27
-	private ParentController uut;
28
-
29
-	@Override
30
-	public void beforeEach() {
31
-		super.beforeEach();
32
-		activity = newActivity();
33
-		children = new ArrayList<>();
34
-		uut = new ParentController(activity, "uut") {
35
-
36
-			@NonNull
37
-			@Override
38
-			protected ViewGroup createView() {
39
-				return new FrameLayout(activity);
40
-			}
41
-
42
-			@NonNull
43
-			@Override
44
-			public Collection<ViewController> getChildControllers() {
45
-				return children;
46
-			}
47
-		};
48
-	}
49
-
50
-	@Test
51
-	public void holdsViewGroup() throws Exception {
52
-		assertThat(uut.getView()).isInstanceOf(ViewGroup.class);
53
-	}
54
-
55
-	@Test
56
-	public void mustHaveChildControllers() throws Exception {
57
-		assertThat(uut.getChildControllers()).isNotNull();
58
-	}
59
-
60
-	@Test
61
-	public void findControllerById_ChildById() throws Exception {
62
-		SimpleViewController child1 = new SimpleViewController(activity, "child1");
63
-		SimpleViewController child2 = new SimpleViewController(activity, "child2");
64
-		children.add(child1);
65
-		children.add(child2);
66
-
67
-		assertThat(uut.findControllerById("uut")).isEqualTo(uut);
68
-		assertThat(uut.findControllerById("child1")).isEqualTo(child1);
69
-	}
70
-
71
-	@Test
72
-	public void findControllerById_Recursive() throws Exception {
73
-		StackController stackController = new StackController(activity, "stack", new TestNavigationAnimator());
74
-		SimpleViewController child1 = new SimpleViewController(activity, "child1");
75
-		SimpleViewController child2 = new SimpleViewController(activity, "child2");
76
-		stackController.push(child1);
77
-		stackController.push(child2);
78
-		children.add(stackController);
79
-
80
-		assertThat(uut.findControllerById("child2")).isEqualTo(child2);
81
-	}
82
-
83
-	@Test
84
-	public void destroy_DestroysChildren() throws Exception {
85
-		ViewController child1 = spy(new SimpleViewController(activity, "child1"));
86
-		children.add(child1);
87
-
88
-		verify(child1, times(0)).destroy();
89
-		uut.destroy();
90
-		verify(child1, times(1)).destroy();
91
-	}
20
+    private Activity activity;
21
+    private List<ViewController> children;
22
+    private ParentController uut;
23
+
24
+    @Override
25
+    public void beforeEach() {
26
+        super.beforeEach();
27
+        activity = newActivity();
28
+        children = new ArrayList<>();
29
+        uut = new ParentController(activity, "uut") {
30
+
31
+            @NonNull
32
+            @Override
33
+            protected ViewGroup createView() {
34
+                return new FrameLayout(activity);
35
+            }
36
+
37
+            @NonNull
38
+            @Override
39
+            public Collection<ViewController> getChildControllers() {
40
+                return children;
41
+            }
42
+        };
43
+    }
44
+
45
+    @Test
46
+    public void holdsViewGroup() throws Exception {
47
+        assertThat(uut.getView()).isInstanceOf(ViewGroup.class);
48
+    }
49
+
50
+    @Test
51
+    public void mustHaveChildControllers() throws Exception {
52
+        assertThat(uut.getChildControllers()).isNotNull();
53
+    }
54
+
55
+    @Test
56
+    public void findControllerById_ChildById() throws Exception {
57
+        SimpleViewController child1 = new SimpleViewController(activity, "child1");
58
+        SimpleViewController child2 = new SimpleViewController(activity, "child2");
59
+        children.add(child1);
60
+        children.add(child2);
61
+
62
+        assertThat(uut.findControllerById("uut")).isEqualTo(uut);
63
+        assertThat(uut.findControllerById("child1")).isEqualTo(child1);
64
+    }
65
+
66
+    @Test
67
+    public void findControllerById_Recursive() throws Exception {
68
+        StackController stackController = new StackController(activity, "stack", new TestNavigationAnimator());
69
+        SimpleViewController child1 = new SimpleViewController(activity, "child1");
70
+        SimpleViewController child2 = new SimpleViewController(activity, "child2");
71
+        stackController.push(child1);
72
+        stackController.push(child2);
73
+        children.add(stackController);
74
+
75
+        assertThat(uut.findControllerById("child2")).isEqualTo(child2);
76
+    }
77
+
78
+    @Test
79
+    public void destroy_DestroysChildren() throws Exception {
80
+        ViewController child1 = spy(new SimpleViewController(activity, "child1"));
81
+        children.add(child1);
82
+
83
+        verify(child1, times(0)).destroy();
84
+        uut.destroy();
85
+        verify(child1, times(1)).destroy();
86
+    }
92 87
 }

+ 277
- 280
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/StackControllerTest.java Wyświetl plik

@@ -1,289 +1,286 @@
1 1
 package com.reactnativenavigation.viewcontrollers;
2 2
 
3
-import android.app.Activity;
3
+import android.app.*;
4 4
 
5
-import com.reactnativenavigation.BaseTest;
6
-import com.reactnativenavigation.mocks.SimpleViewController;
7
-import com.reactnativenavigation.mocks.TestNavigationAnimator;
5
+import com.reactnativenavigation.*;
6
+import com.reactnativenavigation.mocks.*;
8 7
 
9
-import org.assertj.core.api.iterable.Extractor;
10
-import org.junit.Test;
8
+import org.assertj.core.api.iterable.*;
9
+import org.junit.*;
11 10
 
12
-import static org.assertj.core.api.Java6Assertions.assertThat;
13
-import static org.mockito.Mockito.spy;
14
-import static org.mockito.Mockito.times;
15
-import static org.mockito.Mockito.verify;
11
+import static org.assertj.core.api.Java6Assertions.*;
12
+import static org.mockito.Mockito.*;
16 13
 
17 14
 public class StackControllerTest extends BaseTest {
18 15
 
19
-	private Activity activity;
20
-	private StackController uut;
21
-	private ViewController child1;
22
-	private ViewController child2;
23
-	private ViewController child3;
24
-
25
-	@Override
26
-	public void beforeEach() {
27
-		super.beforeEach();
28
-		activity = newActivity();
29
-		uut = new StackController(activity, "uut", new TestNavigationAnimator());
30
-		child1 = new SimpleViewController(activity, "child1");
31
-		child2 = new SimpleViewController(activity, "child2");
32
-		child3 = new SimpleViewController(activity, "child3");
33
-	}
34
-
35
-	@Test
36
-	public void isAViewController() throws Exception {
37
-		assertThat(uut).isInstanceOf(ViewController.class);
38
-	}
39
-
40
-	@Test
41
-	public void holdsAStackOfViewControllers() throws Exception {
42
-		assertThat(uut.isEmpty()).isTrue();
43
-		uut.push(child1);
44
-		uut.push(child2);
45
-		uut.push(child3);
46
-		assertThat(uut.peek()).isEqualTo(child3);
47
-		assertContainsOnlyId(child1.getId(), child2.getId(), child3.getId());
48
-	}
49
-
50
-	@Test
51
-	public void push() throws Exception {
52
-		assertThat(uut.isEmpty()).isTrue();
53
-		uut.push(child1);
54
-		assertContainsOnlyId(child1.getId());
55
-	}
56
-
57
-	@Test
58
-	public void pop() throws Exception {
59
-		uut.push(child1);
60
-		uut.push(child2);
61
-		assertContainsOnlyId(child2.getId(), child1.getId());
62
-		uut.pop();
63
-		assertContainsOnlyId(child1.getId());
64
-	}
65
-
66
-	@Test
67
-	public void stackOperations() throws Exception {
68
-		assertThat(uut.peek()).isNull();
69
-		assertThat(uut.size()).isZero();
70
-		assertThat(uut.isEmpty()).isTrue();
71
-		uut.push(child1);
72
-		assertThat(uut.peek()).isEqualTo(child1);
73
-		assertThat(uut.size()).isEqualTo(1);
74
-		assertThat(uut.isEmpty()).isFalse();
75
-	}
76
-
77
-	@Test
78
-	public void pushAssignsRefToSelfOnPushedController() throws Exception {
79
-		assertThat(child1.getParentStackController()).isNull();
80
-		uut.push(child1);
81
-		assertThat(child1.getParentStackController()).isEqualTo(uut);
82
-
83
-		StackController anotherNavController = new StackController(activity, "another", new TestNavigationAnimator());
84
-		anotherNavController.push(child2);
85
-		assertThat(child2.getParentStackController()).isEqualTo(anotherNavController);
86
-	}
87
-
88
-	@Test
89
-	public void handleBack_PopsUnlessSingleChild() throws Exception {
90
-		assertThat(uut.isEmpty()).isTrue();
91
-		assertThat(uut.handleBack()).isFalse();
92
-
93
-		uut.push(child1);
94
-		assertThat(uut.size()).isEqualTo(1);
95
-		assertThat(uut.handleBack()).isFalse();
96
-
97
-		uut.push(child2);
98
-		assertThat(uut.size()).isEqualTo(2);
99
-		assertThat(uut.handleBack()).isTrue();
100
-		assertThat(uut.size()).isEqualTo(1);
101
-		assertThat(uut.handleBack()).isFalse();
102
-	}
103
-
104
-	@Test
105
-	public void popDoesNothingWhenZeroOrOneChild() throws Exception {
106
-		assertThat(uut.isEmpty()).isTrue();
107
-		uut.pop();
108
-		assertThat(uut.isEmpty()).isTrue();
109
-
110
-		uut.push(child1);
111
-		uut.pop();
112
-		assertContainsOnlyId(child1.getId());
113
-	}
114
-
115
-	@Test
116
-	public void canPopWhenSizeIsMoreThanOne() throws Exception {
117
-		assertThat(uut.isEmpty()).isTrue();
118
-		assertThat(uut.canPop()).isFalse();
119
-		uut.push(child1);
120
-		assertContainsOnlyId(child1.getId());
121
-		assertThat(uut.canPop()).isFalse();
122
-		uut.push(child2);
123
-		assertContainsOnlyId(child1.getId(), child2.getId());
124
-		assertThat(uut.canPop()).isTrue();
125
-	}
126
-
127
-	@Test
128
-	public void pushAddsToViewTree() throws Exception {
129
-		assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
130
-		uut.push(child1);
131
-		assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
132
-	}
133
-
134
-	@Test
135
-	public void pushRemovesPreviousFromTree() throws Exception {
136
-		assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
137
-		uut.push(child1);
138
-		assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
139
-		uut.push(child2);
140
-		assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
141
-		assertThat(uut.getView().findViewById(child2.getView().getId())).isNotNull();
142
-	}
143
-
144
-	@Test
145
-	public void popReplacesViewWithPrevious() throws Exception {
146
-		uut.push(child1);
147
-		uut.push(child2);
148
-		assertIsChildById(uut.getView(), child2.getView());
149
-		assertNotChildOf(uut.getView(), child1.getView());
150
-		uut.pop();
151
-		assertNotChildOf(uut.getView(), child2.getView());
152
-		assertIsChildById(uut.getView(), child1.getView());
153
-	}
154
-
155
-	@Test
156
-	public void popSpecificWhenTopIsRegularPop() throws Exception {
157
-		uut.push(child1);
158
-		uut.push(child2);
159
-		uut.popSpecific(child2);
160
-		assertContainsOnlyId(child1.getId());
161
-		assertIsChildById(uut.getView(), child1.getView());
162
-	}
163
-
164
-	@Test
165
-	public void popSpecificDeepInStack() throws Exception {
166
-		uut.push(child1);
167
-		uut.push(child2);
168
-		assertIsChildById(uut.getView(), child2.getView());
169
-		uut.popSpecific(child1);
170
-		assertContainsOnlyId(child2.getId());
171
-		assertIsChildById(uut.getView(), child2.getView());
172
-	}
173
-
174
-	@Test
175
-	public void popTo_PopsTopUntilControllerIsNewTop() throws Exception {
176
-		uut.push(child1);
177
-		uut.push(child2);
178
-		uut.push(child3);
179
-
180
-		assertThat(uut.size()).isEqualTo(3);
181
-		assertThat(uut.peek()).isEqualTo(child3);
182
-
183
-		uut.popTo(child1);
184
-
185
-		assertThat(uut.size()).isEqualTo(1);
186
-		assertThat(uut.peek()).isEqualTo(child1);
187
-	}
188
-
189
-	@Test
190
-	public void popTo_NotAChildOfThisStack_DoesNothing() throws Exception {
191
-		uut.push(child1);
192
-		uut.push(child3);
193
-		assertThat(uut.size()).isEqualTo(2);
194
-		uut.popTo(child2);
195
-		assertThat(uut.size()).isEqualTo(2);
196
-	}
197
-
198
-	@Test
199
-	public void popToRoot_PopsEverythingAboveFirstController() throws Exception {
200
-		uut.push(child1);
201
-		uut.push(child2);
202
-		uut.push(child3);
203
-
204
-		assertThat(uut.size()).isEqualTo(3);
205
-		assertThat(uut.peek()).isEqualTo(child3);
206
-
207
-		uut.popToRoot();
208
-
209
-		assertThat(uut.size()).isEqualTo(1);
210
-		assertThat(uut.peek()).isEqualTo(child1);
211
-	}
212
-
213
-	@Test
214
-	public void popToRoot_EmptyStackDoesNothing() throws Exception {
215
-		assertThat(uut.isEmpty()).isTrue();
216
-		uut.popToRoot();
217
-		assertThat(uut.isEmpty()).isTrue();
218
-	}
219
-
220
-	@Test
221
-	public void findControllerById_ReturnsSelfOrChildrenById() throws Exception {
222
-		assertThat(uut.findControllerById("123")).isNull();
223
-		assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
224
-		uut.push(child1);
225
-		assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);
226
-	}
227
-
228
-	@Test
229
-	public void findControllerById_Deeply() throws Exception {
230
-		StackController stack = new StackController(activity, "stack2", new TestNavigationAnimator());
231
-		stack.push(child2);
232
-		uut.push(stack);
233
-		assertThat(uut.findControllerById(child2.getId())).isEqualTo(child2);
234
-	}
235
-
236
-	@Test
237
-	public void pop_CallsDestroyOnPoppedChild() throws Exception {
238
-		child1 = spy(child1);
239
-		child2 = spy(child2);
240
-		child3 = spy(child3);
241
-		uut.push(child1);
242
-		uut.push(child2);
243
-		uut.push(child3);
244
-
245
-		verify(child3, times(0)).destroy();
246
-		uut.pop();
247
-		verify(child3, times(1)).destroy();
248
-	}
249
-
250
-	@Test
251
-	public void popSpecific_CallsDestroyOnPoppedChild() throws Exception {
252
-		child1 = spy(child1);
253
-		child2 = spy(child2);
254
-		child3 = spy(child3);
255
-		uut.push(child1);
256
-		uut.push(child2);
257
-		uut.push(child3);
258
-
259
-		verify(child2, times(0)).destroy();
260
-		uut.popSpecific(child2);
261
-		verify(child2, times(1)).destroy();
262
-	}
263
-
264
-	@Test
265
-	public void popTo_CallsDestroyOnPoppedChild() throws Exception {
266
-		child1 = spy(child1);
267
-		child2 = spy(child2);
268
-		child3 = spy(child3);
269
-		uut.push(child1);
270
-		uut.push(child2);
271
-		uut.push(child3);
272
-
273
-		verify(child2, times(0)).destroy();
274
-		verify(child3, times(0)).destroy();
275
-		uut.popTo(child1);
276
-		verify(child2, times(1)).destroy();
277
-		verify(child3, times(1)).destroy();
278
-	}
279
-
280
-	private void assertContainsOnlyId(String... ids) {
281
-		assertThat(uut.size()).isEqualTo(ids.length);
282
-		assertThat(uut.getChildControllers()).extracting(new Extractor<ViewController, String>() {
283
-			@Override
284
-			public String extract(final ViewController input) {
285
-				return input.getId();
286
-			}
287
-		}).containsOnly(ids);
288
-	}
16
+    private Activity activity;
17
+    private StackController uut;
18
+    private ViewController child1;
19
+    private ViewController child2;
20
+    private ViewController child3;
21
+
22
+    @Override
23
+    public void beforeEach() {
24
+        super.beforeEach();
25
+        activity = newActivity();
26
+        uut = new StackController(activity, "uut", new TestNavigationAnimator());
27
+        child1 = new SimpleViewController(activity, "child1");
28
+        child2 = new SimpleViewController(activity, "child2");
29
+        child3 = new SimpleViewController(activity, "child3");
30
+    }
31
+
32
+    @Test
33
+    public void isAViewController() throws Exception {
34
+        assertThat(uut).isInstanceOf(ViewController.class);
35
+    }
36
+
37
+    @Test
38
+    public void holdsAStackOfViewControllers() throws Exception {
39
+        assertThat(uut.isEmpty()).isTrue();
40
+        uut.push(child1);
41
+        uut.push(child2);
42
+        uut.push(child3);
43
+        assertThat(uut.peek()).isEqualTo(child3);
44
+        assertContainsOnlyId(child1.getId(), child2.getId(), child3.getId());
45
+    }
46
+
47
+    @Test
48
+    public void push() throws Exception {
49
+        assertThat(uut.isEmpty()).isTrue();
50
+        uut.push(child1);
51
+        assertContainsOnlyId(child1.getId());
52
+    }
53
+
54
+    @Test
55
+    public void pop() throws Exception {
56
+        uut.push(child1);
57
+        uut.push(child2);
58
+        assertContainsOnlyId(child2.getId(), child1.getId());
59
+        uut.pop();
60
+        assertContainsOnlyId(child1.getId());
61
+    }
62
+
63
+    @Test
64
+    public void stackOperations() throws Exception {
65
+        assertThat(uut.peek()).isNull();
66
+        assertThat(uut.size()).isZero();
67
+        assertThat(uut.isEmpty()).isTrue();
68
+        uut.push(child1);
69
+        assertThat(uut.peek()).isEqualTo(child1);
70
+        assertThat(uut.size()).isEqualTo(1);
71
+        assertThat(uut.isEmpty()).isFalse();
72
+    }
73
+
74
+    @Test
75
+    public void pushAssignsRefToSelfOnPushedController() throws Exception {
76
+        assertThat(child1.getParentStackController()).isNull();
77
+        uut.push(child1);
78
+        assertThat(child1.getParentStackController()).isEqualTo(uut);
79
+
80
+        StackController anotherNavController = new StackController(activity, "another", new TestNavigationAnimator());
81
+        anotherNavController.push(child2);
82
+        assertThat(child2.getParentStackController()).isEqualTo(anotherNavController);
83
+    }
84
+
85
+    @Test
86
+    public void handleBack_PopsUnlessSingleChild() throws Exception {
87
+        assertThat(uut.isEmpty()).isTrue();
88
+        assertThat(uut.handleBack()).isFalse();
89
+
90
+        uut.push(child1);
91
+        assertThat(uut.size()).isEqualTo(1);
92
+        assertThat(uut.handleBack()).isFalse();
93
+
94
+        uut.push(child2);
95
+        assertThat(uut.size()).isEqualTo(2);
96
+        assertThat(uut.handleBack()).isTrue();
97
+        assertThat(uut.size()).isEqualTo(1);
98
+        assertThat(uut.handleBack()).isFalse();
99
+    }
100
+
101
+    @Test
102
+    public void popDoesNothingWhenZeroOrOneChild() throws Exception {
103
+        assertThat(uut.isEmpty()).isTrue();
104
+        uut.pop();
105
+        assertThat(uut.isEmpty()).isTrue();
106
+
107
+        uut.push(child1);
108
+        uut.pop();
109
+        assertContainsOnlyId(child1.getId());
110
+    }
111
+
112
+    @Test
113
+    public void canPopWhenSizeIsMoreThanOne() throws Exception {
114
+        assertThat(uut.isEmpty()).isTrue();
115
+        assertThat(uut.canPop()).isFalse();
116
+        uut.push(child1);
117
+        assertContainsOnlyId(child1.getId());
118
+        assertThat(uut.canPop()).isFalse();
119
+        uut.push(child2);
120
+        assertContainsOnlyId(child1.getId(), child2.getId());
121
+        assertThat(uut.canPop()).isTrue();
122
+    }
123
+
124
+    @Test
125
+    public void pushAddsToViewTree() throws Exception {
126
+        assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
127
+        uut.push(child1);
128
+        assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
129
+    }
130
+
131
+    @Test
132
+    public void pushRemovesPreviousFromTree() throws Exception {
133
+        assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
134
+        uut.push(child1);
135
+        assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
136
+        uut.push(child2);
137
+        assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
138
+        assertThat(uut.getView().findViewById(child2.getView().getId())).isNotNull();
139
+    }
140
+
141
+    @Test
142
+    public void popReplacesViewWithPrevious() throws Exception {
143
+        uut.push(child1);
144
+        uut.push(child2);
145
+        assertIsChildById(uut.getView(), child2.getView());
146
+        assertNotChildOf(uut.getView(), child1.getView());
147
+        uut.pop();
148
+        assertNotChildOf(uut.getView(), child2.getView());
149
+        assertIsChildById(uut.getView(), child1.getView());
150
+    }
151
+
152
+    @Test
153
+    public void popSpecificWhenTopIsRegularPop() throws Exception {
154
+        uut.push(child1);
155
+        uut.push(child2);
156
+        uut.popSpecific(child2);
157
+        assertContainsOnlyId(child1.getId());
158
+        assertIsChildById(uut.getView(), child1.getView());
159
+    }
160
+
161
+    @Test
162
+    public void popSpecificDeepInStack() throws Exception {
163
+        uut.push(child1);
164
+        uut.push(child2);
165
+        assertIsChildById(uut.getView(), child2.getView());
166
+        uut.popSpecific(child1);
167
+        assertContainsOnlyId(child2.getId());
168
+        assertIsChildById(uut.getView(), child2.getView());
169
+    }
170
+
171
+    @Test
172
+    public void popTo_PopsTopUntilControllerIsNewTop() throws Exception {
173
+        uut.push(child1);
174
+        uut.push(child2);
175
+        uut.push(child3);
176
+
177
+        assertThat(uut.size()).isEqualTo(3);
178
+        assertThat(uut.peek()).isEqualTo(child3);
179
+
180
+        uut.popTo(child1);
181
+
182
+        assertThat(uut.size()).isEqualTo(1);
183
+        assertThat(uut.peek()).isEqualTo(child1);
184
+    }
185
+
186
+    @Test
187
+    public void popTo_NotAChildOfThisStack_DoesNothing() throws Exception {
188
+        uut.push(child1);
189
+        uut.push(child3);
190
+        assertThat(uut.size()).isEqualTo(2);
191
+        uut.popTo(child2);
192
+        assertThat(uut.size()).isEqualTo(2);
193
+    }
194
+
195
+    @Test
196
+    public void popToRoot_PopsEverythingAboveFirstController() throws Exception {
197
+        uut.push(child1);
198
+        uut.push(child2);
199
+        uut.push(child3);
200
+
201
+        assertThat(uut.size()).isEqualTo(3);
202
+        assertThat(uut.peek()).isEqualTo(child3);
203
+
204
+        uut.popToRoot();
205
+
206
+        assertThat(uut.size()).isEqualTo(1);
207
+        assertThat(uut.peek()).isEqualTo(child1);
208
+    }
209
+
210
+    @Test
211
+    public void popToRoot_EmptyStackDoesNothing() throws Exception {
212
+        assertThat(uut.isEmpty()).isTrue();
213
+        uut.popToRoot();
214
+        assertThat(uut.isEmpty()).isTrue();
215
+    }
216
+
217
+    @Test
218
+    public void findControllerById_ReturnsSelfOrChildrenById() throws Exception {
219
+        assertThat(uut.findControllerById("123")).isNull();
220
+        assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
221
+        uut.push(child1);
222
+        assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);
223
+    }
224
+
225
+    @Test
226
+    public void findControllerById_Deeply() throws Exception {
227
+        StackController stack = new StackController(activity, "stack2", new TestNavigationAnimator());
228
+        stack.push(child2);
229
+        uut.push(stack);
230
+        assertThat(uut.findControllerById(child2.getId())).isEqualTo(child2);
231
+    }
232
+
233
+    @Test
234
+    public void pop_CallsDestroyOnPoppedChild() throws Exception {
235
+        child1 = spy(child1);
236
+        child2 = spy(child2);
237
+        child3 = spy(child3);
238
+        uut.push(child1);
239
+        uut.push(child2);
240
+        uut.push(child3);
241
+
242
+        verify(child3, times(0)).destroy();
243
+        uut.pop();
244
+        verify(child3, times(1)).destroy();
245
+    }
246
+
247
+    @Test
248
+    public void popSpecific_CallsDestroyOnPoppedChild() throws Exception {
249
+        child1 = spy(child1);
250
+        child2 = spy(child2);
251
+        child3 = spy(child3);
252
+        uut.push(child1);
253
+        uut.push(child2);
254
+        uut.push(child3);
255
+
256
+        verify(child2, times(0)).destroy();
257
+        uut.popSpecific(child2);
258
+        verify(child2, times(1)).destroy();
259
+    }
260
+
261
+    @Test
262
+    public void popTo_CallsDestroyOnPoppedChild() throws Exception {
263
+        child1 = spy(child1);
264
+        child2 = spy(child2);
265
+        child3 = spy(child3);
266
+        uut.push(child1);
267
+        uut.push(child2);
268
+        uut.push(child3);
269
+
270
+        verify(child2, times(0)).destroy();
271
+        verify(child3, times(0)).destroy();
272
+        uut.popTo(child1);
273
+        verify(child2, times(1)).destroy();
274
+        verify(child3, times(1)).destroy();
275
+    }
276
+
277
+    private void assertContainsOnlyId(String... ids) {
278
+        assertThat(uut.size()).isEqualTo(ids.length);
279
+        assertThat(uut.getChildControllers()).extracting(new Extractor<ViewController, String>() {
280
+            @Override
281
+            public String extract(final ViewController input) {
282
+                return input.getId();
283
+            }
284
+        }).containsOnly(ids);
285
+    }
289 286
 }

+ 10
- 12
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabControllerTest.java Wyświetl plik

@@ -1,30 +1,28 @@
1 1
 package com.reactnativenavigation.viewcontrollers;
2 2
 
3
-import android.app.Activity;
3
+import android.app.*;
4 4
 
5
-import com.reactnativenavigation.BaseTest;
6
-import com.reactnativenavigation.mocks.TopTabLayoutMock;
7
-import com.reactnativenavigation.parse.NavigationOptions;
8
-import com.reactnativenavigation.viewcontrollers.toptabs.TopTabController;
5
+import com.reactnativenavigation.*;
6
+import com.reactnativenavigation.mocks.*;
7
+import com.reactnativenavigation.parse.*;
8
+import com.reactnativenavigation.viewcontrollers.toptabs.*;
9 9
 
10
-import org.junit.Test;
10
+import org.junit.*;
11 11
 
12
-import static org.mockito.Mockito.spy;
13
-import static org.mockito.Mockito.times;
14
-import static org.mockito.Mockito.verify;
12
+import static org.mockito.Mockito.*;
15 13
 
16 14
 public class TopTabControllerTest extends BaseTest {
17 15
     private TopTabController uut;
18 16
     private TopTabLayoutMock view;
19 17
     private ParentController parentController;
20
-    private NavigationOptions initialOptions;
18
+    private Options initialOptions;
21 19
 
22 20
     @Override
23 21
     public void beforeEach() {
24 22
         super.beforeEach();
25 23
         Activity activity = newActivity();
26 24
         view = spy(new TopTabLayoutMock(activity));
27
-        initialOptions = new NavigationOptions();
25
+        initialOptions = new Options();
28 26
         uut = new TopTabController(activity,
29 27
                 "componentId",
30 28
                 "componentName",
@@ -46,7 +44,7 @@ public class TopTabControllerTest extends BaseTest {
46 44
     public void styleIsAppliedOnParentControllerWhenOptionsAreSetDynamically() throws Exception {
47 45
         uut.ensureViewIsCreated();
48 46
         uut.onViewAppeared();
49
-        uut.mergeNavigationOptions(new NavigationOptions());
47
+        uut.mergeNavigationOptions(new Options());
50 48
         verify(parentController, times(2)).applyOptions(initialOptions);
51 49
     }
52 50
 

+ 4
- 4
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsControllerMock.java Wyświetl plik

@@ -1,10 +1,10 @@
1 1
 package com.reactnativenavigation.viewcontrollers;
2 2
 
3
-import android.app.Activity;
4
-import android.support.annotation.NonNull;
5
-import android.view.ViewGroup;
3
+import android.app.*;
4
+import android.support.annotation.*;
5
+import android.view.*;
6 6
 
7
-import java.util.Collection;
7
+import java.util.*;
8 8
 
9 9
 public class TopTabsControllerMock extends ParentController {
10 10
     TopTabsControllerMock(Activity activity, String id) {

+ 16
- 22
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsViewControllerTest.java Wyświetl plik

@@ -1,27 +1,21 @@
1 1
 package com.reactnativenavigation.viewcontrollers;
2 2
 
3
-import android.app.Activity;
4
-import android.view.ViewGroup;
3
+import android.app.*;
4
+import android.view.*;
5 5
 
6
-import com.reactnativenavigation.BaseTest;
7
-import com.reactnativenavigation.mocks.TopTabLayoutMock;
8
-import com.reactnativenavigation.parse.NavigationOptions;
9
-import com.reactnativenavigation.viewcontrollers.ComponentViewController.IReactView;
10
-import com.reactnativenavigation.viewcontrollers.toptabs.TopTabController;
11
-import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsAdapter;
12
-import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;
13
-import com.reactnativenavigation.views.TopTabsLayout;
14
-import com.reactnativenavigation.views.TopTabsLayoutCreator;
6
+import com.reactnativenavigation.*;
7
+import com.reactnativenavigation.mocks.*;
8
+import com.reactnativenavigation.parse.*;
9
+import com.reactnativenavigation.viewcontrollers.ComponentViewController.*;
10
+import com.reactnativenavigation.viewcontrollers.toptabs.*;
11
+import com.reactnativenavigation.views.*;
15 12
 
16
-import org.junit.Test;
17
-import org.mockito.Mockito;
13
+import org.junit.*;
14
+import org.mockito.*;
18 15
 
19
-import java.util.ArrayList;
20
-import java.util.List;
16
+import java.util.*;
21 17
 
22
-import static org.mockito.Mockito.spy;
23
-import static org.mockito.Mockito.times;
24
-import static org.mockito.Mockito.verify;
18
+import static org.mockito.Mockito.*;
25 19
 
26 20
 public class TopTabsViewControllerTest extends BaseTest {
27 21
 
@@ -30,8 +24,8 @@ public class TopTabsViewControllerTest extends BaseTest {
30 24
     private TopTabsController uut;
31 25
     private List<TopTabLayoutMock> tabs = new ArrayList<>(SIZE);
32 26
     private List<TopTabController> tabControllers = new ArrayList<>(SIZE);
33
-    private List<NavigationOptions> tabOptions = new ArrayList<>(SIZE);
34
-    private NavigationOptions options;
27
+    private List<Options> tabOptions = new ArrayList<>(SIZE);
28
+    private Options options;
35 29
     private TopTabsLayout topTabsLayout;
36 30
 
37 31
     @Override
@@ -41,7 +35,7 @@ public class TopTabsViewControllerTest extends BaseTest {
41 35
         tabs.clear();
42 36
         Activity activity = newActivity();
43 37
         createTabs(activity);
44
-        options = new NavigationOptions();
38
+        options = new Options();
45 39
         topTabsLayout = spy(new TopTabsLayout(activity, tabControllers, new TopTabsAdapter(tabControllers)));
46 40
 
47 41
         TopTabsLayoutCreator layoutCreator = Mockito.mock(TopTabsLayoutCreator.class);
@@ -53,7 +47,7 @@ public class TopTabsViewControllerTest extends BaseTest {
53 47
         for (int i = 0; i < SIZE; i++) {
54 48
             TopTabLayoutMock reactView = spy(new TopTabLayoutMock(activity));
55 49
             tabs.add(reactView);
56
-            tabOptions.add(new NavigationOptions());
50
+            tabOptions.add(new Options());
57 51
             tabControllers.add(spy(new TopTabController(activity,
58 52
                     "idTab" + i,
59 53
                     "tab" + i,

+ 182
- 186
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java Wyświetl plik

@@ -1,197 +1,193 @@
1 1
 package com.reactnativenavigation.viewcontrollers;
2 2
 
3
-import android.app.Activity;
4
-import android.view.View;
5
-import android.view.ViewParent;
6
-import android.widget.LinearLayout;
3
+import android.app.*;
4
+import android.view.*;
5
+import android.widget.*;
7 6
 
8
-import com.reactnativenavigation.BaseTest;
9
-import com.reactnativenavigation.mocks.SimpleViewController;
7
+import com.reactnativenavigation.*;
8
+import com.reactnativenavigation.mocks.*;
10 9
 
11
-import org.assertj.android.api.Assertions;
12
-import org.junit.Test;
13
-import org.robolectric.Shadows;
10
+import org.assertj.android.api.*;
11
+import org.junit.*;
12
+import org.robolectric.*;
14 13
 
15
-import java.lang.reflect.Field;
14
+import java.lang.reflect.*;
16 15
 
17
-import static org.assertj.core.api.Java6Assertions.assertThat;
18
-import static org.mockito.Mockito.mock;
19
-import static org.mockito.Mockito.spy;
20
-import static org.mockito.Mockito.times;
21
-import static org.mockito.Mockito.verify;
16
+import static org.assertj.core.api.Java6Assertions.*;
17
+import static org.mockito.Mockito.*;
22 18
 
23 19
 public class ViewControllerTest extends BaseTest {
24 20
 
25
-	private ViewController uut;
26
-	private Activity activity;
27
-
28
-	@Override
29
-	public void beforeEach() {
30
-		super.beforeEach();
31
-		activity = newActivity();
32
-		uut = new SimpleViewController(activity, "uut");
33
-	}
34
-
35
-	@Test
36
-	public void holdsAView() throws Exception {
37
-		assertThat(uut.getView()).isNotNull().isInstanceOf(View.class);
38
-	}
39
-
40
-	@Test
41
-	public void holdsARefToActivity() throws Exception {
42
-		assertThat(uut.getActivity()).isNotNull().isEqualTo(activity);
43
-	}
44
-
45
-	@Test
46
-	public void canOverrideViewCreation() throws Exception {
47
-		final View otherView = new View(activity);
48
-		ViewController myController = new ViewController(activity, "vc") {
49
-			@Override
50
-			protected View createView() {
51
-				return otherView;
52
-			}
53
-		};
54
-		assertThat(myController.getView()).isEqualTo(otherView);
55
-	}
56
-
57
-	@Test
58
-	public void holdsAReferenceToStackControllerOrNull() throws Exception {
59
-		assertThat(uut.getParentStackController()).isNull();
60
-		StackController nav = new StackController(activity, "stack");
61
-		nav.push(uut);
62
-		assertThat(uut.getParentStackController()).isEqualTo(nav);
63
-	}
64
-
65
-	@Test
66
-	public void handleBackDefaultFalse() throws Exception {
67
-		assertThat(uut.handleBack()).isFalse();
68
-	}
69
-
70
-	@Test
71
-	public void holdsId() throws Exception {
72
-		assertThat(uut.getId()).isEqualTo("uut");
73
-	}
74
-
75
-	@Test
76
-	public void isSameId() throws Exception {
77
-		assertThat(uut.isSameId("")).isFalse();
78
-		assertThat(uut.isSameId(null)).isFalse();
79
-		assertThat(uut.isSameId("uut")).isTrue();
80
-	}
81
-
82
-	@Test
83
-	public void findControllerById_SelfOrNull() throws Exception {
84
-		assertThat(uut.findControllerById("456")).isNull();
85
-		assertThat(uut.findControllerById("uut")).isEqualTo(uut);
86
-	}
87
-
88
-	@Test
89
-	public void onAppear_WhenShown() throws Exception {
90
-		ViewController spy = spy(uut);
91
-		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
92
-		Assertions.assertThat(spy.getView()).isNotShown();
93
-		verify(spy, times(0)).onViewAppeared();
94
-
95
-		Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
96
-		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
97
-		Assertions.assertThat(spy.getView()).isShown();
98
-
99
-		verify(spy, times(1)).onViewAppeared();
100
-	}
101
-
102
-	@Test
103
-	public void onAppear_CalledAtMostOnce() throws Exception {
104
-		ViewController spy = spy(uut);
105
-		Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
106
-		Assertions.assertThat(spy.getView()).isShown();
107
-		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
108
-		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
109
-		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
110
-
111
-		verify(spy, times(1)).onViewAppeared();
112
-	}
113
-
114
-	@Test
115
-	public void onDisappear_WhenNotShown_AfterOnAppearWasCalled() throws Exception {
116
-		ViewController spy = spy(uut);
117
-		Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
118
-		Assertions.assertThat(spy.getView()).isShown();
119
-		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
120
-		verify(spy, times(1)).onViewAppeared();
121
-		verify(spy, times(0)).onViewDisappear();
122
-
123
-		spy.getView().setVisibility(View.GONE);
124
-		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
125
-		Assertions.assertThat(spy.getView()).isNotShown();
126
-		verify(spy, times(1)).onViewDisappear();
127
-	}
128
-
129
-	@Test
130
-	public void onDisappear_CalledAtMostOnce() throws Exception {
131
-		ViewController spy = spy(uut);
132
-		Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
133
-		Assertions.assertThat(spy.getView()).isShown();
134
-		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
135
-		spy.getView().setVisibility(View.GONE);
136
-		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
137
-		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
138
-		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
139
-		verify(spy, times(1)).onViewDisappear();
140
-	}
141
-
142
-	@Test
143
-	public void onDestroy_RemovesGlobalLayoutListener() throws Exception {
144
-		new SimpleViewController(activity, "ensureNotNull").destroy();
145
-
146
-		ViewController spy = spy(uut);
147
-		View view = spy.getView();
148
-		Shadows.shadowOf(view).setMyParent(mock(ViewParent.class));
149
-
150
-		spy.destroy();
151
-
152
-		Assertions.assertThat(view).isShown();
153
-		view.getViewTreeObserver().dispatchOnGlobalLayout();
154
-		verify(spy, times(0)).onViewAppeared();
155
-		verify(spy, times(0)).onViewDisappear();
156
-
157
-		Field field = ViewController.class.getDeclaredField("view");
158
-		field.setAccessible(true);
159
-		assertThat(field.get(spy)).isNull();
160
-	}
161
-
162
-	@Test
163
-	public void onDestroy_CallsOnDisappearIfNeeded() throws Exception {
164
-		ViewController spy = spy(uut);
165
-		Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
166
-		Assertions.assertThat(spy.getView()).isShown();
167
-		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
168
-		verify(spy, times(1)).onViewAppeared();
169
-
170
-		spy.destroy();
171
-
172
-		verify(spy, times(1)).onViewDisappear();
173
-	}
174
-
175
-	@Test
176
-	public void assignsIdToCreatedView() throws Exception {
177
-		assertThat(uut.getView().getId()).isPositive();
178
-	}
179
-
180
-	@Test
181
-	public void onDestroy_RemovesSelfFromParentIfExists() throws Exception {
182
-		LinearLayout parent = new LinearLayout(activity);
183
-		parent.addView(uut.getView());
184
-
185
-		uut.destroy();
186
-		assertThat(parent.getChildCount()).withFailMessage("expected not to have children").isZero();
187
-	}
188
-
189
-	@Test
190
-	public void ensureViewIsCreated() throws Exception {
191
-		ViewController spy = spy(uut);
192
-		verify(spy, times(0)).getView();
193
-		spy.ensureViewIsCreated();
194
-		verify(spy, times(1)).getView();
195
-	}
21
+    private ViewController uut;
22
+    private Activity activity;
23
+
24
+    @Override
25
+    public void beforeEach() {
26
+        super.beforeEach();
27
+        activity = newActivity();
28
+        uut = new SimpleViewController(activity, "uut");
29
+    }
30
+
31
+    @Test
32
+    public void holdsAView() throws Exception {
33
+        assertThat(uut.getView()).isNotNull().isInstanceOf(View.class);
34
+    }
35
+
36
+    @Test
37
+    public void holdsARefToActivity() throws Exception {
38
+        assertThat(uut.getActivity()).isNotNull().isEqualTo(activity);
39
+    }
40
+
41
+    @Test
42
+    public void canOverrideViewCreation() throws Exception {
43
+        final View otherView = new View(activity);
44
+        ViewController myController = new ViewController(activity, "vc") {
45
+            @Override
46
+            protected View createView() {
47
+                return otherView;
48
+            }
49
+        };
50
+        assertThat(myController.getView()).isEqualTo(otherView);
51
+    }
52
+
53
+    @Test
54
+    public void holdsAReferenceToStackControllerOrNull() throws Exception {
55
+        assertThat(uut.getParentStackController()).isNull();
56
+        StackController nav = new StackController(activity, "stack");
57
+        nav.push(uut);
58
+        assertThat(uut.getParentStackController()).isEqualTo(nav);
59
+    }
60
+
61
+    @Test
62
+    public void handleBackDefaultFalse() throws Exception {
63
+        assertThat(uut.handleBack()).isFalse();
64
+    }
65
+
66
+    @Test
67
+    public void holdsId() throws Exception {
68
+        assertThat(uut.getId()).isEqualTo("uut");
69
+    }
70
+
71
+    @Test
72
+    public void isSameId() throws Exception {
73
+        assertThat(uut.isSameId("")).isFalse();
74
+        assertThat(uut.isSameId(null)).isFalse();
75
+        assertThat(uut.isSameId("uut")).isTrue();
76
+    }
77
+
78
+    @Test
79
+    public void findControllerById_SelfOrNull() throws Exception {
80
+        assertThat(uut.findControllerById("456")).isNull();
81
+        assertThat(uut.findControllerById("uut")).isEqualTo(uut);
82
+    }
83
+
84
+    @Test
85
+    public void onAppear_WhenShown() throws Exception {
86
+        ViewController spy = spy(uut);
87
+        spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
88
+        Assertions.assertThat(spy.getView()).isNotShown();
89
+        verify(spy, times(0)).onViewAppeared();
90
+
91
+        Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
92
+        spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
93
+        Assertions.assertThat(spy.getView()).isShown();
94
+
95
+        verify(spy, times(1)).onViewAppeared();
96
+    }
97
+
98
+    @Test
99
+    public void onAppear_CalledAtMostOnce() throws Exception {
100
+        ViewController spy = spy(uut);
101
+        Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
102
+        Assertions.assertThat(spy.getView()).isShown();
103
+        spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
104
+        spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
105
+        spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
106
+
107
+        verify(spy, times(1)).onViewAppeared();
108
+    }
109
+
110
+    @Test
111
+    public void onDisappear_WhenNotShown_AfterOnAppearWasCalled() throws Exception {
112
+        ViewController spy = spy(uut);
113
+        Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
114
+        Assertions.assertThat(spy.getView()).isShown();
115
+        spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
116
+        verify(spy, times(1)).onViewAppeared();
117
+        verify(spy, times(0)).onViewDisappear();
118
+
119
+        spy.getView().setVisibility(View.GONE);
120
+        spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
121
+        Assertions.assertThat(spy.getView()).isNotShown();
122
+        verify(spy, times(1)).onViewDisappear();
123
+    }
124
+
125
+    @Test
126
+    public void onDisappear_CalledAtMostOnce() throws Exception {
127
+        ViewController spy = spy(uut);
128
+        Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
129
+        Assertions.assertThat(spy.getView()).isShown();
130
+        spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
131
+        spy.getView().setVisibility(View.GONE);
132
+        spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
133
+        spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
134
+        spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
135
+        verify(spy, times(1)).onViewDisappear();
136
+    }
137
+
138
+    @Test
139
+    public void onDestroy_RemovesGlobalLayoutListener() throws Exception {
140
+        new SimpleViewController(activity, "ensureNotNull").destroy();
141
+
142
+        ViewController spy = spy(uut);
143
+        View view = spy.getView();
144
+        Shadows.shadowOf(view).setMyParent(mock(ViewParent.class));
145
+
146
+        spy.destroy();
147
+
148
+        Assertions.assertThat(view).isShown();
149
+        view.getViewTreeObserver().dispatchOnGlobalLayout();
150
+        verify(spy, times(0)).onViewAppeared();
151
+        verify(spy, times(0)).onViewDisappear();
152
+
153
+        Field field = ViewController.class.getDeclaredField("view");
154
+        field.setAccessible(true);
155
+        assertThat(field.get(spy)).isNull();
156
+    }
157
+
158
+    @Test
159
+    public void onDestroy_CallsOnDisappearIfNeeded() throws Exception {
160
+        ViewController spy = spy(uut);
161
+        Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
162
+        Assertions.assertThat(spy.getView()).isShown();
163
+        spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
164
+        verify(spy, times(1)).onViewAppeared();
165
+
166
+        spy.destroy();
167
+
168
+        verify(spy, times(1)).onViewDisappear();
169
+    }
170
+
171
+    @Test
172
+    public void assignsIdToCreatedView() throws Exception {
173
+        assertThat(uut.getView().getId()).isPositive();
174
+    }
175
+
176
+    @Test
177
+    public void onDestroy_RemovesSelfFromParentIfExists() throws Exception {
178
+        LinearLayout parent = new LinearLayout(activity);
179
+        parent.addView(uut.getView());
180
+
181
+        uut.destroy();
182
+        assertThat(parent.getChildCount()).withFailMessage("expected not to have children").isZero();
183
+    }
184
+
185
+    @Test
186
+    public void ensureViewIsCreated() throws Exception {
187
+        ViewController spy = spy(uut);
188
+        verify(spy, times(0)).getView();
189
+        spy.ensureViewIsCreated();
190
+        verify(spy, times(1)).getView();
191
+    }
196 192
 }
197 193
 

+ 10
- 10
lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java Wyświetl plik

@@ -1,18 +1,18 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3
-import com.reactnativenavigation.BaseTest;
3
+import com.reactnativenavigation.*;
4 4
 
5
-import org.junit.Test;
5
+import org.junit.*;
6 6
 
7
-import static org.assertj.core.api.Java6Assertions.assertThat;
7
+import static org.assertj.core.api.Java6Assertions.*;
8 8
 
9 9
 public class TopBarTest extends BaseTest {
10
-	@Test
11
-	public void title() throws Exception {
12
-		TopBar topBar = new TopBar(newActivity(), null, null);
13
-		assertThat(topBar.getTitle()).isEmpty();
10
+    @Test
11
+    public void title() throws Exception {
12
+        TopBar topBar = new TopBar(newActivity(), null, null);
13
+        assertThat(topBar.getTitle()).isEmpty();
14 14
 
15
-		topBar.setTitle("new title");
16
-		assertThat(topBar.getTitle()).isEqualTo("new title");
17
-	}
15
+        topBar.setTitle("new title");
16
+        assertThat(topBar.getTitle()).isEqualTo("new title");
17
+    }
18 18
 }

+ 1
- 1
playground/android/app/src/main/java/com/reactnativenavigation/playground/MainActivity.java Wyświetl plik

@@ -1,6 +1,6 @@
1 1
 package com.reactnativenavigation.playground;
2 2
 
3
-import com.reactnativenavigation.NavigationActivity;
3
+import com.reactnativenavigation.*;
4 4
 
5 5
 public class MainActivity extends NavigationActivity {
6 6
 }

+ 13
- 13
playground/android/app/src/main/java/com/reactnativenavigation/playground/MainApplication.java Wyświetl plik

@@ -1,22 +1,22 @@
1 1
 package com.reactnativenavigation.playground;
2 2
 
3
-import android.support.annotation.Nullable;
3
+import android.support.annotation.*;
4 4
 
5
-import com.facebook.react.ReactPackage;
6
-import com.reactnativenavigation.NavigationApplication;
5
+import com.facebook.react.*;
6
+import com.reactnativenavigation.*;
7 7
 
8
-import java.util.List;
8
+import java.util.*;
9 9
 
10 10
 public class MainApplication extends NavigationApplication {
11 11
 
12
-	@Override
13
-	public boolean isDebug() {
14
-		return BuildConfig.DEBUG;
15
-	}
12
+    @Override
13
+    public boolean isDebug() {
14
+        return BuildConfig.DEBUG;
15
+    }
16 16
 
17
-	@Nullable
18
-	@Override
19
-	public List<ReactPackage> createAdditionalReactPackages() {
20
-		return null;
21
-	}
17
+    @Nullable
18
+    @Override
19
+    public List<ReactPackage> createAdditionalReactPackages() {
20
+        return null;
21
+    }
22 22
 }

+ 1
- 1
playground/src/screens/ModalScreen.js Wyświetl plik

@@ -82,7 +82,7 @@ class ModalScreen extends Component {
82 82
   }
83 83
 
84 84
   onClickPushScreen() {
85
-    Navigation.push(this.props.containerId, {
85
+    Navigation.push(this.props.componentId, {
86 86
       component: {
87 87
         name: `navigation.playground.PushedScreen`,
88 88
         passProps: {

+ 8
- 2
playground/src/screens/WelcomeScreen.js Wyświetl plik

@@ -183,8 +183,14 @@ class WelcomeScreen extends Component {
183 183
 
184 184
   async onClickShowModal() {
185 185
     await Navigation.showModal({
186
-      component: {
187
-        name: 'navigation.playground.ModalScreen'
186
+      stack: {
187
+        children: [
188
+          {
189
+            component: {
190
+              name: 'navigation.playground.ModalScreen'
191
+            }
192
+          }
193
+        ]
188 194
       }
189 195
     });
190 196
   }