mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-11-04 09:02:12 +00:00 
			
		
		
		
	Uiautomator: Adds missing support functionality
Adds initial implementation of ActionLogger class and adds method to BaseUiAutomation to automatically generate packageID.
This commit is contained in:
		@@ -0,0 +1,60 @@
 | 
			
		||||
/*    Copyright 2014-2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package com.arm.wa.uiauto;
 | 
			
		||||
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.util.Log;
 | 
			
		||||
    /**
 | 
			
		||||
     * Basic marker API for workloads to generate start and end markers for
 | 
			
		||||
     * deliminating and timing actions. Markers are output to logcat with debug
 | 
			
		||||
     * priority. Actions represent a series of UI interactions to time.
 | 
			
		||||
     *
 | 
			
		||||
     * The marker API provides a way for instruments and result processors to hook into
 | 
			
		||||
     * per-action timings by parsing logcat logs produced per workload iteration.
 | 
			
		||||
     *
 | 
			
		||||
     * The marker output consists of a logcat tag 'UX_PERF' and a message. The
 | 
			
		||||
     * message consists of a name for the action and a timestamp. The timestamp
 | 
			
		||||
     * is separated by a single space from the name of the action.
 | 
			
		||||
     *
 | 
			
		||||
     * Typical usage:
 | 
			
		||||
     *
 | 
			
		||||
     * ActionLogger logger = ActionLogger("testTag", parameters);
 | 
			
		||||
     * logger.start();
 | 
			
		||||
     * // actions to be recorded
 | 
			
		||||
     * logger.stop();
 | 
			
		||||
     */
 | 
			
		||||
    public class ActionLogger {
 | 
			
		||||
 | 
			
		||||
        private String testTag;
 | 
			
		||||
        private boolean enabled;
 | 
			
		||||
 | 
			
		||||
        public ActionLogger(String testTag, Bundle parameters) {
 | 
			
		||||
            this.testTag = testTag;
 | 
			
		||||
            this.enabled = parameters.getBoolean("markers_enabled");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void start() {
 | 
			
		||||
            if (enabled) {
 | 
			
		||||
                Log.d("UX_PERF", testTag + "_start " + System.nanoTime());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void stop() throws Exception {
 | 
			
		||||
            if (enabled) {
 | 
			
		||||
                Log.d("UX_PERF", testTag + "_end " + System.nanoTime());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -79,6 +79,12 @@ public class BaseUiAutomation {
 | 
			
		||||
        SystemClock.sleep(second * 1000);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //Generate a package ID
 | 
			
		||||
    public String getPackageID(Bundle parameters) {
 | 
			
		||||
        String packageName = parameters.getString("package_name");
 | 
			
		||||
        return packageName + ":id/";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean takeScreenshot(String name) {
 | 
			
		||||
        Bundle params = getArguments();
 | 
			
		||||
        String png_dir = params.getString("workdir");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user