TEST_F(PageSerializerTest, NamespaceElementsDontCrash)
{
    setBaseFolder("pageserializer/namespace/");

    registerURL("namespace_element.html", "text/html");

    serialize("namespace_element.html");

    EXPECT_EQ(1U, getResources().size());
    EXPECT_TRUE(isSerialized("namespace_element.html", "text/html"));
    EXPECT_GT(getSerializedData("namespace_element.html", "text/html").length(), 0U);
}
Пример #2
0
void CPlacementStep::Serialize(stepArchive &ar)
{
  try{
    if (!isSerialized()){
      setSerialized();
    }
  }
  catch(...){
    ar << "\n/*Errors detected in CPlacementStep::Serialize #\n";
//  ar << getNum();
    ar <<   ", but continuing*/\n" ;    
  }

}
// Test that we don't regress https://bugs.webkit.org/show_bug.cgi?id=99105
TEST_F(PageSerializerTest, SVGImageDontCrash)
{
    setBaseFolder("pageserializer/svg/");

    registerURL("page_with_svg_image.html", "text/html");
    registerURL("green_rectangle.svg", "image/svg+xml");

    serialize("page_with_svg_image.html");

    EXPECT_EQ(2U, getResources().size());

    EXPECT_TRUE(isSerialized("green_rectangle.svg", "image/svg+xml"));
    EXPECT_GT(getSerializedData("green_rectangle.svg", "image/svg+xml").length(), 250U);
}
TEST_F(PageSerializerTest, HTMLElements)
{
    setBaseFolder("pageserializer/elements/");

    registerURL("elements.html", "text/html");
    registerURL("style.css", "style.css", "text/css");
    registerURL("copyright.html", "empty.txt", "text/html");
    registerURL("script.js", "empty.txt", "text/javascript");

    registerURL("bodyBackground.png", "image.png", "image/png");

    registerURL("imageSrc.png", "image.png", "image/png");

    registerURL("inputImage.png", "image.png", "image/png");

    registerURL("tableBackground.png", "image.png", "image/png");
    registerURL("trBackground.png", "image.png", "image/png");
    registerURL("tdBackground.png", "image.png", "image/png");

    registerURL("blockquoteCite.html", "empty.txt", "text/html");
    registerURL("qCite.html", "empty.txt", "text/html");
    registerURL("delCite.html", "empty.txt", "text/html");
    registerURL("insCite.html", "empty.txt", "text/html");

    registerErrorURL("nonExisting.png", 404);

    serialize("elements.html");

    EXPECT_EQ(8U, getResources().size());

    EXPECT_TRUE(isSerialized("elements.html", "text/html"));
    EXPECT_TRUE(isSerialized("style.css", "text/css"));
    EXPECT_TRUE(isSerialized("bodyBackground.png", "image/png"));
    EXPECT_TRUE(isSerialized("imageSrc.png", "image/png"));
    EXPECT_TRUE(isSerialized("inputImage.png", "image/png"));
    EXPECT_TRUE(isSerialized("tableBackground.png", "image/png"));
    EXPECT_TRUE(isSerialized("trBackground.png", "image/png"));
    EXPECT_TRUE(isSerialized("tdBackground.png", "image/png"));
    EXPECT_FALSE(isSerialized("nonExisting.png", "image/png"));
}
TEST_F(PageSerializerTest, IFrames)
{
    setBaseFolder("pageserializer/frames/");

    registerURL("top_frame.html", "text/html");
    registerURL("simple_iframe.html", "text/html");
    registerURL("object_iframe.html", "text/html");
    registerURL("embed_iframe.html", "text/html");
    registerURL("encoded_iframe.html", "text/html");

    registerURL("top.png", "image.png", "image/png");
    registerURL("simple.png", "image.png", "image/png");
    registerURL("object.png", "image.png", "image/png");
    registerURL("embed.png", "image.png", "image/png");

    serialize("top_frame.html");

    EXPECT_EQ(9U, getResources().size());

    EXPECT_TRUE(isSerialized("top_frame.html", "text/html"));
    EXPECT_TRUE(isSerialized("simple_iframe.html", "text/html"));
    EXPECT_TRUE(isSerialized("object_iframe.html", "text/html"));
    EXPECT_TRUE(isSerialized("embed_iframe.html", "text/html"));
    EXPECT_TRUE(isSerialized("encoded_iframe.html", "text/html"));

    EXPECT_TRUE(isSerialized("top.png", "image/png"));
    EXPECT_TRUE(isSerialized("simple.png", "image/png"));
    EXPECT_TRUE(isSerialized("object.png", "image/png"));
    EXPECT_TRUE(isSerialized("embed.png", "image/png"));

    // Ensure that page contents are not NFC-normalized before encoding.
    String expectedMetaCharset = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=EUC-KR\">";
    EXPECT_TRUE(getSerializedData("encoded_iframe.html", "text/html").contains(expectedMetaCharset));
    EXPECT_TRUE(getSerializedData("encoded_iframe.html", "text/html").contains("\xE4\xC5\xD1\xE2"));
    EXPECT_FALSE(getSerializedData("encoded_iframe.html", "text/html").contains("\xE4\xC5\xE4\xC5"));
}
Пример #6
0
void CPlaneStep::Serialize( stepArchive &ar) {
    try {
        if (!isSerialized()) {
            setSerialized();
            writePre( ar);
            ar << "'',#";
            ar << m_pPosition->getNum();
            writePost( ar);
            ASSERT( this == m_pPosition->m_pBack );
            m_pPosition->Serialize(ar);
        }
    }
    catch(...) {
        ar << "\n/*Errors detected in ";
        ar << m_szTheClass;
        ar << "::Serialize  #\n";
//  ar << getNum();
        ar <<   ", but continuing*/\n" ;
    }
}
Пример #7
0
void CConnected_face_setStep::Serialize( stepArchive &ar)
{
  char out[128] = "(55%) ";
  strcat(out, this->m_szTheClass);

#if     NOTIFICATION 
  if (CRepresentationStep::m_pStep->m_bWriteFile){
    CRepresentationStep::m_pStep->m_pScribView->Notify( out);}
#else //NOTIFICATION 
#endif//NOTIFICATION 

#ifdef  SHOWPROGRESS
  if (CRepresentationStep::m_pStep->m_bWriteFile){
    CRepresentationStep::m_pStep->m_pScribView->progressBarUpdate( 55);}
#endif//SHOWPROGRESS

  try{
    if (!isSerialized()){
      setSerialized();
      if (NULL != m_pCFS_faces){
       writeNtuple( ar, m_pCFS_faces);
       int is = m_pCFS_faces->GetSize();
       for ( int i = 0; i< is; i++){
          CFaceStep* pS = (CFaceStep*)m_pCFS_faces->GetAt(i);
          pS->Serialize(ar);
       }
      }
      else {
        writeChild(ar, m_pRepresentation_itemStep->getNum());
        m_pRepresentation_itemStep->Serialize(ar);
      }
    }
  }
  catch(...){
    ar << "\n/*Errors detected in CConnected_face_setStep::Serialize #\n";
    ar << getNum();
    ar <<   ", but continuing*/\n" ;    
  }
}
Пример #8
0
void CLineStep::Serialize(stepArchive &ar)
{
  try{
    if (!isSerialized()){
      setSerialized();
      writePre(ar);
      ar << "'',#";
      ar << m_pPos->getNum();
      ar << ",#";
      ar << m_pDir->getNum();
      writePost(ar);

      m_pPos->Serialize( ar);
      m_pDir->Serialize( ar);
    }
  }
  catch(...){
      setSerialized();
      ar << "\n/*Error caught in CCurveStep::Serialize!*/\n";
  }

}
Пример #9
0
void CCurveStep::Serialize(stepArchive &ar)
{
  try{
    if (!isSerialized()){
      setSerialized();
      writePre(ar);
      ar << "'',#";
//    ar << m_rPos.getNum();
      ar << ",#";
//    ar << m_rDir.getNum();
      writePost(ar);

//    m_rPos.Serialize( ar);
//    m_rDir.Serialize( ar);
    }
  }
  catch(...){
      setSerialized();
      ar << "\n/*Error caught in CCurveStep::Serialize!*/\n";
  }

}
// Tests that when serializing a page with blank frames these are reported with their resources.
TEST_F(PageSerializerTest, BlankFrames)
{
    setBaseFolder("pageserializer/frames/");

    registerURL("blank_frames.html", "text/html");
    registerURL("red_background.png", "image.png", "image/png");
    registerURL("orange_background.png", "image.png", "image/png");
    registerURL("blue_background.png", "image.png", "image/png");

    serialize("blank_frames.html");

    EXPECT_EQ(7U, getResources().size());

    EXPECT_TRUE(isSerialized("http://www.test.com/red_background.png", "image/png"));
    EXPECT_TRUE(isSerialized("http://www.test.com/orange_background.png", "image/png"));
    EXPECT_TRUE(isSerialized("http://www.test.com/blue_background.png", "image/png"));
    // The blank frames should have got a magic URL.
    EXPECT_TRUE(isSerialized("wyciwyg://frame/0", "text/html"));
    EXPECT_TRUE(isSerialized("wyciwyg://frame/1", "text/html"));
    EXPECT_TRUE(isSerialized("wyciwyg://frame/2", "text/html"));
}
Пример #11
0
void COpen_shellStep::Serialize( stepArchive &ar)
{
  try{
    if (!isSerialized()){
      setSerialized();
      
      char out[128] = "(53%) ";
      strcat(out, this->name);
#if     NOTIFICATION 
  if (CRepresentationStep::m_pStep->m_bWriteFile)
      CRepresentationStep::m_pStep->m_pScribView->Notify( out);
#else //NOTIFICATION 
#endif//NOTIFICATION 

#ifdef  SHOWPROGRESS
  if (CRepresentationStep::m_pStep->m_bWriteFile)
      CRepresentationStep::m_pStep->m_pScribView->progressBarUpdate( 53);
#endif//SHOWPROGRESS

      writePre(ar);
      ar << "'', " ;
      writeNtuple(ar, m_pCFS_faces, m_pCFS_faces->GetSize());
      writePost(ar);
  
#ifdef   WRITEEULER
      CBaseStep* pBaseStep=NULL;
      backPtr( pBaseStep);
      if (NULL!=pBaseStep){
        CManifold_solid_brepStep* pManifold_solid_brepStep=(CManifold_solid_brepStep*) pBaseStep;
        pManifold_solid_brepStep->eulerCnt.m_numOpenShells++;
      }
#endif//WRITEEULER

      int is = m_pCFS_faces->GetSize();
      for ( int i = 0; i< is; i++){
        CFaceStep* pS = (CFaceStep*)m_pCFS_faces->GetAt(i);
        if (NULL != pS){
          pS->m_pBack = this;
          pS->Serialize(ar);
        }
      }
    }


  }
  catch(...){
    if (CRepresentationStep::m_pStep->m_bWriteFile){
    ar << "\n/*Errors detected in COpen_shellStep::Serialize #\n";
//  ar << getNum();
    ar <<   ", but continuing*/\n" ;    
    }
  }
#if     NOTIFICATION 
  if (CRepresentationStep::m_pStep->m_bWriteFile)
  CRepresentationStep::m_pStep->m_pScribView->Notify("(65%) COpen_shellStep::Serialize");
#else //NOTIFICATION 
#endif//NOTIFICATION 

#ifdef  SHOWPROGRESS
  if (CRepresentationStep::m_pStep->m_bWriteFile)
      CRepresentationStep::m_pStep->m_pScribView->progressBarUpdate( 65);
#endif//SHOWPROGRESS
}
TEST_F(PageSerializerTest, CSS)
{
    setBaseFolder("pageserializer/css/");

    registerURL("css_test_page.html", "text/html");
    registerURL("link_styles.css", "text/css");
    registerURL("encoding.css", "text/css");
    registerURL("import_style_from_link.css", "text/css");
    registerURL("import_styles.css", "text/css");
    registerURL("do_not_serialize.png", "image.png", "image/png");
    registerURL("red_background.png", "image.png", "image/png");
    registerURL("orange_background.png", "image.png", "image/png");
    registerURL("yellow_background.png", "image.png", "image/png");
    registerURL("green_background.png", "image.png", "image/png");
    registerURL("blue_background.png", "image.png", "image/png");
    registerURL("purple_background.png", "image.png", "image/png");
    registerURL("pink_background.png", "image.png", "image/png");
    registerURL("brown_background.png", "image.png", "image/png");
    registerURL("ul-dot.png", "image.png", "image/png");
    registerURL("ol-dot.png", "image.png", "image/png");

    serialize("css_test_page.html");

    EXPECT_EQ(15U, getResources().size());

    EXPECT_FALSE(isSerialized("do_not_serialize.png", "image/png"));

    EXPECT_TRUE(isSerialized("css_test_page.html", "text/html"));
    EXPECT_TRUE(isSerialized("link_styles.css", "text/css"));
    EXPECT_TRUE(isSerialized("encoding.css", "text/css"));
    EXPECT_TRUE(isSerialized("import_styles.css", "text/css"));
    EXPECT_TRUE(isSerialized("import_style_from_link.css", "text/css"));
    EXPECT_TRUE(isSerialized("red_background.png", "image/png"));
    EXPECT_TRUE(isSerialized("orange_background.png", "image/png"));
    EXPECT_TRUE(isSerialized("yellow_background.png", "image/png"));
    EXPECT_TRUE(isSerialized("green_background.png", "image/png"));
    EXPECT_TRUE(isSerialized("blue_background.png", "image/png"));
    EXPECT_TRUE(isSerialized("purple_background.png", "image/png"));
    EXPECT_TRUE(isSerialized("pink_background.png", "image/png"));
    EXPECT_TRUE(isSerialized("brown_background.png", "image/png"));
    EXPECT_TRUE(isSerialized("ul-dot.png", "image/png"));
    EXPECT_TRUE(isSerialized("ol-dot.png", "image/png"));

    // Ensure encodings are specified.
    EXPECT_TRUE(getSerializedData("link_styles.css", "text/css").startsWith("@charset"));
    EXPECT_TRUE(getSerializedData("import_styles.css", "text/css").startsWith("@charset"));
    EXPECT_TRUE(getSerializedData("import_style_from_link.css", "text/css").startsWith("@charset"));
    EXPECT_TRUE(getSerializedData("encoding.css", "text/css").startsWith("@charset \"euc-kr\";"));

    // Ensure that stylesheet contents are not NFC-normalized before encoding.
    EXPECT_TRUE(getSerializedData("encoding.css", "text/css").contains("\xE4\xC5\xD1\xE2"));
    EXPECT_FALSE(getSerializedData("encoding.css", "text/css").contains("\xE4\xC5\xE4\xC5"));
}