summaryrefslogtreecommitdiff
path: root/library/self.gradle
blob: a3e5334862fcd0da7d28b7e6e321916d0b28b816 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
 * This self.gradle build file is only run when built in ub-setupwizard-* branches.
 */
apply from: 'standalone-rules.gradle'
apply from: '../tools/gradle/dist-library-instrumentation-tests.gradle'
apply from: '../tools/gradle/dist-unit-tests.gradle'

// Add targets for tests
android.sourceSets {
    androidTest {
        manifest.srcFile 'test/instrumentation/AndroidManifest.xml'
        java.srcDirs = ['test/instrumentation/src']
        res.srcDirs = ['test/instrumentation/res']

        dependencies {
            androidTestImplementation 'com.android.support.test:rules:0.5'
            androidTestImplementation 'com.android.support.test:runner:0.5'
            androidTestImplementation 'com.google.dexmaker:dexmaker:1.2'
            androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2'
            androidTestImplementation 'junit:junit:4.+'
            androidTestImplementation 'org.mockito:mockito-core:1.9.5'
        }
    }

    androidTestPlatform {
        java.srcDirs = ['platform/test/src']
    }

    androidTestGingerbreadCompat {
        java.srcDirs = [
            'gingerbread/test/instrumentation/src',
            'recyclerview/test/instrumentation/src'
        ]
        res.srcDirs = ['recyclerview/test/instrumentation/res']
    }

    test {
        java.srcDirs = ['test/robotest/src']

        dependencies {
            testImplementation 'org.robolectric:robolectric:3.4.2'
            testImplementation 'org.robolectric:framework:3.4.2'
            testImplementation 'junit:junit:4.+'
            testImplementation 'org.mockito:mockito-core:1.9.5'
            // Workaround for https://github.com/robolectric/robolectric/issues/2566
            testImplementation 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
        }
    }

    testGingerbreadCompat {
        java.srcDirs = ['gingerbread/test/robotest/src', 'recyclerview/test/robotest/src']
    }
}

android.testOptions.unitTests.includeAndroidResources = true

android.defaultConfig.testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
android.lintOptions {
    abortOnError true
    htmlReport true
    textOutput 'stderr'
    textReport true
    warningsAsErrors true
    xmlReport false
}
// Run lint for all variants
android.libraryVariants.all { variant ->
    variant.assemble.dependsOn(tasks.findByName('lint'))
}

// For compatibility with existing continuous test configurations, copy the file to
// setup-wizard-libTest.apk
// TODO: Remove this once continuous test configurations are updated to handle the new file name
task createLegacyTestApk(type: Copy) {
    from "${project.ext.distDir}/setup-wizard-lib-gingerbreadCompat-debug-androidTest.apk"
    into "${project.ext.distDir}"
    rename ('setup-wizard-lib-gingerbreadCompat-debug-androidTest.apk', 'setup-wizard-libTest.apk')
}

tasks.dist.finalizedBy createLegacyTestApk