package org.robolectric;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.Arrays;
import java.util.Collection;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;

import android.net.Uri;

/**
 * Parameterized tests using an Android class originally created outside of the Robolectric classloader.
 */
@RunWith(ParameterizedRobolectricTestRunner.class)
public final class ParameterizedRobolectricTestRunnerClassLoaderTest {

  private final Uri uri;

  public ParameterizedRobolectricTestRunnerClassLoaderTest(Uri uri) {
    this.uri = uri;
  }

  @Test
  @Config(manifest = Config.NONE)
  public void parse() {
    Uri currentUri = Uri.parse("http://host/");
    assertThat(currentUri).isEqualTo(uri);
  }

  @ParameterizedRobolectricTestRunner.Parameters
  public static Collection getTestData() {
    Object[][] data = {
        { Uri.parse("http://host/") }
    };
    return Arrays.asList(data);
  }
}

Test ParameterizedRobolectricTestRunner with Android class parameters
Test ParameterizedRobolectricTestRunner with Android class parameters

There is a known issue that the runner does not work when the test parameters are objects of Android classes, and are tests against objects which are created during the tests. This is because the class loader of the original parameters, and the objects created during the tests are different.
