Esempio n. 1
0
        public bool LaunchApp(Device device)
        {
            string arguments       = device.serial + " " + Settings.chosenApp;
            string launchAppResult = CommandLineExecutor.ExecuteScriptGetOutput(ADBScriptedFunctionsSettings.GetFunctionsFilePath(
                                                                                    ADBScriptedFunctionsSettings.EScriptedFunction.getResolution),
                                                                                arguments,
                                                                                ADBScriptedFunctionsSettings.GetFilePathForOutput(ADBScriptedFunctionsSettings.EScriptedFunction.appLaunch, device)
                                                                                ).ToLower();

            if (launchAppResult.Contains("error") || launchAppResult.Contains("exception"))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 2
0
        public Device GetDevicesResolution(Device device)
        {
            string command = "adb -s " + device.serial + " shell wm size";

            string          arguments = device.serial + " " + ADBScriptedFunctionsSettings.GetFilePathForOutput(ADBScriptedFunctionsSettings.EScriptedFunction.getResolution, device);
            string          output    = CommandLineExecutor.ExecuteScriptGetOutput(ADBScriptedFunctionsSettings.GetFunctionsFilePath(ADBScriptedFunctionsSettings.EScriptedFunction.getResolution), arguments, ADBScriptedFunctionsSettings.GetFilePathForOutput(ADBScriptedFunctionsSettings.EScriptedFunction.getResolution, device));
            MatchCollection Matches   = Regex.Matches(output, @"(\d+)");

            if (Matches.Count == 2)      // Correct case - two values was found (Height and Width)
            {
                device.resolutionY = Int32.Parse(Matches[0].Value);
                device.resolutionX = Int32.Parse(Matches[1].Value);
                return(device);
            }
            else                        // Incorrect case - output is different than expected
            {
                throw new ArgumentException("Could not get resolution for device " + device.serial + ". ADB output is: " + output);
            }
        }
Esempio n. 3
0
        //Begin logcat starts two processes collecting two logcats. Both of them need to be maintained.
        //One of them is "detailedLogcat" which is collecting all info related to this PID and it will be helpful for debugging
        //The second one is "briefLogcat" which is used by this program to determine conditions and actions of TestSteps.
        //The logic is:
        // 1. Check if files exist - if yes, delete them (they may be the result of the previous run)
        // 2. Clear device's logcat
        // 3. Run new process for both logcats
        // 4. Set the path to which logcats will be copied and read
        // 5. Return logcat
        //There is a reason .bat is used here. Cmd.exe crashes and stops logging after a few minutes for unknown reasons.
        public Logcat BeginLogcat(string packagename)
        {
            //first, clean up the old files
            Helpers.DeleteFileIfExists(Settings.briefLogcatFilePath);
            Helpers.DeleteFileIfExists(Settings.detailedLogcatFilePath);

            //second, create new ones
            Logcat logcat = new Logcat();

            logcat.logs = new List <string>();
            Directory.CreateDirectory(Settings.logcatContainerDirectory);

            //clear device's logs
            CommandLineExecutor.ExecuteCommand("adb logcat -c");

            //run .bats that will start logcat
            CommandLineExecutor.ExecuteScript(ADBScriptedFunctionsSettings.GetFunctionsFilePath(ADBScriptedFunctionsSettings.EScriptedFunction.startBriefLogcat), String.Empty, String.Empty);
            CommandLineExecutor.ExecuteScript(ADBScriptedFunctionsSettings.GetFunctionsFilePath(ADBScriptedFunctionsSettings.EScriptedFunction.startDetailedLogcat), String.Empty, String.Empty);

            logcat.detailedLogcatPath = Settings.GetPathForCopy(Settings.briefLogcatFilePath);
            logcat.briefLogcatPath    = Settings.GetPathForCopy(Settings.detailedLogcatFilePath);

            return(logcat);
        }