Search in sources :

Example 1 with DevicesView

use of com.tencent.wstt.apt.ui.views.DevicesView in project GT by Tencent.

the class GetCurCheckedStateUtil method update.

/**
	* @Description 按照设置和设备视图中的更改更新CPU和内存视图中的曲线 
	* @param    
	* @return void 
	* @throws
	 */
public static void update() {
    SettingView settingViewPart = (SettingView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(SettingView.ID);
    DevicesView deviceViewPart = (DevicesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(DevicesView.ID);
    CPUView cpuViewPart = (CPUView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(CPUView.ID);
    MemoryView memViewPart = (MemoryView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(MemoryView.ID);
    if (deviceViewPart == null || settingViewPart == null) {
        return;
    }
    boolean[] pkgCheckeds = deviceViewPart.getPkgChecked();
    if (cpuViewPart != null) {
        for (int i = 0; i < pkgCheckeds.length; i++) {
            cpuViewPart.cpuRealTimeChart.setTimeSeriesEnable(i, 0, pkgCheckeds[i]);
        }
        //当启动APT后,直接打开log,此时tableviewfilter为空
        if (cpuViewPart.cpuTableFilter != null) {
            ((TableViewFilter) cpuViewPart.cpuTableFilter).update(pkgCheckeds, new boolean[] { true });
            cpuViewPart.cpuViewer.refresh();
        }
        if (TestSence.getInstance().isTestJiffies) {
            if (cpuViewPart.jiffiesTableFilter != null) {
                ((TableViewFilter) cpuViewPart.jiffiesTableFilter).update(pkgCheckeds, new boolean[] { true });
                cpuViewPart.jiffiesViewer.refresh();
            }
        }
    }
    if (memViewPart != null) {
        boolean[] memStateCheckeds = settingViewPart.getMemChecked();
        //更新曲线
        for (int i = 0; i < pkgCheckeds.length; i++) {
            for (int j = 0; j < memStateCheckeds.length; j++) {
                memViewPart.memRealTimeChart.setTimeSeriesEnable(i, j, pkgCheckeds[i] && memStateCheckeds[j]);
            }
        }
        //更新统计表格
        if (memViewPart.tableFilter != null) {
            ((TableViewFilter) memViewPart.tableFilter).update(pkgCheckeds, memStateCheckeds);
            memViewPart.viewer.refresh();
        }
    }
}
Also used : MemoryView(com.tencent.wstt.apt.ui.views.MemoryView) SettingView(com.tencent.wstt.apt.ui.views.SettingView) CPUView(com.tencent.wstt.apt.ui.views.CPUView) DevicesView(com.tencent.wstt.apt.ui.views.DevicesView)

Example 2 with DevicesView

use of com.tencent.wstt.apt.ui.views.DevicesView in project GT by Tencent.

the class APTState method setUIEnable.

/**
	 * 设置UI控件是否可用;主要包括三类控件
	* @Title: setUIEnable  
	* @Description:   
	* @param isEnable 
	* void 
	* @throws
	 */
private boolean setUIEnable(boolean isEnable) {
    SettingView settingViewPart = (SettingView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(SettingView.ID);
    DevicesView deviceViewPart = (DevicesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(DevicesView.ID);
    if (settingViewPart == null || deviceViewPart == null) {
        APTConsoleFactory.getInstance().APTPrint("setUIEnable:Setting或者Device视图对象为空");
        return false;
    }
    /**
		 * 测试开关和测试周期
		 */
    for (int i = 0; i < Constant.TEST_ITEM_COUNT; i++) {
        settingViewPart.itemTestSwitch[i].setEnabled(isEnable);
        settingViewPart.itemTestSwitchClose[i].setEnabled(isEnable);
        settingViewPart.itemTestPeriod[i].setEnabled(isEnable);
    }
    /**
		 * CPU测试方式和是否测试jiffies
		 */
    settingViewPart.cpuTestMethod.setEnabled(isEnable);
    settingViewPart.jiffiesSwitch.setEnabled(isEnable);
    settingViewPart.hprofDumpSwitch.setEnabled(isEnable);
    settingViewPart.hprofDumpThreshold.setEnabled(isEnable);
    /**
		 * 禁止进程列表增删操作,包括手动添加
		 */
    deviceViewPart.setAddAndDelOperEnable(isEnable);
    /**
		 * 其他三个按钮
		 */
    deviceViewPart.refreshAction.setEnabled(isEnable);
    deviceViewPart.openLogWithChartAction.setEnabled(isEnable);
    deviceViewPart.openResultDirAction.setEnabled(isEnable);
    return true;
}
Also used : SettingView(com.tencent.wstt.apt.ui.views.SettingView) DevicesView(com.tencent.wstt.apt.ui.views.DevicesView)

Example 3 with DevicesView

use of com.tencent.wstt.apt.ui.views.DevicesView in project GT by Tencent.

the class APTState method DealWithEventBefore_Configuration.

private void DealWithEventBefore_Configuration(APTEventEnum event) {
    switch(event) {
        case CONFIGRURE_OPER:
            break;
        case START_OPER:
            break;
        case STOP_OPER:
            APTConsoleFactory.getInstance().APTPrint("配置状态下不可能接收停止事件");
            StatusBar.getInstance().showInfo("配置状态下不可能接收停止事件");
            break;
        case OPENLOG_OPER:
            //TODO:这里有没有必要把所有的配置进行归位;至少要进行的操作应该是把被测进程列表中的进程清除
            DevicesView deviceViewPart = (DevicesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(DevicesView.ID);
            if (deviceViewPart == null) {
                APTConsoleFactory.getInstance().APTPrint("setUIEnable:Setting或者Device视图对象为空");
                return;
            }
            deviceViewPart.clearTargetPkgTableViewerForUIThread();
            break;
        default:
            APTConsoleFactory.getInstance().APTPrint("配置状态default");
            StatusBar.getInstance().showInfo("配置状态default");
            break;
    }
}
Also used : DevicesView(com.tencent.wstt.apt.ui.views.DevicesView)

Example 4 with DevicesView

use of com.tencent.wstt.apt.ui.views.DevicesView in project GT by Tencent.

the class APTState method setCheckBoxsEnable.

/**
	 * 控制内存曲线、进程显示按钮是否可用
	* @Title: setCheckBoxsEnable  
	* @Description:   
	* @param isEnable 
	* void 
	* @throws
	 */
private boolean setCheckBoxsEnable(boolean isEnable) {
    SettingView settingViewPart = (SettingView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(SettingView.ID);
    DevicesView deviceViewPart = (DevicesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(DevicesView.ID);
    if (settingViewPart == null || deviceViewPart == null) {
        APTConsoleFactory.getInstance().APTPrint("setCheckBoxsEnable:Setting或者Device视图对象为空");
        return false;
    }
    deviceViewPart.setCheckChangeEnable(isEnable);
    settingViewPart.setCheckChangeEnable(isEnable);
    return true;
}
Also used : SettingView(com.tencent.wstt.apt.ui.views.SettingView) DevicesView(com.tencent.wstt.apt.ui.views.DevicesView)

Example 5 with DevicesView

use of com.tencent.wstt.apt.ui.views.DevicesView in project GT by Tencent.

the class TestTaskManager method initTest.

/**
	* @Title: initTest  
	* @Description: 根据测试场景配置来初始化测试   
	* void 
	* @throws
	 */
public boolean initTest() {
    clear();
    //获取进程列表
    int pkgNumber = TestSence.getInstance().pkgInfos.size();
    String[] pkgNames = new String[pkgNumber];
    String[] pkgAbbreviation = new String[pkgNumber];
    //取进程名的后缀
    for (int i = 0; i < pkgNumber; i++) {
        pkgNames[i] = TestSence.getInstance().pkgInfos.get(i).contents[PkgInfo.NAME_INDEX];
        int index = pkgNames[i].lastIndexOf(".");
        ;
        pkgAbbreviation[i] = pkgNames[i].substring(index + 1, pkgNames[i].length());
    }
    CPUView cpuViewPart = (CPUView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(CPUView.ID);
    MemoryView memViewPart = (MemoryView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(MemoryView.ID);
    //设置当前测试场景的结果保存目录
    Date curDate = new Date(System.currentTimeMillis());
    TestSence.getInstance().curDir = Constant.SIMPLE_DATE_FORMAT_SECOND.format(curDate);
    APTConsoleFactory.getInstance().APTPrint("测试开始时间:" + TestSence.getInstance().curDir);
    if (TestSence.getInstance().itemTestSwitch[Constant.CPU_INDEX]) {
        if (cpuViewPart == null) {
            return false;
        }
        //打开文件
        if (!(WriteFileUtil.getInstance().openWriteFile(TestSence.getInstance().curDir, Constant.TEXT_ITEM_TITLES[Constant.CPU_INDEX], TestSence.bufThreshold[0]))) {
            APTConsoleFactory.getInstance().APTPrint("创建CPU结果文件失败");
            return false;
        }
        //写文件头
        if (!APTLogFileParse.writeAPTLogFileHeader(Constant.CPU_INDEX)) {
            APTConsoleFactory.getInstance().APTPrint("写CPU文件头部失败");
            return false;
        }
        cpuViewPart.cpuRealTimeChart.initDataset(pkgAbbreviation, new String[] { Constant.CPU_ITEM_TITLES[Constant.CPU_PERSENT_INDEX] });
        DataProvider dataProvider = new CPUProvider(pkgNames, DeviceInfo.getInstance().androidVersion, TestSence.getInstance().cpuTestMethod);
        dataProvider.attach(new ChartObserver(cpuViewPart.cpuRealTimeChart));
        dataProvider.attach(new TableAllDataObserver(cpuViewPart.cpuViewer, pkgAbbreviation, new String[] { Constant.CPU_ITEM_TITLES[Constant.CPU_PERSENT_INDEX] }));
        dataProvider.attach(new FileObserver(Constant.TEXT_ITEM_TITLES[Constant.CPU_INDEX]));
        TestTask tt = new TestTask(dataProvider, TestSence.getInstance().itemTestPeriod[Constant.CPU_INDEX]);
        addTestTask(tt);
        cpuViewPart.setCpuTableViewerFilter(new TableViewFilter(pkgAbbreviation, new String[] { Constant.CPU_ITEM_TITLES[Constant.CPU_PERSENT_INDEX] }));
        if (TestSence.getInstance().isTestJiffies) {
            DevicesView dv = (DevicesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(DevicesView.ID);
            if (dv == null) {
                return false;
            }
            List<PkgInfo> pkgInfos = TestSence.getInstance().pkgInfos;
            String[] pids = new String[pkgInfos.size()];
            for (int i = 0; i < pids.length; i++) {
                pids[i] = pkgInfos.get(i).contents[PkgInfo.PID_INDEX];
            }
            DataProvider jiffiesDataProvider = new JiffiesProviderNew(pkgNumber);
            cpuViewPart.setJiffiesTableViewerFilter(new TableViewFilter(pkgAbbreviation, new String[] { Constant.CPU_ITEM_TITLES[Constant.CPU_JIFFIES_INDEX] }));
            //jiffiesDataProvider.attach(new TableAllDataObserver(cpuViewPart.jiffiesViewer, pkgAbbreviation, new String[]{Constant.CPU_ITEM_TITLES[Constant.CPU_JIFFIES_INDEX]}));
            jiffiesDataProvider.attach(new JiffiesTableObserver(cpuViewPart.jiffiesViewer, pkgAbbreviation));
            jiffiesDataProvider.attach(new PidUpdateObserver(dv.targetPkgTableViewer, pids));
            TestTask jiffiesTT = new TestTask(jiffiesDataProvider, TestSence.getInstance().itemTestPeriod[Constant.CPU_INDEX]);
            addTestTask(jiffiesTT);
        }
        APTConsoleFactory.getInstance().APTPrint("CPU测试Ready");
    }
    //内存测试
    if (TestSence.getInstance().itemTestSwitch[Constant.MEM_INDEX]) {
        if (memViewPart == null) {
            return false;
        }
        //打开文件
        if (!(WriteFileUtil.getInstance().openWriteFile(TestSence.getInstance().curDir, Constant.TEXT_ITEM_TITLES[Constant.MEM_INDEX], TestSence.bufThreshold[1]))) {
            APTConsoleFactory.getInstance().APTPrint("创建内存结果文件失败");
            return false;
        }
        //写文件头
        if (!APTLogFileParse.writeAPTLogFileHeader(Constant.MEM_INDEX)) {
            APTConsoleFactory.getInstance().APTPrint("写内存文件头部失败");
            return false;
        }
        //填充数据
        memViewPart.memRealTimeChart.initDataset(pkgAbbreviation, Constant.MEM_ITEM_TITLES);
        memViewPart.setTableViewerFilter(new TableViewFilter(pkgAbbreviation, Constant.MEM_ITEM_TITLES));
        //初始化内存视图的数据提供者
        DataProvider dataProvider = new MemProvider(pkgNames, DeviceInfo.getInstance().androidVersion);
        //主持内存数据的观察者
        dataProvider.attach(new ChartObserver(memViewPart.memRealTimeChart));
        dataProvider.attach(new TableAllDataObserver(memViewPart.viewer, pkgAbbreviation, Constant.MEM_ITEM_TITLES));
        dataProvider.attach(new FileObserver(Constant.TEXT_ITEM_TITLES[Constant.MEM_INDEX]));
        if (TestSence.getInstance().isDumpHprof) {
            dataProvider.attach(new HprofDumpObserver(pkgNames));
        }
        //构建测试任务
        TestTask tt = new TestTask(dataProvider, TestSence.getInstance().itemTestPeriod[Constant.MEM_INDEX]);
        addTestTask(tt);
        memViewPart.setTableViewerFilter(new TableViewFilter(pkgAbbreviation, Constant.MEM_ITEM_TITLES));
        APTConsoleFactory.getInstance().APTPrint("内存测试Ready");
    }
    APTConsoleFactory.getInstance().APTPrint("开始测试更新");
    GetCurCheckedStateUtil.update();
    return true;
}
Also used : PidUpdateObserver(com.tencent.wstt.apt.chart.PidUpdateObserver) MemoryView(com.tencent.wstt.apt.ui.views.MemoryView) ChartObserver(com.tencent.wstt.apt.chart.ChartObserver) MemProvider(com.tencent.wstt.apt.chart.MemProvider) JiffiesProviderNew(com.tencent.wstt.apt.chart.JiffiesProviderNew) TableAllDataObserver(com.tencent.wstt.apt.chart.TableAllDataObserver) Date(java.util.Date) FileObserver(com.tencent.wstt.apt.chart.FileObserver) TableViewFilter(com.tencent.wstt.apt.util.TableViewFilter) DataProvider(com.tencent.wstt.apt.chart.DataProvider) HprofDumpObserver(com.tencent.wstt.apt.chart.HprofDumpObserver) CPUView(com.tencent.wstt.apt.ui.views.CPUView) JiffiesTableObserver(com.tencent.wstt.apt.chart.JiffiesTableObserver) CPUProvider(com.tencent.wstt.apt.chart.CPUProvider) DevicesView(com.tencent.wstt.apt.ui.views.DevicesView)

Aggregations

DevicesView (com.tencent.wstt.apt.ui.views.DevicesView)9 SettingView (com.tencent.wstt.apt.ui.views.SettingView)4 PkgInfo (com.tencent.wstt.apt.data.PkgInfo)2 CPUView (com.tencent.wstt.apt.ui.views.CPUView)2 MemoryView (com.tencent.wstt.apt.ui.views.MemoryView)2 TableItem (org.eclipse.swt.widgets.TableItem)2 CPUProvider (com.tencent.wstt.apt.chart.CPUProvider)1 ChartObserver (com.tencent.wstt.apt.chart.ChartObserver)1 DataProvider (com.tencent.wstt.apt.chart.DataProvider)1 FileObserver (com.tencent.wstt.apt.chart.FileObserver)1 HprofDumpObserver (com.tencent.wstt.apt.chart.HprofDumpObserver)1 JiffiesProviderNew (com.tencent.wstt.apt.chart.JiffiesProviderNew)1 JiffiesTableObserver (com.tencent.wstt.apt.chart.JiffiesTableObserver)1 MemProvider (com.tencent.wstt.apt.chart.MemProvider)1 PidUpdateObserver (com.tencent.wstt.apt.chart.PidUpdateObserver)1 TableAllDataObserver (com.tencent.wstt.apt.chart.TableAllDataObserver)1 TableViewFilter (com.tencent.wstt.apt.util.TableViewFilter)1 Date (java.util.Date)1