aboutsummaryrefslogtreecommitdiff
path: root/testutil/src/main/java/com/bumptech/glide/testutil/TestResourceUtil.java
blob: e523b67d06562d398023bc6aa902f804fecf6330 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.bumptech.glide.testutil;

import java.io.InputStream;

/**
 * Test only utility for opening resources in androidTest/resources.
 */
public final class TestResourceUtil {
    private TestResourceUtil() {
        // Utility class
    }

    /**
     * Returns an InputStream for the given test class and sub-path.
     *
     * @param testClass A Junit test class.
     * @param subPath The sub-path under androidTest/resources where the desired resource is located.
     *                Should not be prefixed with a '/'
     */
    public static InputStream openResource(Class testClass, String subPath) {
        return testClass.getResourceAsStream("/" + subPath);
    }
}