forked from robolectric/robolectric
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate ctesque for `GradientDrawable` with the related resources.
- Loading branch information
Showing
25 changed files
with
1,684 additions
and
2 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...ration_tests/ctesque/src/sharedTest/java/android/graphics/drawable/DrawableTestUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package android.graphics.drawable; | ||
|
||
import android.content.res.Configuration; | ||
import android.content.res.Resources; | ||
import android.content.res.XmlResourceParser; | ||
import java.io.IOException; | ||
import org.xmlpull.v1.XmlPullParser; | ||
import org.xmlpull.v1.XmlPullParserException; | ||
|
||
/** | ||
* Partially copied from <a | ||
* href="https://cs.android.com/android/platform/superproject/main/+/main:cts/tests/tests/graphics/src/android/graphics/drawable/cts/DrawableTestUtils.java">DrawableTestUtils</a> | ||
*/ | ||
public class DrawableTestUtils { | ||
public static XmlResourceParser getResourceParser(Resources res, int resId) | ||
throws XmlPullParserException, IOException { | ||
final XmlResourceParser parser = res.getXml(resId); | ||
int type; | ||
while ((type = parser.next()) != XmlPullParser.START_TAG | ||
&& type != XmlPullParser.END_DOCUMENT) { | ||
// Empty loop | ||
} | ||
return parser; | ||
} | ||
|
||
public static void setResourcesDensity(Resources res, int densityDpi) { | ||
final Configuration config = new Configuration(); | ||
config.setTo(res.getConfiguration()); | ||
config.densityDpi = densityDpi; | ||
res.updateConfiguration(config, null); | ||
} | ||
} |
Oops, something went wrong.