mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
We have a test suite that can run (thanks to achen's start)
This commit is contained in:
parent
4f77063755
commit
2d347826a7
21
tests/AndroidManifest.xml
Normal file
21
tests/AndroidManifest.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.fsck.k9.tests"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0">
|
||||||
|
<!-- We add an application tag here just so that we can indicate that
|
||||||
|
this package needs to link against the android.test library,
|
||||||
|
which is needed when building test cases. -->
|
||||||
|
<application>
|
||||||
|
<uses-library android:name="android.test.runner" />
|
||||||
|
</application>
|
||||||
|
<!--
|
||||||
|
This declares that this application uses the instrumentation test runner targeting
|
||||||
|
the package of com.fsck.k9. To run the tests use the command:
|
||||||
|
"adb shell am instrument -w com.fsck.k9.tests/android.test.InstrumentationTestRunner"
|
||||||
|
-->
|
||||||
|
<instrumentation android:name="android.test.InstrumentationTestRunner"
|
||||||
|
android:targetPackage="com.fsck.k9"
|
||||||
|
android:label="Tests for com.fsck.k9"/>
|
||||||
|
</manifest>
|
18
tests/build.properties
Normal file
18
tests/build.properties
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# This file is used to override default values used by the Ant build system.
|
||||||
|
#
|
||||||
|
# This file must be checked in Version Control Systems, as it is
|
||||||
|
# integral to the build system of your project.
|
||||||
|
|
||||||
|
# This file is only used by the Ant script.
|
||||||
|
|
||||||
|
# You can use this to override default values such as
|
||||||
|
# 'source.dir' for the location of your java source folder and
|
||||||
|
# 'out.dir' for the location of your output folder.
|
||||||
|
|
||||||
|
# You can also use it define how the release builds are signed by declaring
|
||||||
|
# the following properties:
|
||||||
|
# 'key.store' for the location of your keystore and
|
||||||
|
# 'key.alias' for the name of the key to use.
|
||||||
|
# The password will be asked during the build when you use the 'release' target.
|
||||||
|
|
||||||
|
tested.project.dir=../
|
84
tests/build.xml
Normal file
84
tests/build.xml
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project name="K9Test" default="help">
|
||||||
|
|
||||||
|
<!-- The local.properties file is created and updated by the 'android'
|
||||||
|
tool.
|
||||||
|
It contains the path to the SDK. It should *NOT* be checked into
|
||||||
|
Version Control Systems. -->
|
||||||
|
<property file="local.properties" />
|
||||||
|
|
||||||
|
<!-- The build.properties file can be created by you and is never touched
|
||||||
|
by the 'android' tool. This is the place to change some of the
|
||||||
|
default property values used by the Ant rules.
|
||||||
|
Here are some properties you may want to change/update:
|
||||||
|
|
||||||
|
source.dir
|
||||||
|
The name of the source directory. Default is 'src'.
|
||||||
|
out.dir
|
||||||
|
The name of the output directory. Default is 'bin'.
|
||||||
|
|
||||||
|
Properties related to the SDK location or the project target should
|
||||||
|
be updated using the 'android' tool with the 'update' action.
|
||||||
|
|
||||||
|
This file is an integral part of the build system for your
|
||||||
|
application and should be checked into Version Control Systems.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<property file="build.properties" />
|
||||||
|
|
||||||
|
<!-- The default.properties file is created and updated by the 'android'
|
||||||
|
tool, as well as ADT.
|
||||||
|
This file is an integral part of the build system for your
|
||||||
|
application and should be checked into Version Control Systems. -->
|
||||||
|
<property file="default.properties" />
|
||||||
|
|
||||||
|
<!-- Custom Android task to deal with the project target, and import the
|
||||||
|
proper rules.
|
||||||
|
This requires ant 1.6.0 or above. -->
|
||||||
|
<path id="android.antlibs">
|
||||||
|
<pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
|
||||||
|
<pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
|
||||||
|
<pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
|
||||||
|
</path>
|
||||||
|
|
||||||
|
<taskdef name="setup"
|
||||||
|
classname="com.android.ant.SetupTask"
|
||||||
|
classpathref="android.antlibs" />
|
||||||
|
|
||||||
|
<!-- extension targets. Uncomment the ones where you want to do custom work
|
||||||
|
in between standard targets -->
|
||||||
|
<!--
|
||||||
|
<target name="-pre-build">
|
||||||
|
</target>
|
||||||
|
<target name="-pre-compile">
|
||||||
|
</target>
|
||||||
|
|
||||||
|
[This is typically used for code obfuscation.
|
||||||
|
Compiled code location: ${out.classes.absolute.dir}
|
||||||
|
If this is not done in place, override ${out.dex.input.absolute.dir}]
|
||||||
|
<target name="-post-compile">
|
||||||
|
</target>
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Execute the Android Setup task that will setup some properties
|
||||||
|
specific to the target, and import the build rules files.
|
||||||
|
|
||||||
|
The rules file is imported from
|
||||||
|
<SDK>/platforms/<target_platform>/ant/ant_rules_r#.xml
|
||||||
|
|
||||||
|
To customize existing targets, there are two options:
|
||||||
|
- Customize only one target:
|
||||||
|
- copy/paste the target into this file, *before* the
|
||||||
|
<setup> task.
|
||||||
|
- customize it to your needs.
|
||||||
|
- Customize the whole script.
|
||||||
|
- copy/paste the content of the rules files (minus the top node)
|
||||||
|
into this file, *after* the <setup> task
|
||||||
|
- disable the import of the rules by changing the setup task
|
||||||
|
below to <setup import="false" />.
|
||||||
|
- customize to your needs.
|
||||||
|
-->
|
||||||
|
<setup />
|
||||||
|
|
||||||
|
</project>
|
11
tests/default.properties
Normal file
11
tests/default.properties
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# This file is automatically generated by Android Tools.
|
||||||
|
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||||
|
#
|
||||||
|
# This file must be checked in Version Control Systems.
|
||||||
|
#
|
||||||
|
# To customize properties used by the Ant build system use,
|
||||||
|
# "build.properties", and override values to adapt the script to your
|
||||||
|
# project structure.
|
||||||
|
|
||||||
|
# Project target.
|
||||||
|
target=android-9
|
36
tests/proguard.cfg
Normal file
36
tests/proguard.cfg
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
-optimizationpasses 5
|
||||||
|
-dontusemixedcaseclassnames
|
||||||
|
-dontskipnonpubliclibraryclasses
|
||||||
|
-dontpreverify
|
||||||
|
-verbose
|
||||||
|
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
||||||
|
|
||||||
|
-keep public class * extends android.app.Activity
|
||||||
|
-keep public class * extends android.app.Application
|
||||||
|
-keep public class * extends android.app.Service
|
||||||
|
-keep public class * extends android.content.BroadcastReceiver
|
||||||
|
-keep public class * extends android.content.ContentProvider
|
||||||
|
-keep public class * extends android.app.backup.BackupAgentHelper
|
||||||
|
-keep public class * extends android.preference.Preference
|
||||||
|
-keep public class com.android.vending.licensing.ILicensingService
|
||||||
|
|
||||||
|
-keepclasseswithmembernames class * {
|
||||||
|
native <methods>;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclasseswithmembernames class * {
|
||||||
|
public <init>(android.content.Context, android.util.AttributeSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclasseswithmembernames class * {
|
||||||
|
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclassmembers enum * {
|
||||||
|
public static **[] values();
|
||||||
|
public static ** valueOf(java.lang.String);
|
||||||
|
}
|
||||||
|
|
||||||
|
-keep class * implements android.os.Parcelable {
|
||||||
|
public static final android.os.Parcelable$Creator *;
|
||||||
|
}
|
21
tests/src/com/fsck/k9/activity/AccountsTest.java
Normal file
21
tests/src/com/fsck/k9/activity/AccountsTest.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package com.fsck.k9;
|
||||||
|
|
||||||
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
|
import com.fsck.k9.activity.Accounts;
|
||||||
|
/**
|
||||||
|
* This is a simple framework for a test of an Application. See
|
||||||
|
* {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
|
||||||
|
* how to write and extend Application tests.
|
||||||
|
* <p/>
|
||||||
|
* To run this test, you can type:
|
||||||
|
* adb shell am instrument -w \
|
||||||
|
* -e class com.fsck.k9.activity.AccountsTest \
|
||||||
|
* com.fsck.k9.tests/android.test.InstrumentationTestRunner
|
||||||
|
*/
|
||||||
|
public class AccountsTest extends ActivityInstrumentationTestCase2<Accounts> {
|
||||||
|
|
||||||
|
public AccountsTest() {
|
||||||
|
super("com.fsck.k9", Accounts.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,62 +1,62 @@
|
|||||||
package com.fsck.k9.helper;
|
package com.fsck.k9.helper;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
public class Utility_quoteAtoms extends TestCase
|
public class Utility_quoteAtoms extends TestCase
|
||||||
{
|
{
|
||||||
public void testNoQuote() {
|
public void testNoQuote() {
|
||||||
// Alpha
|
// Alpha
|
||||||
noQuote("a");
|
noQuote("a");
|
||||||
noQuote("aa");
|
noQuote("aa");
|
||||||
noQuote("aaa aaa");
|
noQuote("aaa aaa");
|
||||||
|
|
||||||
// Numeric
|
// Numeric
|
||||||
noQuote("1");
|
noQuote("1");
|
||||||
noQuote("12");
|
noQuote("12");
|
||||||
noQuote("123 456");
|
noQuote("123 456");
|
||||||
|
|
||||||
// Alpha Numeric
|
// Alpha Numeric
|
||||||
noQuote("abc 123");
|
noQuote("abc 123");
|
||||||
|
|
||||||
// Specials
|
// Specials
|
||||||
noQuote("!");
|
noQuote("!");
|
||||||
noQuote("#");
|
noQuote("#");
|
||||||
noQuote("$");
|
noQuote("$");
|
||||||
noQuote("%");
|
noQuote("%");
|
||||||
noQuote("&");
|
noQuote("&");
|
||||||
noQuote("'");
|
noQuote("'");
|
||||||
noQuote("*");
|
noQuote("*");
|
||||||
noQuote("+");
|
noQuote("+");
|
||||||
noQuote("-");
|
noQuote("-");
|
||||||
noQuote("/");
|
noQuote("/");
|
||||||
noQuote("=");
|
noQuote("=");
|
||||||
noQuote("?");
|
noQuote("?");
|
||||||
noQuote("^");
|
noQuote("^");
|
||||||
noQuote("_");
|
noQuote("_");
|
||||||
noQuote("`");
|
noQuote("`");
|
||||||
noQuote("{");
|
noQuote("{");
|
||||||
noQuote("|");
|
noQuote("|");
|
||||||
noQuote("}");
|
noQuote("}");
|
||||||
noQuote("~");
|
noQuote("~");
|
||||||
|
|
||||||
// Combos
|
// Combos
|
||||||
noQuote("bob barker! #1!");
|
noQuote("bob barker! #1!");
|
||||||
noQuote("!");
|
noQuote("!");
|
||||||
noQuote("#&#!");
|
noQuote("#&#!");
|
||||||
noQuote("{|}");
|
noQuote("{|}");
|
||||||
noQuote("'-=+=-'");
|
noQuote("'-=+=-'");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testQuote() {
|
public void testQuote() {
|
||||||
assertEquals("\"bob s. barker\"", quote("bob s. barker"));
|
assertEquals("\"bob s. barker\"", quote("bob s. barker"));
|
||||||
assertEquals("\":(\"", quote(":("));
|
assertEquals("\":(\"", quote(":("));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void noQuote(final String s) {
|
private void noQuote(final String s) {
|
||||||
assertEquals(s, Utility.quoteAtoms(s));
|
assertEquals(s, Utility.quoteAtoms(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String quote(final String s) {
|
private String quote(final String s) {
|
||||||
return Utility.quoteAtoms(s);
|
return Utility.quoteAtoms(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user