package com.example.demo.test;

import java.util.ArrayList;

import android.view.KeyEvent;
import android.widget.Button;

import com.baidu.cafe.CafeTestCase;
import com.baidu.cafe.local.LocalLib;
import com.baidu.cafe.local.Log;
import com.baidu.cafe.local.NetworkUtils;

/**
 * @author luxiaoyu01@baidu.com
 * @date 2012-6-27
 * @version
 * @todo
 */
public class TestCafe extends CafeTestCase {
    private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.baidu.news.MainActivity";
    private static Class<?>     launcherActivityClass;
    private static final String TARGET_PACKAGE                   = "com.baidu.news";
    static {
        try {
            launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    public TestCafe() {
        super(TARGET_PACKAGE, launcherActivityClass);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
    }

    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    /**
     * NOTICE: caseǰҪcafe_setup.bat
     */
    public void test_sample() {
        local.beginRecordCode();
        local.sleep(2000000);
    }

    private void history() {
        Log.i("###", "" + new NetworkUtils().getPackageRcv("com.baidu.BaiduMap"));
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Log.i("###", "" + new NetworkUtils().getPackageRcv("com.baidu.BaiduMap"));
        remote.pressKey(KeyEvent.KEYCODE_HOME);
        //
        remote.pressKey(KeyEvent.KEYCODE_POWER);
        //
        remote.pressKey(KeyEvent.KEYCODE_VOLUME_DOWN);
        //˵
        remote.pressKey(KeyEvent.KEYCODE_MENU);
        //ؼ
        remote.pressKey(KeyEvent.KEYCODE_BACK);
        //
        remote.pressKey(KeyEvent.KEYCODE_SEARCH);
        //жsd
        remote.unmount();
        //װsd
        remote.mount();
        //ɱ̨
        remote.killBackgroundProcesses("com.android.launcher");
        //Ӧ
        remote.launchActivity("com.android.launcher");
        //ַ
        local.enterText(0, "Cafe");//0ʾһ
        //
        //        local.clickLongOnView(fakeView);
        local.clickLongInList(1);
        local.clickLongOnText("Cafe");
        local.clickLongOnScreen(100, 100);
        //֣κοؼϵ֣
        local.clickOnText("Cafe");
        //ȡؼ
        local.getCurrentViews(Button.class);
        //ȡlogcat
        String[] logs = remote.getLog();
        //ȡ
        remote.getBatteryLevel();
        //ȡ
        remote.getScreenBrightness();
        //(0,0)϶(100,100)
        local.drag(0, 100, 0, 100, 10);
        //ŴС
        /**
         * zoom screen
         * 
         * @param start
         *            the start position e.g. new int[]{0,0,1,2}; means two
         *            pointers start at {0,0} and {1,2}
         * @param end
         *            the end position e.g. new int[]{100,110,200,220}; means
         *            two pointers end at {100,110} and {200,220}
         */
        local.zoom(new int[] { 0, 0, 1, 2 }, new int[] { 100, 110, 200, 220 });
        //̵
        remote.clickViewByText("ͨѶ¼");
        if (remote.waitForActivity("com.android.contacts.DialtactsContactsEntryActivity", 5000)) {
            Log.i("at com.android.contacts.DialtactsContactsEntryActivity");
        }
    }
}

@@ -225,50 +225,8 @@
 Log;
-%0Aimport com.baidu.cafe.local.NetworkUtils;
 %0A%0A/*
@@ -1261,306 +1261,8 @@
 ) %7B%0A
-        Log.i(%22###%22, %22%22 + new NetworkUtils().getPackageRcv(%22com.baidu.BaiduMap%22));%0A        try %7B%0A            Thread.sleep(5000);%0A        %7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        Log.i(%22###%22, %22%22 + new NetworkUtils().getPackageRcv(%22com.baidu.BaiduMap%22));%0A
     

add OutputEvent.java