Android 工厂模式增加Type-A功能测试

Android 工厂模式增加Type-A功能测试

收到客户需求想要增加Type-A测试项来验证Type-A功能,具体功能实现参照如下:


/vendor/freeme/packages/apps/FreemeFactoryTest/src/com/freeme/factory/usb/TypeAUSB.java    
 

package com.freeme.factory.usb;

import android.os.Bundle;
import android.widget.TextView;

import java.io.File;

import android.os.Handler;

import com.freeme.factory.FactoryTest;
import com.freeme.factory.R;
import com.freeme.factory.base.BaseTest;

public class TypeAUSB extends BaseTest {
    private TextView mText;

    private final Runnable parseScanRunnable = new Runnable() {
        public void run() {
           test();
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.typea_usb);
        mText = (TextView) findViewById(R.id.text);
        mText.setText(R.string.typea_hint);
        testActionCompleted(false);
	Handler mHandler = new Handler();
        mHandler.postDelayed(parseScanRunnable, 1000);
        
    }

    public void test() {
        String mUSB0Path = "/dev/hidraw0";
        String mUSB1Path = "/dev/hidraw1";
        File usb0File = new File(mUSB0Path);
        File usb1File = new File(mUSB1Path);
        boolean usb0Exists = usb0File.exists();
        boolean usb1Exists = usb1File.exists();
        mText.setText("usb0Exists : " + usb0Exists + "\n" + "usb1Exists : " + usb1Exists);
        if (usb0File.exists() && usb1File.exists()) {
            mText.setText(R.string.typea_found);
            testActionCompleted(true);
            if (FactoryTest.getTestMode() != 0) {
                testResultCommit(true);
            }
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}

重新编译验证,修改生效,工厂模式Type-A功能验证通过

你可能感兴趣的:(Android,android)