Browse Source

navigator id

Daniel Zlotin 7 years ago
parent
commit
f67c2bf2d9

+ 3
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/Navigator.java View File

@@ -5,11 +5,13 @@ import android.support.annotation.NonNull;
5 5
 import android.view.View;
6 6
 import android.widget.FrameLayout;
7 7
 
8
+import com.reactnativenavigation.utils.CompatUtils;
9
+
8 10
 public class Navigator extends ViewController {
9 11
 	private boolean activityResumed = false;
10 12
 
11 13
 	public Navigator(final Activity activity) {
12
-		super(activity, "navigator");
14
+		super(activity, "navigator" + CompatUtils.generateViewId());
13 15
 	}
14 16
 
15 17
 	@NonNull

+ 8
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java View File

@@ -8,6 +8,8 @@ import com.reactnativenavigation.mocks.SimpleViewController;
8 8
 import org.junit.Test;
9 9
 import org.robolectric.Shadows;
10 10
 
11
+import java.util.regex.Pattern;
12
+
11 13
 import static org.assertj.core.api.Java6Assertions.assertThat;
12 14
 
13 15
 public class NavigatorTest extends BaseTest {
@@ -58,6 +60,12 @@ public class NavigatorTest extends BaseTest {
58 60
 		assertHasSingleChildViewOf(child2);
59 61
 	}
60 62
 
63
+	@Test
64
+	public void holdsUniqueId() throws Exception {
65
+		assertThat(uut.getId()).startsWith("navigator").matches(Pattern.compile("navigator\\d"));
66
+		assertThat(new Navigator(activity).getId()).isNotEqualTo(uut.getId());
67
+	}
68
+
61 69
 	private void assertHasSingleChildViewOf(ViewController vc) {
62 70
 		assertThat(uut.getView().getChildCount()).isEqualTo(1);
63 71
 		assertThat(uut.getView().getChildAt(0)).isEqualTo(vc.getView()).isNotNull();