Unit Test Failures - Difference in Execution

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Unit Test Failures - Difference in Execution

Post by DolphinMann »

I do not think this is a PDF X-Change issue, but I wanted to post here in the event a developer has experience with this.

I am executing a export to tif operation(code below). If I create a Windows Service/Console App/Mock Desktop app it works fine, but when I create a VS2017 unit test i get a "-2147418113", Critical Failure. The error is on the "operation.do()" call.

Anyone have experience or advice on this topic?

Code: Select all

                    if (File.Exists(inputPDF))
                    {
                        if (File.Exists(outputTIF))
                        {
                            DolphinIOTools.DeleteFile(outputTIF);
                        }

                        if (outputTIF == null || outputTIF == "")
                        {
                            outputTIF = DolphinIOTools.GetNextValidFileName(Path.GetDirectoryName(inputPDF) + @"\" + Path.GetFileNameWithoutExtension(inputPDF) + ".tif");
                            Logger.Log("SavePath not set, defaulting to PDF path: " + outputTIF, 5);
                        }

                        if (!Directory.Exists(Path.GetDirectoryName(outputTIF)))
                        {
                            Directory.CreateDirectory(Path.GetDirectoryName(outputTIF));
                        }

                        Init();
                        IPXC_Inst pxcInst = (IPXC_Inst)viewerInstance.GetExtension("PXC");
                        IPXC_Document doc = pxcInst.OpenDocumentFromFile(inputPDF, clbk);
                        
                        int nID = viewerInstance.Str2ID("op.document.exportToImages", false);
                        IOperation Op = viewerInstance.CreateOp(nID);
                        ICabNode input = Op.Params.Root["Input"];

                        input.Add().v = doc;

                        ICabNode options = Op.Params.Root["Options"];
                        if (page == -1)
                        {
                            options["PagesRange.Type"].v = "All";
                        }
                        else
                        {
                            options["PagesRange.Type"].v = "Exactly";
                            options["PagesRange.Text"].v = Convert.ToString(page+1);
                        }
                        options["FileName"].v = outputTIF;
                        options["ExportMode"].v = "AllToMutliPage";
                        options["ShowResultFolder"].v = 0;
                        options["DpiX"].v = dpi;
                        options["DpiY"].v = dpi;
                        ICabNode fmtParams = options["FormatParams"];
                        fmtParams["COMP"].v = 5; //LZW compression
                        fmtParams["FMT"].v = 1414088262; //TIFF
                        if (useColor)
                        {
                            fmtParams["ITYP"].v = 32; //24 TrueColor w/alpha
                        }
                        else
                        {
                            fmtParams["ITYP"].v = 8;
                        }
                        fmtParams["PRED"].v = 1; //Yes
                        if (thumbNail)
                        {
                            double thumbZoom = doc.Pages[((uint)page)].get_Box(PXC_BoxType.PBox_CropBox).right / 72 * dpi / defaultThumbNailWidth;
                            thumbZoom = Math.Round(thumbZoom, 2);

                            options["Zoom"].v = thumbZoom;
                            //fmtParams["THUM"].v = 1; //No
                        }
                        else
                        {
                            options["Zoom"].v = 100;
                            fmtParams["THUM"].v = 0; //No
                        }
                        
                        Op.Do();

                        doc.Close();
                        options.Clear();
                        fmtParams.Clear();
                        input.Clear();
                        pxcInst = null;

                        Logger.Log("PDF File: " + inputPDF + ", does not exist. Cannot convert to TIF file: " + outputTIF, 1);
                    }
                    else
                    {
                        Logger.Log("PDF File: " + inputPDF + ", does not exist. Cannot convert to TIF", 1);
                    }
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Unit Test Failures - Difference in Execution

Post by Sasha - Tracker Dev Team »

Hello DolphinMann,

Have you tried other operation and/or simplifying the operation's parameters?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Unit Test Failures - Difference in Execution

Post by DolphinMann »

Yes, it is something about unit tests in VS2017. I have 4 operations in my code and all execute real-time but not within the Unit Tests.

I should edit:

Exact same code/function calls and it only fails on the operation.Do, all of the other code items work, including the initialization of the objects. Is it something to do with the lack of UI for VS2017 unit tests and calling the Editor SDK?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Unit Test Failures - Difference in Execution

Post by Sasha - Tracker Dev Team »

Hello DolphinMann,

Please give us a full test that recreates the problem that we can test from our side and see where the problem is.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Unit Test Failures - Difference in Execution

Post by DolphinMann »

I think I may have figured it out. I will update the thread once I have more evidence and/or a solution others might find valuable. Thus far it seems to be related to the way the unit tests load libraries so I adjusted some of the configuration around the Unit Test Project
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Unit Test Failures - Difference in Execution

Post by Will - Tracker Supp »

Keep us posted!
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Unit Test Failures - Difference in Execution

Post by DolphinMann »

Consider this topic closed. It was my error in understanding how VS2017 works with unit tests. Thank you for the response however.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Unit Test Failures - Difference in Execution

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply