User:Ricekeller/sandbox

= Investigating Sub Systems QANs =

Sub Systems Components
Besides the above components, there are still several components not listed here because we are not using them in SmartTextBox (they may be used by printing team).

Get Sub Systems Source code and Test Bench
Consult this wiki for details about the SVN repository address of the source codes and the test bench. After checking out the codes, you should be able to run the test bench projects. This wiki also includes some introduction about the test bench.

NOTE: Currently the test bench can only be used to test C components.

Demo Applications from Sub Systems
Sub Systems provides some demo applications and we can use them to reproduce some issues.

A Step by Step Guild to Crash Sub Systems
NOTE: This is the characteristic of crashes that happen in the TER control. If you can get VB runtime errors, it is highly likely NOT a Sub Systems' crash.
 * 1) Create a new folder()
 * 2) Copy hts.bas, EACHts81.dll, ter.bas, EACTer81.dll, EACToc81.ocx from ./Test Bench/EpicVersion2014 to the new folder, double click the EACTer81.ocx to register the ocx.
 * 3) Open VB6, create a new standard EXE project, save everything (.vbp and .frm) to the new folder
 * 4) Add ter.bas and hts.bas to the project
 * 5) Add following variable to form1:
 * 6) * Private Const TOC_LICENSE_KEY As String = "68H3D-91K4F-MW623"
 * 7) Add this line to the form_load event, it sets the license of the TER control:
 * 8) * Call TerSetLicenseKey(TOC_LICENSE_KEY)
 * 9) Goto Project -> Components, find "Epic Ter Edit OCX, v20 (8.1)". Select it and click OK.
 * 10) The TE control will appear on the ToolBox, drag one onto the form, and rename it to "toc", also drag one button onto the form.
 * 11) In the form_load event, use the following lines to create a table:
 * 12) * Call TerCreateTable(toc.hwnd, 2, 3, True)
 * 13) In the button's click event, add following codes:
 * 14) * Dim lNdx As Long
 * 15) * For lNdx = 1 To 2
 * 16) * Call TerInsertTableCol(toc.hwnd, False, 1, 0)
 * 17) * Next lNdx
 * 18) Now save all the files and run the project, you should see a blue table.
 * 19) Type some characters in each cell.
 * 20) Click the button, then click inside the TER control, you should see that two columns are appended to the table.
 * 21) Press Ctrl+Z to undo, see the crash, WOW! :).

A Step By Step Guild to Debug the Code
In order to debug such issues, you need to attach Visual Studio debugger to the process and make sure the symbols of TER are loaded. Sometimes it is really easy to find what is wrong, such as negative array index. But sometimes it is not. If you can reproduce the crash like this, it is good enough to report to Sub Systems.
 * 1) Navigate to C:\EpicSource\8.1\2014 QA\ApplCore\SubSystems\src. ( If you don't have 8.1, check out one...)
 * 2) Open All.sln, if it prompts to upgrade the sln, do it.
 * 3) RIght click on the solution, select build-solution. You will see an link error, select rebuild-solution and this error will gone.
 * 4) Goto C:\EpicSource\8.1\2014 QA\ApplCore\SubSystems\bin, you will see EACHts81.dll and EACTer81.dll, copy these two DLLs to the new folder you created in the above example.
 * 5) If you haven't done this, in the folder you created, right click the vbp and select Make, it will generate a .exe. This is the executable of your crash project.
 * 6) Run the .exe file.
 * 7) Open Visual Studio, Debug -> Attach to Process...
 * 8) Select your .exe from the Available Processes panel, click Attach.
 * 9) Goto Debug -> Windows -> Modules, this will open the modules window that show all loaded components. You can find EACTer81.dll in this window.
 * 10) In your .exe window, do the same workflow that causes the crash.
 * 11) Visual Studio debugger will catch this crash and shows which line crashes.

Test Bench
The previous method can be used to try to reproduce bugs, but there are things that need to be done every time, such as copy & paste license, etc... And it is NOT easy to test different versions.

For each bug we report, Sub Systems fixes it and sends all of the latest code to us. We then try to identify the fix and merge it into our codebase. Sometimes it is possible that a bug has been fixed but we didn't merge because it was not the bug that we requested for a fix. So it is important to test/reproduce a bug using his latest code. This means it is necessary to test a bug in different versions.

This is why we have a test bench. Gregory Mason created this test bench which makes it easy to test issues in different versions.

(TODO:screenshot)

In the test bench, each test case is a user control. To create a test case, the easiest way is to copy an existing one:
 * 1) Double click the test case you want to copy to activate it.
 * 2) Goto Dev -> Bootstrap -> CopyQAN
 * 3) Enter the QAN number and a description.
 * 4) Goto the QANs folder and open the folder whose name is the QAN number you just entered.
 * 5) This is the folder of the test case. You can open the user control and modify the code.

Common Errors

 * 1) "Evaluation expired..." or "Invalid license..."
 * 2) * This means you may not set the license or the license is incorrect. You can codesearch for license of each version.
 * 3) When running the test bench from source, IDE shows "variable not defined" or "User defined type not found" error.
 * 4) * Most often this is caused by not referencing ACSubsystems dll. You need to compile SSInterface project first. Then goto Project -> References, add ACSubsystems.
 * 5) When opening the prj of the test bench, it shows "error when loading... see <...>.log for details" error.
 * 6) * Most often this is caused by not registering correct TOC ocx file. Double click the coresponding toc.ocx file to register it.