Skip to content

Commit 78aafe7

Browse files
author
luxiaoyu01
committed
release Cafe-3.1
1 parent 230d979 commit 78aafe7

File tree

27 files changed

+359
-58
lines changed

27 files changed

+359
-58
lines changed

downloads/Cafe-3.1.zip

434 KB
Binary file not shown.

testrunner/src/com/baidu/cafe/local/Log.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import android.test.ActivityInstrumentationTestCase2;
2323

24-
import com.baidu.cafe.remote.Armser;
25-
2624
/**
2725
2826
* @date 2011-6-13

testrunner/src/com/baidu/cafe/local/traveler/APPTraveler.java

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,37 +53,38 @@
5353
* @todo
5454
*/
5555
public class APPTraveler {
56-
public final static int MODE_PREORDER = 0;
57-
public final static int MODE_BREADTH_FIRST = 1;
58-
public final static int MODE_ACTIVITY = 2;
59-
public final static int MODE_GRID = 3;
60-
public final static int TRAVEL_MODE = MODE_PREORDER;
61-
62-
public static TreeNode<Operation> mRoot = null;
63-
public static boolean mCrashBeforeTravel = true;
64-
public static boolean mIsEnd = false;
65-
public static int mDisplayX = 0;
66-
public static int mDisplayY = 0;
67-
public static Armser remote = null;
68-
public static LocalLib local = null;
69-
public static String mUsername = null;
70-
public static String mPassword = null;
71-
72-
private final static int LOOP_MAX_LENGTH = 100;
73-
private final static int LOOP_MIN_LENGTH = 4;
74-
private final static int TIMEOUT_WAIT_FOR_SCREEN_SHOT = 1000 * 5;
75-
private final static int TRAVEL_TIME_OUT = 1000 * 60 * 30;
76-
private final static int MAX_TRAVEL_DEPTH = 3;
77-
private final static int RET_PASS = 0;
78-
private final static int RET_NOT_ENABLE = 1;
79-
private final static int RET_SHOULD_NOT_REPEAT = 2;
80-
private final static int RET_NOT_UNDOEN = 3;
81-
private final static int RET_NOT_AVAILABLE = 4;
82-
83-
private static int mScreenShotCounter = 1;
84-
private long mEnd = 0;
85-
private ArrayList<Operation> mAllOperations = new ArrayList<Operation>();
86-
private ArrayList<Operation> mOldOperations = new ArrayList<Operation>();
56+
public final static int MODE_PREORDER = 0;
57+
public final static int MODE_BREADTH_FIRST = 1;
58+
public final static int MODE_ACTIVITY = 2;
59+
public final static int MODE_GRID = 3;
60+
public final static int TRAVEL_MODE = MODE_PREORDER;
61+
62+
public static TreeNode<Operation> mRoot = null;
63+
public static boolean mCrashBeforeTravel = true;
64+
public static boolean mIsEnd = false;
65+
public static int mDisplayX = 0;
66+
public static int mDisplayY = 0;
67+
public static Armser remote = null;
68+
public static LocalLib local = null;
69+
public static String mUsername = null;
70+
public static String mPassword = null;
71+
72+
private final static int LOOP_MAX_LENGTH = 100;
73+
private final static int LOOP_MIN_LENGTH = 4;
74+
private final static int TIMEOUT_WAIT_FOR_SCREEN_SHOT = 1000 * 5;
75+
private final static int TIMEOUT_WAIT_FOR_LAUNCH_COMPLETED = 1000 * 10;
76+
private final static int TRAVEL_TIME_OUT = 1000 * 60 * 30;
77+
private final static int MAX_TRAVEL_DEPTH = 3;
78+
private final static int RET_PASS = 0;
79+
private final static int RET_NOT_ENABLE = 1;
80+
private final static int RET_SHOULD_NOT_REPEAT = 2;
81+
private final static int RET_NOT_UNDOEN = 3;
82+
private final static int RET_NOT_AVAILABLE = 4;
83+
84+
private static int mScreenShotCounter = 1;
85+
private long mEnd = 0;
86+
private ArrayList<Operation> mAllOperations = new ArrayList<Operation>();
87+
private ArrayList<Operation> mOldOperations = new ArrayList<Operation>();
8788

8889
public APPTraveler(Armser r, LocalLib l, String username, String password) {
8990
local = l;
@@ -111,9 +112,14 @@ private void init() {
111112
}
112113

113114
public void travel(int depth) {
115+
long end = System.currentTimeMillis() + TIMEOUT_WAIT_FOR_LAUNCH_COMPLETED;
114116
while (remote.getTopActivity().indexOf(CafeTestCase.mActivityClass.getName()) == -1) {
115117
local.sleep(1000);
116118
Logger.println("wait for " + CafeTestCase.mActivityClass.getName());
119+
if (System.currentTimeMillis() > end) {
120+
Logger.println("TIMEOUT_WAIT_FOR_LAUNCH_COMPLETED");
121+
break;
122+
}
117123
}
118124

119125
mCrashBeforeTravel = false;

testrunner/src/com/baidu/cafe/remote/Armser.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434

3535
import com.baidu.cafe.local.LocalLib;
3636

37+
/**
38+
* This is a interface-class to invoke functions of
39+
* com.baidu.cafe.remote.ArmsBinder.
40+
*
41+
42+
* @date 2011-06-20
43+
*/
3744
public class Armser {
3845

3946
private IRemoteArms iArms = null;

tests/TestCafe/src/com/example/demo/test/TestCafe.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
package com.example.demo.test;
22

3-
import java.util.ArrayList;
4-
53
import android.view.KeyEvent;
6-
import android.view.View;
74
import android.widget.Button;
85

96
import com.baidu.cafe.CafeTestCase;
10-
import com.baidu.cafe.local.LocalLib;
117
import com.baidu.cafe.local.Log;
128

139
/**

tests/TestRecord/src/com/example/demo/test/CafeReplay.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
package com.example.demo.test;
22

3-
import java.util.ArrayList;
4-
5-
import android.view.KeyEvent;
6-
import android.view.View;
7-
import android.widget.Button;
8-
93
import com.baidu.cafe.CafeTestCase;
10-
import com.baidu.cafe.local.LocalLib;
114

125
/**
136

tests/TestTravel/.classpath

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="gen"/>
5+
<classpathentry combineaccessrules="false" kind="src" path="/Demo"/>
6+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
7+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
8+
<classpathentry kind="lib" path="D:/workspace/TestCafe/libs/cafe.jar"/>
9+
<classpathentry kind="output" path="bin/classes"/>
10+
</classpath>

tests/TestTravel/.project

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

tests/TestTravel/Android.mk

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
LOCAL_PATH:= $(call my-dir)
2+
include $(CLEAR_VARS)
3+
4+
# We only want this apk build for tests.
5+
LOCAL_MODULE_TAGS := tests
6+
7+
LOCAL_DEX_PREOPT := false
8+
9+
LOCAL_JAVA_LIBRARIES := android.test.runner
10+
11+
LOCAL_STATIC_JAVA_LIBRARIES := libCafe
12+
13+
# Include all test java files.
14+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
15+
LOCAL_PACKAGE_NAME := {test_apk}
16+
17+
include $(BUILD_PACKAGE)
18+
19+
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libCafe:libs/cafe.jar
20+
21+
include $(BUILD_MULTI_PREBUILT)

tests/TestTravel/AndroidManifest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="{test_package}"
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="{target_package}" />
12+
13+
<instrumentation
14+
android:name="com.baidu.cafe.CafeTestRunner"
15+
android:targetPackage="{target_package}" />
16+
17+
<application
18+
android:icon="@drawable/ic_launcher"
19+
android:label="@string/app_name" >
20+
<uses-library android:name="android.test.runner" />
21+
</application>
22+
23+
</manifest>

0 commit comments

Comments
 (0)