BloomTests.Publish.ExportEpubTests.ImageStyles_PercentsAdjustForContainingPercentDivs C# (CSharp) Method

ImageStyles_PercentsAdjustForContainingPercentDivs() private method

        public void ImageStyles_PercentsAdjustForContainingPercentDivs()
        {
            var book = SetupBookLong("This is some text", "en",
                extraPageClass: " A5Portrait",
                extraImages: @"<div id='anotherWrapper' style='width:80%'>
                                <div id='innerrWrapper' style='width:50%'>
                                    <div><img src='image1.png' width='40' height='220' style='width:40px; height:220px; margin-left: 14px; margin-top: 0px;'></img></div>
                                </div>
                            </div>");
            MakeImageFiles(book, "image1");
            MakeEpub("output", "ImageStyles_PercentsAdjustForContainingPercentDivs", book);
            CheckBasicsInManifest("image1");
            CheckBasicsInPage("image1");

            // A5Portrait page is 297/2 mm wide
            // Percent size however is relative to containing block,
            // which in this case is 50% of 80% of the marginBox,
            // which is inset 40mm from page
            // a px in a printed book is exactly 1/96 in.
            // 25.4mm.in
            var marginboxInches = (297.0 / 2.0 - 40) / 25.4;
            var picWidthInches = 40 / 96.0;
            var parentWidthInches = marginboxInches*0.8*0.5;
            var widthPercent = Math.Round(picWidthInches / parentWidthInches * 1000) / 10;
            var picIndentInches = 14 / 96.0;
            var picIndentPercent = Math.Round(picIndentInches / parentWidthInches * 1000) / 10;
            AssertThatXmlIn.String(_page1Data).HasAtLeastOneMatchForXpath("//xhtml:img[@style='width:" + widthPercent.ToString("F1")
                + "%; height:auto; margin-left: " + picIndentPercent.ToString("F1") + "%; margin-top: 0px;']", _ns);
        }