|
@@ -1,5 +1,6 @@
|
1
|
1
|
package com.reactnativenavigation.viewcontrollers.stack;
|
2
|
2
|
|
|
3
|
+import android.animation.Animator;
|
3
|
4
|
import android.app.Activity;
|
4
|
5
|
import android.content.Context;
|
5
|
6
|
import android.view.View;
|
|
@@ -13,6 +14,7 @@ import com.reactnativenavigation.mocks.SimpleViewController;
|
13
|
14
|
import com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock;
|
14
|
15
|
import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
|
15
|
16
|
import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
|
|
17
|
+import com.reactnativenavigation.parse.AnimationOptions;
|
16
|
18
|
import com.reactnativenavigation.parse.NestedAnimationsOptions;
|
17
|
19
|
import com.reactnativenavigation.parse.Options;
|
18
|
20
|
import com.reactnativenavigation.parse.params.Bool;
|
|
@@ -36,6 +38,7 @@ import com.reactnativenavigation.views.element.ElementTransitionManager;
|
36
|
38
|
import com.reactnativenavigation.views.topbar.TopBar;
|
37
|
39
|
|
38
|
40
|
import org.assertj.core.api.iterable.Extractor;
|
|
41
|
+import org.json.JSONException;
|
39
|
42
|
import org.json.JSONObject;
|
40
|
43
|
import org.junit.Test;
|
41
|
44
|
import org.mockito.ArgumentCaptor;
|
|
@@ -317,7 +320,7 @@ public class StackControllerTest extends BaseTest {
|
317
|
320
|
}
|
318
|
321
|
|
319
|
322
|
@Test
|
320
|
|
- public void popDoesNothingWhenZeroOrOneChild() {
|
|
323
|
+ public void pop_doesNothingWhenZeroOrOneChild() {
|
321
|
324
|
assertThat(uut.isEmpty()).isTrue();
|
322
|
325
|
uut.pop(Options.EMPTY, new CommandListenerAdapter());
|
323
|
326
|
assertThat(uut.isEmpty()).isTrue();
|
|
@@ -327,6 +330,33 @@ public class StackControllerTest extends BaseTest {
|
327
|
330
|
assertContainsOnlyId(child1.getId());
|
328
|
331
|
}
|
329
|
332
|
|
|
333
|
+ @SuppressWarnings("MagicNumber")
|
|
334
|
+ @Test
|
|
335
|
+ public void pop_animationOptionsAreMergedCorrectlyToDisappearingChild() throws JSONException {
|
|
336
|
+ disablePushAnimation(child1, child2);
|
|
337
|
+
|
|
338
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
339
|
+ uut.push(child2, new CommandListenerAdapter());
|
|
340
|
+
|
|
341
|
+ Options mergeOptions = new Options();
|
|
342
|
+ JSONObject content = new JSONObject();
|
|
343
|
+ JSONObject x = new JSONObject();
|
|
344
|
+ x.put("duration", 300);
|
|
345
|
+ x.put("from", 0);
|
|
346
|
+ x.put("to", 1000);
|
|
347
|
+ content.put("x", x);
|
|
348
|
+ mergeOptions.animations.pop.content = AnimationOptions.parse(content);
|
|
349
|
+
|
|
350
|
+ uut.pop(mergeOptions, new CommandListenerAdapter());
|
|
351
|
+ ArgumentCaptor<NestedAnimationsOptions> captor = ArgumentCaptor.forClass(NestedAnimationsOptions.class);
|
|
352
|
+ verify(animator, times(1)).pop(any(), captor.capture(), any());
|
|
353
|
+ Animator animator = captor.getValue().content
|
|
354
|
+ .getAnimation(mock(View.class))
|
|
355
|
+ .getChildAnimations()
|
|
356
|
+ .get(0);
|
|
357
|
+ assertThat(animator.getDuration()).isEqualTo(300);
|
|
358
|
+ }
|
|
359
|
+
|
330
|
360
|
@Test
|
331
|
361
|
public void canPopWhenSizeIsMoreThanOne() {
|
332
|
362
|
assertThat(uut.isEmpty()).isTrue();
|