I'm implementing a way to obfuscate an apk's strings.xml file, and later de-obfuscating it without changing the java resource calls. To test my solution, I need some android project that uses lots of different ways to load string resources. I'm guessing there is some project/framework that does that, but didn't find any.
For example some of the tests I did:
simple testing getTest and setText:
TextView textView2 = findViewById(R.id.new_text);
String my_context = textView2.getContext().getString(R.string.new_text);
textView2.setText(my_context);
testing setPositiveButton
AlertDialog.Builder buildexit=new AlertDialog.Builder(this);
buildexit.setPositiveButton(R.string.setpos, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.i("my_app", "onClick pressed");
}
});
testing EditText using styles.xml:
EditText editText = findViewById(R.id.editTextLineNumber);
String content = editText.getText().toString();
activity.xml:
<EditText
android:id="@+id/editTextLineNumber"
style="@style/MainEditText"/>
styles.xml:
<style name="MainEditText">
<item name="android:layout_marginTop">15dp</item>
<item name="android:hint">@string/line_hint</item>
<item name="android:text">@string/line_hint_text</item>
<item name="android:name">@string/line_hint_name</item>
<item name="android:maxLines">1</item>
<item name="android:inputType">number</item>
</style>
prefereably it would be some automated test, such as done in https://medium.com/android-testing-daily/unit-testing-xml-resources-7387447f9ef7
Aucun commentaire:
Enregistrer un commentaire