public static bool Exec(AutomationWindow window) { //uint id = 1820; uint id = 1605; byte[] payload; //payload = new byte[9]; // works //payload = new byte[2]; // does not work //for (int index = 0; index < payload.Length; index++) // payload[index] = 0; payload = new byte[10]; payload[0] = 0x02; payload[1] = 0x00; payload[2] = 0x00; payload[3] = 0x00; payload[4] = 0x00; payload[5] = 0x00; payload[6] = 0x00; payload[7] = 0x00; payload[8] = 0x00; payload[9] = 0x02; string result = window.GetSummary(id, payload); Console.WriteLine("Result:" + result); return(true); }
public static bool Exec(AutomationWindow window) { Console.Write("\n\nCollect some logs, press enter when QXDM has gathered some."); Console.ReadKey(); //wait some time to collect logging return(true); }
public static bool Teardown(AutomationWindow window) { window.CopyViewItems("Item View", "C:\\temp\\CopyViewItems.txt"); window.ExportViewText("Item View", "C:\\temp\\ExportViewText.txt"); return(true); }
/* * If call to sendDmIcdPacketEx was successful, export text from Item View into a store file */ public static bool Teardown(AutomationWindow window) { if (sentPacket && response.Length > 0) { // Get path to export to (current working directory) string storeFilePath = Program.GetWorkingDirectory(); if (storeFilePath == "") { return(false); } storeFilePath += "ExportViewTextWithComTest.txt"; // Export Item View text to store file uint success = window.ExportViewText("Item View", storeFilePath); if (success == 0) { Console.WriteLine("Unable to export items, 'Item View'"); Console.WriteLine("Last error string: " + window.GetLastErrorString()); return(false); } Console.WriteLine("Items exported to item store file: " + storeFilePath); return(true); } else { Console.WriteLine("Problem writing or retrieving packet"); Console.WriteLine("Last error string: " + window.GetLastErrorString()); return(false); } }
public static bool Exec(AutomationWindow automationWindow) { automationWindow.CreateView("Item View", string.Empty); System.Threading.Thread.Sleep(10000); automationWindow.ClearViewItems("Item View"); return(true); }
public static bool Teardown(AutomationWindow window) { bool result; result = window.ClearViewItems("Item View"); if (result == false) { Console.WriteLine("Error ClearViewItems: " + window.GetLastErrorString()); } return(result); }
/* * Call GetItemSummary() and print results */ public static bool Exec(AutomationWindow window) { string summary = item.GetItemSummary(); if (summary == "") { Console.WriteLine("Unable to retrieve item summary"); return(false); } Console.WriteLine("Item summary: " + summary); return(true); }
public static bool Teardown(AutomationWindow window) { if (_payload.Length > 0) { System.Console.WriteLine(_payload); } else { System.Console.WriteLine("Payload Empty"); } return(true); }
/* * Export Item View text to "ExportViewTextTest.txt" in current working directory */ public static bool Exec(AutomationWindow window) { string storeFile = Program.GetWorkingDirectory() + "ExportViewTextTest.txt"; uint success = window.ExportViewText("Item View", storeFile); if (success == 0) { Console.WriteLine("Unable to export items, 'Item View'"); return(false); } Console.WriteLine("Items exported to item store file: " + storeFile); return(true); }
public static bool Exec(AutomationWindow window) { byte[] payload; payload = new byte[1]; payload[0] = 12; System.Array result; result = window.SendDmIcdPacketEx(payload, 9000); if (result.Length > 0) { _payload = new byte[result.Length]; _payload = ConvertToBytes(result); } return(true); }
/* * Request status from phone and store the response */ public static bool Exec(AutomationWindow window) { // Send request for status byte[] request = new byte[1]; request[0] = statusRequestCode; System.Array result = window.SendDmIcdPacketEx(request, 9000); System.Threading.Thread.Sleep(4000); // Store response if returned properly if (result.Length > 0) { sentPacket = true; response = new byte[result.Length]; response = ConvertToBytes(result); } return(sentPacket); }
public bool Start(string sourceFile) { qxdmApplication = new QXDMAutoApplication(); qxdmWindow = qxdmApplication.GetAutomationWindow(); isfHandler = qxdmWindow.LoadItemStore(sourceFile); if (isfHandler == 0xFFFFFFFF) { Debug.WriteLine("Error: Failed to load input ISF: {0}", sourceFile); return(false); } uint itemCount = qxdmWindow.GetItemCount(); Debug.WriteLine("itemCount: " + itemCount); iClient = (AutomationClientInterface)qxdmWindow.GetClientInterface(isfHandler); if (iClient == null) { Debug.WriteLine("Unable to obtain ISF client interface"); qxdmWindow.CloseItemStore(); return(false); } clientHandler = iClient.RegisterClient(true); if (clientHandler == 0xFFFFFFFF) { Debug.WriteLine("Unable to register ISF client"); qxdmWindow.CloseItemStore(); return(false); } iConfig = (AutomationConfigClient)iClient.ConfigureClient(clientHandler); if (iConfig == null) { Debug.WriteLine("Unable to configure ISF client"); iClient.UnregisterClient(clientHandler); qxdmWindow.CloseItemStore(); return(false); } return(true); }
public static bool Setup(AutomationWindow window) { bool result; uint autoResult; result = window.LoadConfig(Program.GetWorkingDirectory() + "simple.dmc"); if (result == true) { autoResult = window.CloseView("Item View", null); Console.WriteLine("Close Itemview, result = " + autoResult); autoResult = window.CreateView("Item View", ""); Console.WriteLine("Create Itemview, result = " + autoResult); } else { Console.WriteLine("Load Config Error:" + window.GetLastErrorString()); } return(result); }
/* * Load item store file */ public static bool Setup(AutomationWindow window) { // Get path to ISF file string fPath = Program.GetWorkingDirectory(); if (fPath == "") { return(false); } fPath += "medium.isf"; // Get file handle & load item store file uint handle = window.LoadItemStore(fPath); if (handle == 0) { Console.Write("\nUnable to load ISF:\n" + fPath + "\n"); return(false); } return(true); }
/* * Retrieve item from ISF file in current working directory */ public static bool Setup(AutomationWindow window) { string path = Program.GetWorkingDirectory(); if (path == "") { return(false); } string fileNm = path + "Example.isf"; // Get file handle & load item store file uint handle = window.LoadItemStore(fileNm); if (handle == 0) { Console.Write("\nUnable to load ISF:\n" + fileNm + "\n"); return(false); } // Retrieve item try { item = window.GetItem(handle, 2); } catch (COMException e) { Console.WriteLine("Exception while trying to retrieve item: " + e.Message); } if (item == null) { Console.WriteLine("Unable to retrieve item"); return(false); } return(true); }
public static bool Exec(AutomationWindow window) { bool result = false; uint clientHandle = window.RegisterClient("Automation", true); if (clientHandle != 0xFFFFFFFF) { AutomationConfigClient clientObject = window.ConfigureClientByKeys(clientHandle); if (clientObject != null) { // my log types clientObject.AddLog(0x1375); clientObject.AddLog(0x158C); clientObject.AddLog(0x4004); clientObject.AddLog(0x4179); // Original bug logs clientObject.AddLog(0x506F); clientObject.AddLog(0x5079); clientObject.AddLog(0x5130); clientObject.AddLog(0x5131); clientObject.AddLog(0x5132); clientObject.AddLog(0x5133); clientObject.AddLog(0x5134); clientObject.AddLog(0x5135); clientObject.AddLog(0x51F4); clientObject.AddLog(0x5A6F); clientObject.AddLog(0x5A79); clientObject.AddLog(0x5B30); clientObject.AddLog(0x5B31); clientObject.AddLog(0x5B32); clientObject.AddLog(0x5B33); clientObject.AddLog(0x5B34); clientObject.AddLog(0x5B35); clientObject.CommitConfig(); Thread.Sleep(10000); // sleep for 10 seconds, collect some logs uint itemCount = window.GetClientItemCount(clientHandle); for (uint i = 0; i > itemCount; i--) { AutomationColorItem item = window.GetClientItem(clientHandle, i); if (item != null) { string itemText = item.GetItemParsedText(); Console.WriteLine("Item: " + i + " Text: " + itemText); } } result = true; } else { Console.WriteLine("window.ConfigureClientByKeys(clientHandle) failed "); } } else { Console.WriteLine("window.RegisterClient(\"Automation\", true) failed "); } return(result); }
static bool RunTestCase(QXDMAutomation.TestCase testCase, string functionName, AutomationWindow automationWindow, uint port) { bool usesComPort = testCase._requiresComPort; // Print to log string msg = "< RUNNING TEST CASE: " + functionName.ToUpper() + " >"; LogEverywhere(""); for (int i = 0; i < msg.Length; i++) { Console.Write("\\"); logFile.Write("\\"); } LogEverywhere("\n" + msg); string errorMessage = "\t[ERROR] Test case \"" + functionName + "\" failed: "; string successMessage = "\t[PASS] Test case \"" + functionName + "\" succeeded"; // Run setup function if (testCase._setup != null && testCase._setup(automationWindow) == false) { logFile.WriteLine(errorMessage + "Setup function failed"); return(false); } // Set up COM stuff if needed if (usesComPort == true) { if (port != 0) { if (automationWindow.SetComPort(port) == true) { if (automationWindow.GetServerState() == 2) { Console.WriteLine("Connected to port: {0}", port); } else { logFile.WriteLine(errorMessage + "Error connecting to port: " + port); return(false); } } else { logFile.WriteLine(errorMessage + "SetComPort Failed - port: " + port + " message: " + automationWindow.GetLastErrorString()); return(false); } } else { logFile.WriteLine(errorMessage + "Requires a connection"); return(false); } } // Run exec function if (testCase._exec != null && testCase._exec(automationWindow) == false) { logFile.WriteLine(errorMessage + "Exec function failed"); return(false); } // Disconnect the port if in use if (usesComPort == true) { automationWindow.SetComPort(0); } // Run teardown (cleanup) function if (testCase._teardown != null && testCase._teardown(automationWindow) == false) { logFile.WriteLine(errorMessage + "Teardown function failed"); return(false); } logFile.WriteLine(successMessage); return(true); }
static void Main(string[] args) { string functionName = null; uint port = 0; int numFailed = 0; // Initialize log file logFile = new System.IO.StreamWriter(GetWorkingDirectory() + "log.txt"); logFile.WriteLine("QXDM Automation Test Log"); // Parse arguments waitForInputToExit = true; switch (args.Length) { case 0: ExitWithFail("Tried to run with improper syntax. Syntax is: QXDMAutomation <functionname> {port #} {nowait}", ExitCode.AUTOMATION_SETUP_ERROR); break; case 1: functionName = args[0]; break; // 2nd argument is ambiguous (port or "nowait"?) so check by type case 2: functionName = args[0]; uint tempPort = 0; if (uint.TryParse(args[1], out tempPort)) { port = tempPort; } else if (args[1] == waitForInput_arg) { waitForInputToExit = false; } break; default: functionName = args[0]; uint.TryParse(args[1], out port); if (args[2] == waitForInput_arg) { waitForInputToExit = false; } break; } if (InitializeTestFunctions() == false) { ExitWithFail("Could not initialize test functions.", ExitCode.AUTOMATION_SETUP_ERROR); } QXDMAutoApplication qxdmApplication = null; try { qxdmApplication = (QXDMAutoApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("QXDM.QXDMAutoApplication"); } catch (COMException e) { if (e.HResult == -2147221021) // Running object not found { qxdmApplication = new QXDMAutoApplication(); // Attempt to start it } if (qxdmApplication == null) { ExitWithFail("Error Starting QXDM", ExitCode.AUTOMATION_SETUP_ERROR); } } if (qxdmApplication != null) { Console.WriteLine("Interface Version: {0}", qxdmApplication.Get_Automation_Version()); AutomationWindow automationWindow = qxdmApplication.GetAutomationWindow(); automationWindow.SetVisible(true); Console.WriteLine("QXDM Version: {0}", automationWindow.GetQXDMVersion()); QXDMAutomation.TestCase testCase = null; if (functionName.ToLower() == runall) // Running all test cases { TestFunctionsIterator iterator = gTestFunctions.GetEnumerator(); while (iterator.MoveNext() == true) { CurrTestFunction current = iterator.Current; string testName = current.Key; testCase = current.Value; // If no port is defined, only run test cases that do not require a COM port if (port != 0 || testCase._requiresComPort == false) { if (RunTestCase(testCase, testName, automationWindow, port) == false) { numFailed++; } } } } else if (gTestFunctions.TryGetValue(functionName.ToLower(), out testCase)) // Run a single test case { if (RunTestCase(testCase, functionName, automationWindow, port) == false) { numFailed++; } } else { LogEverywhere("Function " + functionName + " not found."); // Could not find test case numFailed++; } automationWindow.Quit(); // Exit with an error if any test cases failed. if (numFailed > 1) { ExitWithFail("Two or more test cases failed.", ExitCode.MULT_TESTCASES_FAILED); } else if (numFailed == 1) { ExitWithFail("A test case failed.", ExitCode.TESTCASE_FAILED); } LogEverywhere("\n. . .\n[SUCCESS] All test cases passed"); if (waitForInputToExit) { Console.Write("\n\nPress enter to exit."); Console.Read(); } } logFile.Close(); }