import org.tizen.dynamicanalyzer.communicator.DeviceInfo;
import org.tizen.dynamicanalyzer.communicator.DeviceManager;
import org.tizen.dynamicanalyzer.handlers.CommandAction;
+import org.tizen.dynamicanalyzer.handlers.CommonAction;
import org.tizen.dynamicanalyzer.handlers.UIActionHolder;
+import org.tizen.dynamicanalyzer.nl.ConfigureLabels;
+import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
import org.tizen.dynamicanalyzer.project.AppInfo;
import org.tizen.dynamicanalyzer.project.PackageInfo;
+import org.tizen.dynamicanalyzer.setting.FlatPreferences;
import org.tizen.dynamicanalyzer.setting.PrimitiveFeature;
import org.tizen.dynamicanalyzer.setting.SettingDataManager;
import org.tizen.dynamicanalyzer.setting.TargetData;
* @param features set of features to be enabled.
* @return was operation successful or not.
*/
- private static boolean selectFeatures(Set<PrimitiveFeature> features) {
+ private static boolean selectFeatures(TracingArguments args) {
+ selectScreenshotFeature(args.getScreenshotPeriod(),
+ args.isScreenshotPeriodSpecified());
+ args.getFeatures().remove(PrimitiveFeature.SCREENSHOT);//This feature added to target by selectScreenshotFeature().
+
TargetData target = SettingDataManager.INSTANCE.getTarget(null);
- Set<String> selectedChartSet = new HashSet<String>();
- for (PrimitiveFeature feature : features) {
+ for (PrimitiveFeature feature : args.getFeatures()) {
target.addSelectedFlatFeature(feature.getName());
- selectedChartSet.add(feature.getChart());
+ UILayoutDataManager.INSTANCE.addSelectedChart(feature.getChart());
}
- UILayoutDataManager.INSTANCE.setSelectedChartSet(selectedChartSet);
return true;
}
/**
+ * Enables screenshot onSceneTransition or periodically.
+ *
+ * @param period period in seconds, onSceneTransition if period == 0.
+ * @return was operation successful or not.
+ */
+ private static void selectScreenshotFeature(int period,
+ boolean isScreenshotsEnabled) {
+ // TODO move this to common place for CLI and GUI
+ if (!isScreenshotsEnabled) {
+ Logger.debug("Screenshots are not captured.");
+ return;
+ }
+
+ if (period == 0){
+ TargetData target = SettingDataManager.INSTANCE.getTarget(null);
+ target.addSelectedFlatFeature(ConfigureLabels.FEATURE_NAME_SCREENSHOT);
+ Logger.debug("Screenshots are captured on scene transition.");
+ }
+
+ if (period > 0){
+ SettingDataManager.INSTANCE.addOptionsSelectedPreference(
+ FlatPreferences.SCREENSHOT_PERIODICALLY, period);
+ Logger.debug("Screenshots are captured every " + period + " sec.");
+ }
+ UILayoutDataManager.INSTANCE
+ .addSelectedChart(TimelineChartLabels.SCREENSHOT_CHART_TITLE);
+ return;
+ }
+
+ /**
* Helper function for packages list extraction from selected device.
*
* @param dev IDevice object presenting selected device
}
Logger.debug("Set current app: " + args.getApplication());
- if (!selectFeatures(args.getFeatures())) {
+ if (!selectFeatures(args)) {
Logger.debug("Failed to select features");
return ErrorCode.ERR_EXCEPTION_OCCURRED;
}
- Logger.debug("Set features: "
- + Arrays.asList(args.getFeatures().toArray()));
+ Logger.debug("Set features: " + Arrays.asList(args.getFeatures().toArray()));
// Create all needed data managers before
UIActionHolder.getUIAction().setUIElementsBySetting();
+ CommonAction.configure(); // TODO move this to common place for CLI and GUI
CommandAction.startTrace(false);
Logger.debug("Tracing started");
private File output; // file with tracing output
// TODO duration actually is not supported yet by CLI, always set to 0
private long durationSec; // tracing duration in seconds (0 is for unlimited duration)
+ private int screenshotPeriod = 0; // Screenshot period in s. If 0
+ // onSceneTransition else periodically
+ private boolean isScreenshotPeriodSpecified = false;
private String errMessage; // contains message about all found errors during validation ( isValid() )
msg += " * Duration is negative%n";
}
+ // Screenshot period check
+ if (isScreenshotPeriodSpecified) {
+ if (screenshotPeriod < 0) {
+ result = false;
+ msg += " * Screenshot period is negative%n";
+ }
+ }
+
// Features check
if (featuresSet.isEmpty()) {
result = false;
}
/**
+ * @return Screenshot period in seconds. If 0 it means onSceneTransition.
+ */
+ public int getScreenshotPeriod() {
+ return screenshotPeriod;
+ }
+
+ /**
+ * @return <code>true</code> if screenshots enabled.
+ */
+ public boolean isScreenshotPeriodSpecified() {
+ return isScreenshotPeriodSpecified;
+ }
+
+ /**
+ * @param period The period in seconds to set. 0 for onSceneTransition.
+ * @return this object to allow chained methods execution
+ */
+ public TracingArguments setScreenshotPeriod(int period) {
+ this.screenshotPeriod = period;
+ this.isScreenshotPeriodSpecified = true;
+ return this;
+ }
+
+ /**
* @return the featuresList list of features selected for tracing
*/
public Set<PrimitiveFeature> getFeatures() {
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
+import org.tizen.dynamicanalyzer.setting.PrimitiveFeature;
import org.tizen.dynamicanalyzer.util.Logger;
/**
.desc("redirect tracing output to file")
.build();
+ private static Option screenshotPeriod = Option.builder("S")
+ .hasArg()
+ .optionalArg(true)
+ .longOpt("screenshot")
+ .argName("screenshot")
+ .desc("Enable screenshots capturing periodically or on scene transition if no argument set")
+ .build();
+
private static Options opts = new Options();
static {
+ // One of template options is required
opts.addOption(application)
// TODO duration option is not supported yet
// .addOption(duration)
for (TracingFeatureArgument featureOpt : TracingFeatureArgument.values()) {
opts.addOption(featureOpt.getOption());
}
+ opts.addOption(screenshotPeriod);
}
/**
result.setOutput(new File(outString));
}
+ // Get screenshot period
+ if (cmdline.hasOption(screenshotPeriod.getOpt())) {
+ String period = cmdline.getOptionValue(screenshotPeriod.getOpt());
+ if (period == null) {
+ result.setScreenshotPeriod(0);
+ } else {
+ int periodInt = Integer.parseInt(period);
+ result.setScreenshotPeriod(periodInt);
+ }
+ result.addFeature(PrimitiveFeature.SCREENSHOT);
+ }
+
// Get features
TracingFeatureArgument.parseFeatureOptions(result, cmdline);
result.add(out.getAbsolutePath());
}
+ int period = args.getScreenshotPeriod();
+ if (args.isScreenshotPeriodSpecified()) {
+ result.add('-' + screenshotPeriod.getOpt());
+ if (period > 0)
+ result.add(Integer.toString(period));
+ }
+
// Features
result.addAll(TracingFeatureArgument.toStringArrayList(args));
private final static File output = new File("output.out");
private final static PrimitiveFeature feature = PrimitiveFeature.CPU_USAGE;
private final static PrimitiveFeature feature2 = PrimitiveFeature.POWER_ESTIMATION;
+ private final static int period = 3;
@Before
public void setUp() {
TracingArguments args = new TracingArguments();
assertFalse(args.isValid());
}
+
+ @Test
+ public void isValid_withOkPeriod() {
+ TracingArguments args = new TracingArguments()
+ .setDevice(device)
+ .setApplication(application)
+ .addFeature(feature)
+ .setScreenshotPeriod(period);
+ assertTrue(args.isValid());
+ }
+
+ @Test
+ public void isValid_withBadPeriod() {
+ TracingArguments args = new TracingArguments()
+ .setDevice(device)
+ .setApplication(application)
+ .addFeature(feature)
+ .setScreenshotPeriod(-period);
+ assertFalse(args.isValid());
+ }
}
import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.setting.SettingConstants;
import org.tizen.dynamicanalyzer.setting.SettingDataManager;
-import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;
import org.tizen.dynamicanalyzer.ui.file.FilePage;
import org.tizen.dynamicanalyzer.ui.file.manager.FileDataManager;
import org.tizen.dynamicanalyzer.ui.interactive.InteractivePage;
import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveDataManager;
import org.tizen.dynamicanalyzer.ui.kernel.KernelPage;
+import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataManager;
import org.tizen.dynamicanalyzer.ui.memory.MemoryPage;
import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataManager;
import org.tizen.dynamicanalyzer.ui.memory.data.MemoryDataManager;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataManager;
import org.tizen.dynamicanalyzer.ui.network.NetworkPage;
import org.tizen.dynamicanalyzer.ui.network.data.NetworkDataManager;
import org.tizen.dynamicanalyzer.ui.opengl.GLPage;
// InteractiveDataManager is not supported in CLI mode
if (Global.isGUIMode()) {
timelinePageInfo.addDataManager(InteractiveDataManager.class);
- // Screenshots are not tested in CLI mode yet
- // TODO test and enable
- timelinePageInfo.addDataManager(ScreenshotDataManager.class);
}
+ timelinePageInfo.addDataManager(ScreenshotDataManager.class);
timelinePageInfo.addDataManager(MemoryDataManager.class);
timelinePageInfo.addDataManager(DLogDataManager.class);
timelinePageInfo.addDataManager(FunctionUsageProfiler.class);