optimize memory and image size. remove unnecessary language file

This commit is contained in:
hyb1996
2017-05-10 15:42:58 +08:00
parent e5ade55519
commit 1222e00adc
77 changed files with 590 additions and 436 deletions

View File

@@ -1,8 +1,13 @@
package com.stardust.autojs;
import android.app.Instrumentation;
import android.app.UiAutomation;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.uiautomator.UiDevice;
import android.view.InputEvent;
import android.test.ActivityInstrumentationTestCase2;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@@ -11,9 +11,9 @@ module.exports = function(__runtime__, scope){
return eval(console.rawInput.call(console, [].slice(arguments)) + "");
}
scope.print = console.log.bind(console);
scope.print = console.print.bind(console, android.util.Log.DEBUG);
scope.log = scope.print;
scope.log = console.log.bind(console);
scope.err = console.error.bind(console);

View File

@@ -3,7 +3,7 @@
module.exports = function(__runtime__, scope){
scope.SetScreenMetrics = function(w, h){
__runtime__.getRootShell().SetScreenMetrics(x, y);
__runtime__.getRootShell().SetScreenMetrics(w, h);
}
scope.Tap = function(x, y){

View File

@@ -1,9 +1,103 @@
assert = console.assert.bind(console);
function test(){
//testInput();
///sleep(500);
//testLongClick();
//sleep(500);
testScrollAndShow();
}
Function.prototype.getName = function(){
return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]
}
assert = function(){
if(arguments.length == 1){
if(!arguments[0]){
throw new Error("Assertion fail");
}
return;
}
if(arguments[0] != arguments[1]){
var msg = "Assertion fail: " + arguments[0] + " != " + arguments[1];
throw new Error(msg);
}
}
function testInput(){
log("testInput...");
id("add").findOne().click();
while(!click("新建文件"));
for(var i = 0; i < 9; i++){
input(i);
}
sleep(200);
assert('请输入名称012345678', editable().findOne().text());
sleep(400);
back();
sleep(200);
back();
sleep(200);
back();
}
function random(){
return ("" + Math.random()).substring(2);
}
function testLongClick(){
log("testLongClick...");
id("script_list_recycler_view").findOne().child(0).longClick();
while(!click("重命名"));
sleep(200);
var r = random();
editable().setText(r);
sleep(200);
while(!click("确定"));
sleep(200);
assert(text(r).exists());
}
function newFile(name){
name = name + random();
id("add").findOne().click();
sleep(400);
while(!click("新建文件"));
sleep(400);
editable().setText(name);
sleep(400);
while(!click("确定"));
sleep(500);
back();
sleep(200);
back();
return name;
}
function testScrollAndShow(){
var name1 = newFile("zzz");
for(var i = 0; i < 10; i++){
id("script_list_recycler_view").scrollForward();
}
assert(text(name1).findOne().visibleToUser());
sleep(500);
var name2 = newFile("000");
sleep(200);
for(var i = 0; i < 10; i++){
id("script_list_recycler_view").scrollForward();
}
sleep(500);
text(name2).findOne().show();
assert(text(name2).findOne().visibleToUser());
}
function testApp(){
print('正在测试模块app');
before();
assert("com.tencent.mm" == app.getPackageName("微信"));
assert("com.tencent.mobileqq" == app.getPackageName("QQ"));
}
}
module.exports = test;

View File

@@ -4,7 +4,6 @@ import android.support.annotation.Nullable;
import android.util.Log;
import com.stardust.autojs.runtime.ScriptStopException;
import com.stardust.autojs.runtime.api.Console;
/**
* Created by Stardust on 2017/5/1.
@@ -24,6 +23,12 @@ public abstract class AbstractConsole implements Console {
return String.format(data.toString(), options);
}
@Override
public void print(int level, Object data, Object... options) {
write(level, format(data, options));
}
protected abstract void write(int level, CharSequence data);
@Override
public void verbose(@Nullable Object data, Object... options) {

View File

@@ -16,6 +16,9 @@ public interface Console {
@ScriptInterface
void log(@Nullable Object data, Object... options);
@ScriptInterface
void print(int level, Object data, Object... options);
@ScriptInterface
void info(@Nullable Object data, Object... options);

View File

@@ -151,7 +151,6 @@ public class UiSelector extends UiGlobalSelector {
} else {
super.id(id);
}
Intent intent;
return this;
}
@@ -160,6 +159,11 @@ public class UiSelector extends UiGlobalSelector {
return untilFind().performAction(action, arguments);
}
public boolean exists() {
UiObjectCollection collection = find();
return collection != null && collection.size() > 0;
}
@ScriptInterface
public boolean click() {
return performAction(ACTION_CLICK);