// Path: me.gladwell.eclipse.m2e.android.test/src/me/gladwell/eclipse/m2e/android/test/FileMatchers.java
// public static Matcher<IFile> containsString(final String expected) {
//     return new BaseMatcher<IFile>() {
//             
//         @Override
//         public boolean matches(Object target) {
//             return getContents((IFile) target).contains(expected);
//         }
// 
//         @Override
//         public void describeTo(Description description) {
//             description.appendText("file containing ");
//             description.appendText(expected);
//         }
//             
//         @Override
//         public void describeMismatch(Object item, Description description) {
//             description.appendText("was ").appendValue(item).appendText(" with content:\n")
//                     .appendText(getContents((IFile) item));
//         }
//     };
// }
// 
// Path: me.gladwell.eclipse.m2e.android.test/src/me/gladwell/eclipse/m2e/android/test/ProjectImporter.java
// public static ProjectImporter importAndroidTestProject(String projectName) {
//     return new ProjectImporter(projectName);
// }


import static me.gladwell.eclipse.m2e.android.test.FileMatchers.containsString;
import static me.gladwell.eclipse.m2e.android.test.ProjectImporter.importAndroidTestProject;
import static org.junit.Assert.assertThat;
import java.io.File;
import java.lang.reflect.Field;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
import org.eclipse.m2e.core.project.ResolverConfiguration;
/*******************************************************************************
 * Copyright (c) 2012, 2013, 2014, 2015 Ricardo Gladwell
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package me.gladwell.eclipse.m2e.android.test;




public class ManifestMergerTest extends AndroidMavenPluginTestCase {

    private static final String PROJECT_NAME = "manifestmerger";

    @Override
    protected void tearDown() throws Exception {
        setLifecycleMappingMetadata("lifecycle-mapping-metadata-empty.xml");

        super.tearDown();
    }

    public void testBuildMergesManifest() throws Exception {
        setLifecycleMappingMetadata("lifecycle-mapping-metadata.xml");

        IProject project = importAndroidProject(PROJECT_NAME);

        buildAndroidProject(project, IncrementalProjectBuilder.FULL_BUILD);

        IFile manifest = project.getFile("bin/AndroidManifest.xml");

// Path: me.gladwell.eclipse.m2e.android.test/src/me/gladwell/eclipse/m2e/android/test/FileMatchers.java
// public static Matcher<IFile> containsString(final String expected) {
//     return new BaseMatcher<IFile>() {
//             
//         @Override
//         public boolean matches(Object target) {
//             return getContents((IFile) target).contains(expected);
//         }
// 
//         @Override
//         public void describeTo(Description description) {
//             description.appendText("file containing ");
//             description.appendText(expected);
//         }
//             
//         @Override
//         public void describeMismatch(Object item, Description description) {
//             description.appendText("was ").appendValue(item).appendText(" with content:\n")
//                     .appendText(getContents((IFile) item));
//         }
//     };
// }
// 
// Path: me.gladwell.eclipse.m2e.android.test/src/me/gladwell/eclipse/m2e/android/test/ProjectImporter.java
// public static ProjectImporter importAndroidTestProject(String projectName) {
//     return new ProjectImporter(projectName);
// }


// Path: me.gladwell.eclipse.m2e.android.test/src/me/gladwell/eclipse/m2e/android/test/ManifestMergerTest.java
import static me.gladwell.eclipse.m2e.android.test.FileMatchers.containsString;
import static me.gladwell.eclipse.m2e.android.test.ProjectImporter.importAndroidTestProject;
import static org.junit.Assert.assertThat;
import java.io.File;
import java.lang.reflect.Field;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
import org.eclipse.m2e.core.project.ResolverConfiguration;

/*******************************************************************************
 * Copyright (c) 2012, 2013, 2014, 2015 Ricardo Gladwell
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package me.gladwell.eclipse.m2e.android.test;




public class ManifestMergerTest extends AndroidMavenPluginTestCase {

    private static final String PROJECT_NAME = "manifestmerger";

    @Override
    protected void tearDown() throws Exception {
        setLifecycleMappingMetadata("lifecycle-mapping-metadata-empty.xml");

        super.tearDown();
    }

    public void testBuildMergesManifest() throws Exception {
        setLifecycleMappingMetadata("lifecycle-mapping-metadata.xml");

        IProject project = importAndroidProject(PROJECT_NAME);

        buildAndroidProject(project, IncrementalProjectBuilder.FULL_BUILD);

        IFile manifest = project.getFile("bin/AndroidManifest.xml");

        assertThat(manifest, containsString("android:versionCode=\"1000000\""));