Skip to content

Commit 3436f85

Browse files
committed
自动化 UI 测试:新增工具栏,新增对称分割线,完善录制和回放,优化性能,优化代码
1 parent 0697786 commit 3436f85

File tree

8 files changed

+1283
-753
lines changed

8 files changed

+1283
-753
lines changed

APIJSON-Android/APIJSONTest/app/src/main/java/apijson/demo/application/DemoApplication.java

Lines changed: 1067 additions & 682 deletions
Large diffs are not rendered by default.

APIJSON-Android/APIJSONTest/app/src/main/java/apijson/demo/ui/SelectActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public boolean onLongClick(View v) {
118118
}
119119

120120
DemoApplication.getInstance().onUIAutoActivityCreate(this);
121-
DemoApplication.getInstance().record();
121+
DemoApplication.getInstance().prepareRecord(this);
122122

123123
}
124124

APIJSON-Android/APIJSONTest/app/src/main/java/apijson/demo/ui/UIAutoActivity.java

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
import android.app.Activity;
1818
import android.content.Context;
1919
import android.content.Intent;
20-
import android.content.SharedPreferences;
2120
import android.os.Bundle;
22-
import android.os.Handler;
2321
import android.view.MotionEvent;
2422
import android.view.View;
2523
import android.view.Window;
@@ -31,7 +29,6 @@
3129

3230
import apijson.demo.R;
3331
import apijson.demo.application.DemoApplication;
34-
import zuo.biao.apijson.JSON;
3532

3633

3734
/**自动 UI 测试,需要用 UIAuto 发请求到这个设备
@@ -118,7 +115,6 @@ public static Intent createIntent(Context context, String list) {
118115

119116
private JSONArray touchList;
120117

121-
SharedPreferences cache;
122118
private long flowId = 0;
123119
@Override
124120
protected void onCreate(Bundle savedInstanceState) {
@@ -132,7 +128,7 @@ protected void onCreate(Bundle savedInstanceState) {
132128

133129

134130
flowId = getIntent().getLongExtra(INTENT_FLOW_ID, flowId);
135-
touchList = JSON.parseArray(getIntent().getStringExtra(INTENT_TOUCH_LIST));
131+
//太卡 touchList = JSON.parseArray(getIntent().getStringExtra(INTENT_TOUCH_LIST));
136132

137133
//
138134
// DisplayMetrics outMetrics = new DisplayMetrics();
@@ -157,7 +153,7 @@ protected void onCreate(Bundle savedInstanceState) {
157153

158154
if (touchList != null && touchList.isEmpty() == false) { //TODO 回放操作
159155
// recover(touchList);
160-
startActivityForResult(UIAutoListActivity.createIntent(DemoApplication.getInstance(), touchList == null ? null : touchList.toJSONString()), REQUEST_UI_AUTO_LIST);
156+
startActivity(UIAutoListActivity.createIntent(DemoApplication.getInstance(), touchList == null ? null : touchList.toJSONString()));
161157
// return;
162158
}
163159

@@ -364,11 +360,11 @@ public void onClick(View v) {
364360
}
365361

366362
public void toRemote(View v) {
367-
startActivityForResult(UIAutoListActivity.createIntent(context, false), REQUEST_UI_AUTO_LIST);
363+
startActivity(UIAutoListActivity.createIntent(context, false));
368364
}
369365

370366
public void toLocal(View v) {
371-
startActivityForResult(UIAutoListActivity.createIntent(context, true), REQUEST_UI_AUTO_LIST);
367+
startActivity(UIAutoListActivity.createIntent(context, true));
372368
}
373369

374370
public void record(View v) {
@@ -379,7 +375,7 @@ public void record(View v) {
379375
// finish();
380376

381377
DemoApplication.getInstance().onUIAutoActivityCreate(this);
382-
DemoApplication.getInstance().record();
378+
DemoApplication.getInstance().prepareRecord(this);
383379
finish();
384380
}
385381

@@ -806,35 +802,7 @@ public void record(View v) {
806802
// return touchList;
807803
// }
808804

809-
810-
811-
public static final int REQUEST_UI_AUTO_LIST = 1;
812-
813-
@Override
814-
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
815-
super.onActivityResult(requestCode, resultCode, data);
816-
817-
if (resultCode != RESULT_OK) {
818-
return;
819-
}
820-
821-
if (requestCode == REQUEST_UI_AUTO_LIST) {
822-
JSONArray array = data == null ? null : JSON.parseArray(data.getStringExtra(UIAutoListActivity.RESULT_LIST));
823-
finish();
824-
825-
new Handler().postDelayed(new Runnable() {
826-
@Override
827-
public void run() {
828-
touchList = new JSONArray();
829-
DemoApplication.getInstance().recover(array);
830-
}
831-
}, 1000);
832-
}
833-
834-
}
835-
836-
837-
//
805+
//
838806
// private static class Node<E> {
839807
// E item;
840808
// Node<E> next;

0 commit comments

Comments
 (0)