Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Unified Diff: Source/core/editing/StyledMarkupSerializerTest.cpp

Issue 1295073002: Move serializer related files in core/editing/ related files into core/editing/serializers/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-17T15:24:31 Rebase for Source/web/WebPageSerializerImpl.cpp Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/StyledMarkupSerializer.cpp ('k') | Source/core/editing/TextOffset.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/StyledMarkupSerializerTest.cpp
diff --git a/Source/core/editing/StyledMarkupSerializerTest.cpp b/Source/core/editing/StyledMarkupSerializerTest.cpp
deleted file mode 100644
index 4236d65ddcdc539fb8267baca73640b296788c8b..0000000000000000000000000000000000000000
--- a/Source/core/editing/StyledMarkupSerializerTest.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "core/editing/StyledMarkupSerializer.h"
-
-#include "core/dom/Text.h"
-#include "core/editing/EditingTestBase.h"
-
-namespace blink {
-
-// This is smoke test of |StyledMarkupSerializer|. Full testing will be done
-// in layout tests.
-class StyledMarkupSerializerTest : public EditingTestBase {
-protected:
- template <typename Strategy>
- std::string serialize(EAnnotateForInterchange = DoNotAnnotateForInterchange);
-
- template <typename Strategy>
- std::string serializePart(const PositionAlgorithm<Strategy>& start, const PositionAlgorithm<Strategy>& end, EAnnotateForInterchange = DoNotAnnotateForInterchange);
-};
-
-template <typename Strategy>
-std::string StyledMarkupSerializerTest::serialize(EAnnotateForInterchange shouldAnnotate)
-{
- PositionAlgorithm<Strategy> start = PositionAlgorithm<Strategy>(document().body(), PositionAnchorType::BeforeChildren);
- PositionAlgorithm<Strategy> end = PositionAlgorithm<Strategy>(document().body(), PositionAnchorType::AfterChildren);
- return createMarkup(start, end, shouldAnnotate).utf8().data();
-}
-
-template <typename Strategy>
-std::string StyledMarkupSerializerTest::serializePart(const PositionAlgorithm<Strategy>& start, const PositionAlgorithm<Strategy>& end, EAnnotateForInterchange shouldAnnotate)
-{
- return createMarkup(start, end, shouldAnnotate).utf8().data();
-}
-
-TEST_F(StyledMarkupSerializerTest, TextOnly)
-{
- const char* bodyContent = "Hello world!";
- setBodyContent(bodyContent);
- const char* expectedResult = "<span style=\"display: inline !important; float: none;\">Hello world!</span>";
- EXPECT_EQ(expectedResult, serialize<EditingStrategy>());
- EXPECT_EQ(expectedResult, serialize<EditingInComposedTreeStrategy>());
-}
-
-TEST_F(StyledMarkupSerializerTest, BlockFormatting)
-{
- const char* bodyContent = "<div>Hello world!</div>";
- setBodyContent(bodyContent);
- EXPECT_EQ(bodyContent, serialize<EditingStrategy>());
- EXPECT_EQ(bodyContent, serialize<EditingInComposedTreeStrategy>());
-}
-
-TEST_F(StyledMarkupSerializerTest, FormControlInput)
-{
- const char* bodyContent = "<input value='foo'>";
- setBodyContent(bodyContent);
- const char* expectedResult = "<input value=\"foo\">";
- EXPECT_EQ(expectedResult, serialize<EditingStrategy>());
- EXPECT_EQ(expectedResult, serialize<EditingInComposedTreeStrategy>());
-}
-
-TEST_F(StyledMarkupSerializerTest, FormControlInputRange)
-{
- const char* bodyContent = "<input type=range>";
- setBodyContent(bodyContent);
- const char* expectedResult = "<input type=\"range\">";
- EXPECT_EQ(expectedResult, serialize<EditingStrategy>());
- EXPECT_EQ(expectedResult, serialize<EditingInComposedTreeStrategy>());
-}
-
-TEST_F(StyledMarkupSerializerTest, FormControlSelect)
-{
- const char* bodyContent = "<select><option value=\"1\">one</option><option value=\"2\">two</option></select>";
- setBodyContent(bodyContent);
- EXPECT_EQ(bodyContent, serialize<EditingStrategy>());
- EXPECT_EQ(bodyContent, serialize<EditingInComposedTreeStrategy>());
-}
-
-TEST_F(StyledMarkupSerializerTest, FormControlTextArea)
-{
- const char* bodyContent = "<textarea>foo bar</textarea>";
- setBodyContent(bodyContent);
- const char* expectedResult = "<textarea></textarea>";
- EXPECT_EQ(expectedResult, serialize<EditingStrategy>())
- << "contents of TEXTAREA element should not be appeared.";
- EXPECT_EQ(expectedResult, serialize<EditingInComposedTreeStrategy>());
-}
-
-TEST_F(StyledMarkupSerializerTest, HeadingFormatting)
-{
- const char* bodyContent = "<h4>Hello world!</h4>";
- setBodyContent(bodyContent);
- EXPECT_EQ(bodyContent, serialize<EditingStrategy>());
- EXPECT_EQ(bodyContent, serialize<EditingInComposedTreeStrategy>());
-}
-
-TEST_F(StyledMarkupSerializerTest, InlineFormatting)
-{
- const char* bodyContent = "<b>Hello world!</b>";
- setBodyContent(bodyContent);
- EXPECT_EQ(bodyContent, serialize<EditingStrategy>());
- EXPECT_EQ(bodyContent, serialize<EditingInComposedTreeStrategy>());
-}
-
-TEST_F(StyledMarkupSerializerTest, Mixed)
-{
- const char* bodyContent = "<i>foo<b>bar</b>baz</i>";
- setBodyContent(bodyContent);
- EXPECT_EQ(bodyContent, serialize<EditingStrategy>());
- EXPECT_EQ(bodyContent, serialize<EditingInComposedTreeStrategy>());
-}
-
-TEST_F(StyledMarkupSerializerTest, ShadowTreeDistributeOrder)
-{
- const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\">22</b>33</p>";
- const char* shadowContent = "<a><content select=#two></content><content select=#one></content></a>";
- setBodyContent(bodyContent);
- setShadowContent(shadowContent);
- EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\">22</b></p>", serialize<EditingStrategy>())
- << "00 and 33 aren't appeared since they aren't distributed.";
- EXPECT_EQ("<p id=\"host\"><a><b id=\"two\">22</b><b id=\"one\">11</b></a></p>", serialize<EditingInComposedTreeStrategy>())
- << "00 and 33 aren't appeared since they aren't distributed.";
-}
-
-TEST_F(StyledMarkupSerializerTest, ShadowTreeInput)
-{
- const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\"><input value=\"22\"></b>33</p>";
- const char* shadowContent = "<a><content select=#two></content><content select=#one></content></a>";
- setBodyContent(bodyContent);
- setShadowContent(shadowContent);
- EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\"><input value=\"22\"></b></p>", serialize<EditingStrategy>())
- << "00 and 33 aren't appeared since they aren't distributed.";
- EXPECT_EQ("<p id=\"host\"><a><b id=\"two\"><input value=\"22\"></b><b id=\"one\">11</b></a></p>", serialize<EditingInComposedTreeStrategy>())
- << "00 and 33 aren't appeared since they aren't distributed.";
-}
-
-TEST_F(StyledMarkupSerializerTest, ShadowTreeNested)
-{
- const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\">22</b>33</p>";
- const char* shadowContent1 = "<a><content select=#two></content><b id=host2></b><content select=#one></content></a>";
- const char* shadowContent2 = "NESTED";
- setBodyContent(bodyContent);
- RefPtrWillBeRawPtr<ShadowRoot> shadowRoot1 = setShadowContent(shadowContent1);
- createShadowRootForElementWithIDAndSetInnerHTML(*shadowRoot1, "host2", shadowContent2);
-
- EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\">22</b></p>", serialize<EditingStrategy>())
- << "00 and 33 aren't appeared since they aren't distributed.";
- EXPECT_EQ("<p id=\"host\"><a><b id=\"two\">22</b><b id=\"host2\">NESTED</b><b id=\"one\">11</b></a></p>", serialize<EditingInComposedTreeStrategy>())
- << "00 and 33 aren't appeared since they aren't distributed.";
-}
-
-TEST_F(StyledMarkupSerializerTest, StyleDisplayNone)
-{
- const char* bodyContent = "<b>00<i style='display:none'>11</i>22</b>";
- setBodyContent(bodyContent);
- const char* expectedResult = "<b>0022</b>";
- EXPECT_EQ(expectedResult, serialize<EditingStrategy>());
- EXPECT_EQ(expectedResult, serialize<EditingInComposedTreeStrategy>());
-}
-
-TEST_F(StyledMarkupSerializerTest, StyleDisplayNoneAndNewLines)
-{
- const char* bodyContent = "<div style='display:none'>11</div>\n\n";
- setBodyContent(bodyContent);
- EXPECT_EQ("", serialize<EditingStrategy>());
- EXPECT_EQ("", serialize<EditingInComposedTreeStrategy>());
-}
-
-TEST_F(StyledMarkupSerializerTest, ShadowTreeStyle)
-{
- const char* bodyContent = "<p id='host' style='color: red'><span style='font-weight: bold;'><span id='one'>11</span></span></p>\n";
- setBodyContent(bodyContent);
- RefPtrWillBeRawPtr<Element> one = document().getElementById("one");
- RefPtrWillBeRawPtr<Text> text = toText(one->firstChild());
- Position startDOM(text, 0);
- Position endDOM(text, 2);
- const std::string& serializedDOM = serializePart<EditingStrategy>(startDOM, endDOM, AnnotateForInterchange);
-
- bodyContent = "<p id='host' style='color: red'>00<span id='one'>11</span>22</p>\n";
- const char* shadowContent = "<span style='font-weight: bold'><content select=#one></content></span>";
- setBodyContent(bodyContent);
- setShadowContent(shadowContent);
- one = document().getElementById("one");
- text = toText(one->firstChild());
- PositionInComposedTree startICT(text, 0);
- PositionInComposedTree endICT(text, 2);
- const std::string& serializedICT = serializePart<EditingInComposedTreeStrategy>(startICT, endICT, AnnotateForInterchange);
-
- EXPECT_EQ(serializedDOM, serializedICT);
-}
-
-TEST_F(StyledMarkupSerializerTest, AcrossShadow)
-{
- const char* bodyContent = "<p id='host1'>[<span id='one'>11</span>]</p><p id='host2'>[<span id='two'>22</span>]</p>";
- setBodyContent(bodyContent);
- RefPtrWillBeRawPtr<Element> one = document().getElementById("one");
- RefPtrWillBeRawPtr<Element> two = document().getElementById("two");
- Position startDOM(toText(one->firstChild()), 0);
- Position endDOM(toText(two->firstChild()), 2);
- const std::string& serializedDOM = serializePart<EditingStrategy>(startDOM, endDOM, AnnotateForInterchange);
-
- bodyContent = "<p id='host1'><span id='one'>11</span></p><p id='host2'><span id='two'>22</span></p>";
- const char* shadowContent1 = "[<content select=#one></content>]";
- const char* shadowContent2 = "[<content select=#two></content>]";
- setBodyContent(bodyContent);
- setShadowContent(shadowContent1, "host1");
- setShadowContent(shadowContent2, "host2");
- one = document().getElementById("one");
- two = document().getElementById("two");
- PositionInComposedTree startICT(toText(one->firstChild()), 0);
- PositionInComposedTree endICT(toText(two->firstChild()), 2);
- const std::string& serializedICT = serializePart<EditingInComposedTreeStrategy>(startICT, endICT, AnnotateForInterchange);
-
- EXPECT_EQ(serializedDOM, serializedICT);
-}
-
-TEST_F(StyledMarkupSerializerTest, AcrossInvisibleElements)
-{
- const char* bodyContent = "<span id='span1' style='display: none'>11</span><span id='span2' style='display: none'>22</span>";
- setBodyContent(bodyContent);
- RefPtrWillBeRawPtr<Element> span1 = document().getElementById("span1");
- RefPtrWillBeRawPtr<Element> span2 = document().getElementById("span2");
- Position startDOM = Position::firstPositionInNode(span1.get());
- Position endDOM = Position::lastPositionInNode(span2.get());
- EXPECT_EQ("", serializePart<EditingStrategy>(startDOM, endDOM));
- PositionInComposedTree startICT = PositionInComposedTree::firstPositionInNode(span1.get());
- PositionInComposedTree endICT = PositionInComposedTree::lastPositionInNode(span2.get());
- EXPECT_EQ("", serializePart<EditingInComposedTreeStrategy>(startICT, endICT));
-}
-
-} // namespace blink
« no previous file with comments | « Source/core/editing/StyledMarkupSerializer.cpp ('k') | Source/core/editing/TextOffset.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698