1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.wm.flicker.monitor; 18 19 import android.os.Environment; 20 21 import java.nio.file.Path; 22 import java.nio.file.Paths; 23 24 /** 25 * Collects test artifacts during a UI transition. 26 */ 27 public interface ITransitionMonitor { 28 Path OUTPUT_DIR = Paths.get(Environment.getExternalStorageDirectory().toString(), "flicker"); 29 30 /** 31 * Starts monitor. 32 */ start()33 void start(); 34 35 /** 36 * Stops monitor. 37 */ stop()38 void stop(); 39 40 /** 41 * Saves any monitor artifacts to file adding {@code testTag} and {@code iteration} 42 * to the file name. 43 * 44 * @param testTag suffix added to artifact name 45 * @param iteration suffix added to artifact name 46 * 47 * @return Path to saved artifact 48 */ save(String testTag, int iteration)49 default Path save(String testTag, int iteration) { 50 return save(testTag + "_" + iteration); 51 } 52 53 /** 54 * Saves any monitor artifacts to file adding {@code testTag} to the file name. 55 * 56 * @param testTag suffix added to artifact name 57 * 58 * @return Path to saved artifact 59 */ save(String testTag)60 default Path save(String testTag) { 61 throw new UnsupportedOperationException("Save not implemented for this monitor"); 62 } 63 } 64