Skip to content

Commit 75a24ce

Browse files
add screenshots for android tutorial
1 parent 94a1bfa commit 75a24ce

33 files changed

+252
-0
lines changed
Loading
88.4 KB
Loading
141 KB
Loading
74.3 KB
Loading
52.7 KB
Loading
59.4 KB
Loading
71.7 KB
Loading
209 KB
Loading
63.7 KB
Loading

java/sample/.classpath

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="gen"/>
5+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
7+
<classpathentry kind="lib" path="/media/work/workspace/iqa/java/out/iQA.Runtime.Instrument.jar"/>
8+
<classpathentry kind="lib" path="/media/work/workspace/iqa/java/out/iQA.Runtime.jar"/>
9+
<classpathentry kind="lib" path="/media/work/workspace/iqa/java/lib/antlr-runtime-3.4.jar"/>
10+
<classpathentry kind="lib" path="/media/work/workspace/iqa/java/lib/robotium-solo-3.1.jar"/>
11+
<classpathentry kind="output" path="bin/classes"/>
12+
</classpath>

java/sample/.project

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>tutorial</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.jdt.core.javabuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>

java/sample/AndroidManifest.xml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="cc.iqa.studio.demo.test"
4+
android:versionCode="1"
5+
android:versionName="1.0" >
6+
7+
<uses-sdk android:minSdkVersion="8" />
8+
9+
<instrumentation
10+
android:name="android.test.InstrumentationTestRunner"
11+
android:targetPackage="cc.iqa.studio.demo" />
12+
13+
<application
14+
android:icon="@drawable/ic_launcher"
15+
android:label="@string/app_name" >
16+
<uses-library android:name="android.test.runner" />
17+
</application>
18+
19+
</manifest>

java/sample/bin/classes.dex

273 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading
Loading

java/sample/bin/resources.ap_

10.2 KB
Binary file not shown.

java/sample/bin/tutorial.apk

135 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* AUTO-GENERATED FILE. DO NOT MODIFY.
2+
*
3+
* This class was automatically generated by the
4+
* aapt tool from the resource data it found. It
5+
* should not be modified by hand.
6+
*/
7+
8+
package cc.iqa.studio.demo.test;
9+
10+
public final class R {
11+
public static final class attr {
12+
}
13+
public static final class drawable {
14+
public static final int ic_launcher=0x7f020000;
15+
}
16+
public static final class layout {
17+
public static final int main=0x7f030000;
18+
}
19+
public static final class string {
20+
public static final int app_name=0x7f040001;
21+
public static final int hello=0x7f040000;
22+
}
23+
}

java/sample/proguard.cfg

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
-optimizationpasses 5
2+
-dontusemixedcaseclassnames
3+
-dontskipnonpubliclibraryclasses
4+
-dontpreverify
5+
-verbose
6+
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7+
8+
-keep public class * extends android.app.Activity
9+
-keep public class * extends android.app.Application
10+
-keep public class * extends android.app.Service
11+
-keep public class * extends android.content.BroadcastReceiver
12+
-keep public class * extends android.content.ContentProvider
13+
-keep public class * extends android.app.backup.BackupAgentHelper
14+
-keep public class * extends android.preference.Preference
15+
-keep public class com.android.vending.licensing.ILicensingService
16+
17+
-keepclasseswithmembernames class * {
18+
native <methods>;
19+
}
20+
21+
-keepclasseswithmembers class * {
22+
public <init>(android.content.Context, android.util.AttributeSet);
23+
}
24+
25+
-keepclasseswithmembers class * {
26+
public <init>(android.content.Context, android.util.AttributeSet, int);
27+
}
28+
29+
-keepclassmembers class * extends android.app.Activity {
30+
public void *(android.view.View);
31+
}
32+
33+
-keepclassmembers enum * {
34+
public static **[] values();
35+
public static ** valueOf(java.lang.String);
36+
}
37+
38+
-keep class * implements android.os.Parcelable {
39+
public static final android.os.Parcelable$Creator *;
40+
}

java/sample/project.properties

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system use,
7+
# "ant.properties", and override values to adapt the script to your
8+
# project structure.
9+
10+
# Project target.
11+
target=android-8
4.05 KB
Loading
1.68 KB
Loading
2.51 KB
Loading

java/sample/res/layout/main.xml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="fill_parent"
4+
android:layout_height="fill_parent"
5+
android:orientation="vertical" >
6+
7+
<TextView
8+
android:layout_width="fill_parent"
9+
android:layout_height="wrap_content"
10+
android:text="@string/hello" />
11+
12+
</LinearLayout>

