react-native-navigation的迁移库

BaseTest.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package com.reactnativenavigation;
  2. import android.app.Activity;
  3. import android.view.View;
  4. import android.view.ViewGroup;
  5. import org.junit.After;
  6. import org.junit.Before;
  7. import org.junit.runner.RunWith;
  8. import org.robolectric.Robolectric;
  9. import org.robolectric.RobolectricTestRunner;
  10. import org.robolectric.annotation.Config;
  11. import static org.assertj.core.api.Java6Assertions.assertThat;
  12. @RunWith(RobolectricTestRunner.class)
  13. @Config(sdk = 25, constants = BuildConfig.class, manifest = "/../../../../../src/test/AndroidManifest.xml")
  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(Activity.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. }