Search in sources :

Example 1 with InstrumentorToTarget

use of com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep.InstrumentorToTarget in project intellij by bazelbuild.

the class BlazeInstrumentationTestApkBuildStepIntegrationTest method getInstrumentorToTargetPair_separateInstrumentorAndTestTargets.

@Test
public void getInstrumentorToTargetPair_separateInstrumentorAndTestTargets() {
    setupProject();
    MessageCollector messageCollector = new MessageCollector();
    BlazeContext context = BlazeContext.create();
    context.addOutputSink(IssueOutput.class, messageCollector);
    BlazeInstrumentationTestApkBuildStep buildStep = new BlazeInstrumentationTestApkBuildStep(getProject(), Label.create("//java/com/foo/app:instrumentation_test"), ImmutableList.of());
    InstrumentorToTarget pair = buildStep.getInstrumentorToTargetPair(context, BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData());
    assertThat(pair.instrumentor).isEqualTo(Label.create("//java/com/foo/app:test_app"));
    assertThat(pair.target).isEqualTo(Label.create("//java/com/foo/app:app"));
    assertThat(pair.isSelfInstrumentingTest()).isFalse();
    assertThat(messageCollector.getMessages()).isEmpty();
}
Also used : BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) MessageCollector(com.google.idea.blaze.android.MessageCollector) BlazeInstrumentationTestApkBuildStep(com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep) InstrumentorToTarget(com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep.InstrumentorToTarget) Test(org.junit.Test)

Example 2 with InstrumentorToTarget

use of com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep.InstrumentorToTarget in project intellij by bazelbuild.

the class BlazeInstrumentationTestApkBuildStepIntegrationTest method getInstrumentorToTargetPair_selfInstrumentingTest.

@Test
public void getInstrumentorToTargetPair_selfInstrumentingTest() {
    setupProject();
    MessageCollector messageCollector = new MessageCollector();
    BlazeContext context = BlazeContext.create();
    context.addOutputSink(IssueOutput.class, messageCollector);
    BlazeInstrumentationTestApkBuildStep buildStep = new BlazeInstrumentationTestApkBuildStep(getProject(), Label.create("//java/com/foo/app:self_instrumenting_test"), ImmutableList.of());
    InstrumentorToTarget pair = buildStep.getInstrumentorToTargetPair(context, BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData());
    assertThat(pair.instrumentor).isEqualTo(Label.create("//java/com/foo/app:test_app_self_instrumenting"));
    assertThat(pair.target).isNull();
    assertThat(pair.isSelfInstrumentingTest()).isTrue();
    assertThat(messageCollector.getMessages()).isEmpty();
}
Also used : BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) MessageCollector(com.google.idea.blaze.android.MessageCollector) BlazeInstrumentationTestApkBuildStep(com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep) InstrumentorToTarget(com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep.InstrumentorToTarget) Test(org.junit.Test)

Example 3 with InstrumentorToTarget

use of com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep.InstrumentorToTarget in project intellij by bazelbuild.

the class BlazeInstrumentationTestApkBuildStepIntegrationTest method noTestAppSpecified.

@Test
public void noTestAppSpecified() {
    setProjectView("directories:", "  java/com/foo/app", "targets:", "  //java/com/foo/app:instrumentation_test", "android_sdk_platform: android-27");
    MockSdkUtil.registerSdk(workspace, "27");
    workspace.createFile(new WorkspacePath("java/com/foo/app/MainActivity.java"), "package com.foo.app", "import android.app.Activity;", "public class MainActivity extends Activity {}");
    workspace.createFile(new WorkspacePath("java/com/foo/app/Test.java"), "package com.foo.app", "public class Test {}");
    setTargetMap(android_binary("//java/com/foo/app:app").src("MainActivity.java"), android_binary("//java/com/foo/app:test_app").setResourceJavaPackage("com.foo.app.androidtest").src("Test.java").instruments("//java/com/foo/app:app"), android_instrumentation_test("//java/com/foo/app:instrumentation_test"));
    runFullBlazeSyncWithNoIssues();
    MessageCollector messageCollector = new MessageCollector();
    BlazeContext context = BlazeContext.create();
    context.addOutputSink(IssueOutput.class, messageCollector);
    BlazeInstrumentationTestApkBuildStep buildStep = new BlazeInstrumentationTestApkBuildStep(getProject(), Label.create("//java/com/foo/app:instrumentation_test"), ImmutableList.of());
    InstrumentorToTarget pair = buildStep.getInstrumentorToTargetPair(context, BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData());
    assertThat(pair).isNull();
    assertThat(messageCollector.getMessages()).hasSize(1);
    assertThat(messageCollector.getMessages().get(0)).contains("No \"test_app\" in target definition for //java/com/foo/app:instrumentation_test.");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) MessageCollector(com.google.idea.blaze.android.MessageCollector) BlazeInstrumentationTestApkBuildStep(com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep) InstrumentorToTarget(com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep.InstrumentorToTarget) Test(org.junit.Test)

Example 4 with InstrumentorToTarget

use of com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep.InstrumentorToTarget in project intellij by bazelbuild.

the class BlazeInstrumentationTestApkBuildStepIntegrationTest method findInstrumentorAndTestTargets.

@Test
public void findInstrumentorAndTestTargets() {
    setupProject();
    BlazeInstrumentationTestApkBuildStep buildStep = new BlazeInstrumentationTestApkBuildStep(getProject(), Label.create("//java/com/foo/app:instrumentation_test"), ImmutableList.of());
    InstrumentorToTarget pair = buildStep.getInstrumentorToTargetPair(BlazeContext.create(), BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData());
    assertThat(pair.instrumentor).isEqualTo(Label.create("//java/com/foo/app:test_app"));
    assertThat(pair.target).isEqualTo(Label.create("//java/com/foo/app:app"));
}
Also used : BlazeInstrumentationTestApkBuildStep(com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep) InstrumentorToTarget(com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep.InstrumentorToTarget) Test(org.junit.Test)

Aggregations

BlazeInstrumentationTestApkBuildStep (com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep)4 InstrumentorToTarget (com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep.InstrumentorToTarget)4 Test (org.junit.Test)4 MessageCollector (com.google.idea.blaze.android.MessageCollector)3 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)3 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)1