java/sample/res/values/strings.xml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<string name="hello">Hello World!</string>
5+
<string name="app_name">Tutorial</string>
6+
7+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package cc.iqa.studio.demo.test;
2+
3+
4+
import java.io.*;
5+
import java.util.*;
6+
import org.antlr.runtime.*;
7+
8+
import junit.framework.Assert;
9+
import cc.iqa.iquery.*;
10+
import cc.iqa.iquery.android.*;
11+
12+
import com.jayway.android.robotium.solo.*;
13+
14+
import android.test.ActivityInstrumentationTestCase2;
15+
import android.view.*;
16+
17+
@SuppressWarnings("rawtypes")
18+
public class DemoOnlyTest extends ActivityInstrumentationTestCase2 {
19+
private static String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "cc.iqa.studio.demo.MainActivity";
20+
private static String TARGET_PACKAGE_ID = "cc.iqa.studio.demo";
21+
22+
private Solo _solo;
23+
24+
@SuppressWarnings("unchecked")
25+
public DemoOnlyTest() throws Exception {
26+
super(TARGET_PACKAGE_ID, Class
27+
.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME));
28+
}
29+
30+
public void setUp() throws Exception {
31+
this._solo = new Solo(this.getInstrumentation(), this.getActivity());
32+
}
33+
34+
public void testParseElement() throws Exception {
35+
List<ITreeNode> actual = parseQueryAgainst(
36+
_solo.getCurrentViews().get(0), "LinearLayout >> TextView");
37+
Assert.assertEquals(12, actual.size());
38+
39+
for (int i = 0; i < actual.size(); ++i) {
40+
Assert.assertTrue(actual.get(i).getName().endsWith("TextView"));
41+
}
42+
}
43+
44+
public void testParseAttribute() throws Exception {
45+
List<ITreeNode> actual = parseQueryAgainst(
46+
_solo.getCurrentViews().get(0),
47+
"LinearLayout >> TextView [mText = 'Down Under']");
48+
Assert.assertEquals(2, actual.size());
49+
50+
for (int i = 0; i < actual.size(); ++i) {
51+
Assert.assertTrue(actual.get(i).getName().endsWith("TextView"));
52+
Assert.assertEquals("Down Under", actual.get(i)
53+
.getProperty("mText").getValue());
54+
}
55+
}
56+
57+
public void testParseAttributeNegative() throws Exception {
58+
// remove supports to UNICODE attribute name for sake of consistent with iOS.
59+
List<ITreeNode> actual = parseQueryAgainst(
60+
_solo.getCurrentViews().get(0),
61+
"LinearLayout >> TextView [mText = 'Down Under']");
62+
Assert.assertEquals(2, actual.size());
63+
}
64+
65+
public void testSimpleCreatingParserMethod() throws Exception {
66+
iQueryParser parser = iQuery.createParser("LinearLayout >> TextView [mText = 'Down Under']");
67+
List<ITreeNode> candidates = new ArrayList<ITreeNode>();
68+
candidates.add(new SoloTreeNode(_solo.getCurrentViews().get(0)));
69+
List<ITreeNode> result = parser.query(candidates);
70+
71+
Assert.assertEquals(0, parser.getErrors().size());
72+
Assert.assertEquals(2, result.size());
73+
}
74+
75+
public void testSimplifiedAPI() throws Exception {
76+
List<SoloTreeNode> r1 = iQuery.query(
77+
new SoloTreeNode(_solo.getCurrentViews().get(0)),
78+
"LinearLayout >> TextView [mText = 'Down Under']");
79+
Assert.assertEquals(2, r1.size());
80+
}
81+
82+
private List<ITreeNode> parseQueryAgainst(View root, String iquery)
83+
throws IOException, RecognitionException {
84+
InputStream query = new ByteArrayInputStream(iquery.getBytes("utf8"));
85+
ANTLRInputStream input = new ANTLRInputStream(query);
86+
iQueryLexer lexer = new iQueryLexer(input);
87+
CommonTokenStream tokens = new CommonTokenStream(lexer);
88+
iQueryParser parser = new iQueryParser(tokens);
89+
90+
List<ITreeNode> candidates = new ArrayList<ITreeNode>();
91+
candidates.add(new SoloTreeNode(root));
92+
List<ITreeNode> result = parser.query(candidates);
93+
return result;
94+
}
95+
}

0 commit comments

Comments
 (0)