package org.robolectric.internal;

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

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.robolectric.annotation.Config;
import org.robolectric.res.FileFsFile;
import org.robolectric.res.FsFile;

@RunWith(JUnit4.class)
public class MavenManifestFactoryTest {

  private Config.Builder configBuilder;
  private MyMavenManifestFactory myMavenManifestFactory;

  @Before
  public void setUp() throws Exception {
    configBuilder = Config.Builder.defaults();
    myMavenManifestFactory = new MyMavenManifestFactory();
  }

  @Test public void identify() throws Exception {
    ManifestIdentifier manifestIdentifier = myMavenManifestFactory.identify(configBuilder.build());
    assertThat(manifestIdentifier.getManifestFile())
        .isEqualTo(FileFsFile.from(":fakefs:path/to/AndroidManifest.xml"));
    assertThat(manifestIdentifier.getResDir())
        .isEqualTo(FileFsFile.from(":fakefs:path/to/res"));
  }

  @Test public void withDotSlashManifest_identify() throws Exception {
    configBuilder.setManifest("./AndroidManifest.xml");

    ManifestIdentifier manifestIdentifier = myMavenManifestFactory.identify(configBuilder.build());
    assertThat(manifestIdentifier.getManifestFile())
        .isEqualTo(FileFsFile.from(":fakefs:path/to/AndroidManifest.xml"));
    assertThat(manifestIdentifier.getResDir())
        .isEqualTo(FileFsFile.from(":fakefs:path/to/res"));
  }

  @Test public void withDotDotSlashManifest_identify() throws Exception {
    configBuilder.setManifest("../AndroidManifest.xml");

    ManifestIdentifier manifestIdentifier = myMavenManifestFactory.identify(configBuilder.build());
    assertThat(manifestIdentifier.getManifestFile())
        .isEqualTo(FileFsFile.from(":fakefs:path/to/../AndroidManifest.xml"));
    assertThat(manifestIdentifier.getResDir())
        .isEqualTo(FileFsFile.from(":fakefs:path/to/../res"));
  }

  private static class MyMavenManifestFactory extends MavenManifestFactory {
    @Override
    FsFile getBaseDir() {
      return FileFsFile.from(":fakefs:path/to");
    }
  }
}
@@ -576,18 +576,55 @@
 faults()
+.setManifest(%22DifferentManifest.xml%22)
 ;%0A
-
     myMa
@@ -926,39 +926,41 @@
 :fakefs:path/to/
-Android
+Different
 Manifest.xml%22));
@@ -1176,23 +1176,25 @@
 fest(%22./
-Android
+Different
 Manifest
@@ -1407,23 +1407,25 @@
 path/to/
-Android
+Different
 Manifest
@@ -1653,23 +1653,25 @@
 est(%22../
-Android
+Different
 Manifest
@@ -1891,15 +1891,17 @@
 /../
-Android
+Different
 Mani

Fix tests.