Exemplo n.º 1
0
 public void openGui()
 {
     DI.log.info("Opening GUI");
     if (O2AscxGUI.launch())
     {
         O2AscxGUI.setLogViewerDockState(O2DockState.DockBottom);
         O2Messages.openControlInGUISync(typeof(ascx_CirCreator), O2DockState.Document, cirAnalysisControlName);
         //DI.log.info("after launch");
         //O2AscxGUI.logInfo("from Test_CirCreatorAscxControl");  // this is actually a hack since there is still a bug in the thread invocation which makes sometimes the getGuiAscx below to fail
     }
 }
Exemplo n.º 2
0
 public void openGui()
 {
     DI.log.info("Opening GUI");
     // first set up GUI
     if (O2AscxGUI.launch())
     {
         O2AscxGUI.setLogViewerDockState(O2DockState.DockBottom);
         cirDataViewer = (ascx_CirDataViewer)O2Messages.openControlInGUISync(typeof(ascx_CirDataViewer), O2DockState.Document, cirDataViewerControlName);
         Assert.That(cirDataViewer != null, "cirDataViewer was null");
         // Then create CirData and fire global O2Message showCirDataStats
         createCirDataObject();
     }
 }
Exemplo n.º 3
0
        public void loadTestGui()
        {
            // lauch Gui
            O2AscxGUI.launch();
            DI.log.LogRedirectionTarget = null; // so that we get all DI.log messages
            O2AscxGUI.setLogViewerDockState(O2DockState.DockBottom);
            // load the controls we need
            O2AscxGUI.openAscx(typeof(ascx_Scripts), O2DockState.Document, ascx_ScriptControl);
            O2AscxGUI.openAscx(typeof(ascx_ScriptsFolder), O2DockState.DockLeft, ascx_ScriptsFolderControl);
            O2AscxGUI.openAscx(typeof(ascx_AssemblyInvoke), O2DockState.DockRight, ascx_AssemblyInvokeControl);
            O2AscxGUI.openAscx(typeof(ascx_O2MdbgShell), O2DockState.DockBottom, ascx_O2MdbgShellName);
            // make sure they are loaded
            Assert.That(O2AscxGUI.isAscxLoaded(ascx_ScriptControl), "ascxScriptControl was not loaded");
            Assert.That(O2AscxGUI.isAscxLoaded(ascx_ScriptsFolderControl), "ascxScriptFolderControl was not loaded");
            Assert.That(O2AscxGUI.isAscxLoaded(ascx_AssemblyInvokeControl), "ascx_AssemblyInvokeControl was not loaded");
            Assert.That(O2AscxGUI.isAscxLoaded(ascx_O2MdbgShellName), "ascx_AssemblyInvokeControl was not loaded");

            // load sample script in scripts folder
            ascx_ScriptsFolderControl.invokeOnAscx("loadSampleScripts");
            var sampleScriptNames = O2AscxGUI.invokeAndGetStringList(ascx_ScriptsFolderControl, "getSampleScriptNames");

            Assert.That(sampleScriptNames.Count > 2, "There should be at least 3 scripts");
            var targetSampleScript         = sampleScriptNames[0];
            var targetSampleScriptContents = (string)O2AscxGUI.invokeOnAscxControl(ascx_ScriptsFolderControl, "getSampleScriptContent", new object[] { targetSampleScript });
            var scriptFile = (string)O2AscxGUI.invokeOnAscxControl(ascx_ScriptsFolderControl, "createTempScriptFile", new object[] { Path.Combine(DI.config.O2TempDir, targetSampleScript), targetSampleScriptContents });

            Assert.IsNotNull(scriptFile, "scriptFile was null");
            Assert.That(File.Exists(scriptFile), "scriptFile didn't exist");
            O2AscxGUI.invokeOnAscxControl(ascx_ScriptControl, "loadSourceCodeFile", new object[] { scriptFile });

            // and confirm that its contents are the same as the content retrieved from the ascx_ScriptsFolderControl
            var scriptContentsFromAscxScriptsControl = (string)O2AscxGUI.invokeOnAscxControl(ascx_ScriptControl, "getSourceCode");

            Assert.IsNotNull(scriptContentsFromAscxScriptsControl, "scriptContentsFromAscxScriptsControl was null");
            Assert.That(scriptContentsFromAscxScriptsControl == targetSampleScriptContents, "Source code didn't match");

            // let's wait a bit so that the compile event can trigger
            Processes.Sleep(1000);

            // the above load should have triggered the auto compile of the source code file, so lets get its type
            var compiledTypes = O2AscxGUI.invokeAndGetStringList(ascx_AssemblyInvokeControl, "getTypes");

            Assert.That(compiledTypes != null && compiledTypes.Count > 0, "prob with types");

            // now that we have the type we need to use it to configure the exe settings (since we cant debug a Dll
            var typeName = compiledTypes[0];

            DI.log.info("There were {0} methods compiled", compiledTypes.Count);

            // final test is to make sure the assembly file to execute exists
            // first configure the exe compilation mode (which needs the name of the type that holds the Main method
            O2AscxGUI.invokeOnAscxControl(ascx_ScriptControl, "setExeCompilationMode", new object[] { typeName });

            // then simulate a compile by clicking on the compile button
            O2AscxGUI.clickButton(ascx_ScriptControl, "btSourceCode_Compile");
            // let's wait a bit so that the compile event can trigger
            Processes.Sleep(1000);

            // now get the compile assembly name which should be an *.exe
            assemblyToExecute = (string)O2AscxGUI.invokeOnAscxControl(ascx_AssemblyInvokeControl, "getAssemblyLocation");
            DI.log.info("The assembly to debug is: {0}", assemblyToExecute);
            Assert.That(assemblyToExecute != null && File.Exists(assemblyToExecute) && Path.GetExtension(assemblyToExecute) == ".exe", "prob with assemblyToExecute");
            // and make sure all supporting dlls are in temp folder (namely O2_Kernel.dll
            makeSureAllDependentAssembliesExistInTempDirectory(assemblyToExecute);

            //so that it is null, select a line of the document
            setSelectedLineNumber(scriptFile, currentSelectedLine);
            Assert.That(currentSelectedLine == getSelectedLineNumber(), "currentSelectedLine didn't match");
        }