react-native-navigation的迁移库

BaseTest.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package com.reactnativenavigation;
  2. import android.app.*;
  3. import android.support.v7.app.*;
  4. import android.view.*;
  5. import com.reactnativenavigation.parse.params.Bool;
  6. import com.reactnativenavigation.viewcontrollers.ViewController;
  7. import org.junit.*;
  8. import org.junit.runner.*;
  9. import org.robolectric.*;
  10. import org.robolectric.annotation.*;
  11. import static org.assertj.core.api.Java6Assertions.*;
  12. @RunWith(RobolectricTestRunner.class)
  13. @Config(sdk = 27, application = TestApplication.class)
  14. public abstract class BaseTest {
  15. @Before
  16. public void beforeEach() {
  17. //
  18. }
  19. @After
  20. public void afterEach() {
  21. //
  22. }
  23. public Activity newActivity() {
  24. return Robolectric.setupActivity(AppCompatActivity.class);
  25. }
  26. public void assertIsChildById(ViewGroup parent, View child) {
  27. assertThat(parent).isNotNull();
  28. assertThat(child).isNotNull();
  29. assertThat(child.getId()).isNotZero().isPositive();
  30. assertThat(parent.findViewById(child.getId())).isNotNull().isEqualTo(child);
  31. }
  32. public void assertNotChildOf(ViewGroup parent, View child) {
  33. assertThat(parent).isNotNull();
  34. assertThat(child).isNotNull();
  35. assertThat(child.getId()).isNotZero().isPositive();
  36. assertThat(parent.findViewById(child.getId())).isNull();
  37. }
  38. protected void disablePushAnimation(ViewController... controllers) {
  39. for (ViewController controller : controllers) {
  40. controller.options.animations.push.enabled = new Bool(false);
  41. }
  42. }
  43. }