mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Allow StyledResources to receive a fixed theme for testing
This commit is contained in:
@@ -116,6 +116,7 @@ public class BaseAndroidTest
|
|||||||
protected void setTheme(@StyleRes int themeId)
|
protected void setTheme(@StyleRes int themeId)
|
||||||
{
|
{
|
||||||
targetContext.setTheme(themeId);
|
targetContext.setTheme(themeId);
|
||||||
|
StyledResources.setFixedTheme(themeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sleep(int time)
|
protected void sleep(int time)
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public class CheckmarkWidgetViewTest extends BaseViewTest
|
|||||||
public void setUp()
|
public void setUp()
|
||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
setTheme(R.style.TransparentWidgetTheme);
|
||||||
|
|
||||||
habit = fixtures.createShortHabit();
|
habit = fixtures.createShortHabit();
|
||||||
view = new CheckmarkWidgetView(targetContext);
|
view = new CheckmarkWidgetView(targetContext);
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import org.isoron.uhabits.*;
|
|||||||
|
|
||||||
public class StyledResources
|
public class StyledResources
|
||||||
{
|
{
|
||||||
|
private static Integer fixedTheme;
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
public StyledResources(@NonNull Context context)
|
public StyledResources(@NonNull Context context)
|
||||||
@@ -35,6 +37,11 @@ public class StyledResources
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setFixedTheme(Integer theme)
|
||||||
|
{
|
||||||
|
fixedTheme = theme;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getBoolean(@AttrRes int attrId)
|
public boolean getBoolean(@AttrRes int attrId)
|
||||||
{
|
{
|
||||||
TypedArray ta = getTypedArray(attrId);
|
TypedArray ta = getTypedArray(attrId);
|
||||||
@@ -92,9 +99,8 @@ public class StyledResources
|
|||||||
{
|
{
|
||||||
int[] attrs = new int[]{ attrId };
|
int[] attrs = new int[]{ attrId };
|
||||||
|
|
||||||
// Integer fixedTheme = ThemeSwitcher.fixedTheme;
|
if (fixedTheme != null)
|
||||||
// if (fixedTheme != null)
|
return context.getTheme().obtainStyledAttributes(fixedTheme, attrs);
|
||||||
// return context.getTheme().obtainStyledAttributes(fixedTheme, attrs);
|
|
||||||
|
|
||||||
return context.obtainStyledAttributes(attrs);
|
return context.obtainStyledAttributes(attrs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user