
The idea was good: reduce the amount of copied/pasted code where ContentValues were initialized, populated, then inserted. I've kept the idea, by putting it in its own method which is called twice. But the resources are not loaded dynamically any more. This is so that the compiler will be able to pick up if we reference a missing resource. Also, I took the opportunity to replace the field name string literals with references to RepoProvider.DataColumns.* constants. Finally, changed the tests around because now we need to have the "getInteger()" call mocked in resources correctly (for priority/inUse).
27 lines
655 B
Java
27 lines
655 B
Java
package mock;
|
|
|
|
import android.content.Context;
|
|
import android.test.mock.*;
|
|
import org.fdroid.fdroid.*;
|
|
|
|
public class MockCategoryResources extends MockFDroidResources {
|
|
|
|
public MockCategoryResources(Context getStringDelegatingContext) {
|
|
super(getStringDelegatingContext);
|
|
}
|
|
|
|
@Override
|
|
public String getString(int id) {
|
|
if (id == R.string.category_all) {
|
|
return "All";
|
|
} else if (id == R.string.category_recentlyupdated) {
|
|
return "Recently Updated";
|
|
} else if (id == R.string.category_whatsnew) {
|
|
return "Whats New";
|
|
} else {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
}
|