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

Side by Side Diff: third_party/WebKit/Source/core/editing/EditorTest.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/Editor.h" 5 #include "core/editing/Editor.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/editing/EditingTestBase.h" 8 #include "core/editing/EditingTestBase.h"
9 #include "core/html/HTMLBodyElement.h" 9 #include "core/html/HTMLBodyElement.h"
10 #include "core/html/HTMLDivElement.h" 10 #include "core/html/HTMLDivElement.h"
11 #include "core/html/HTMLHeadElement.h" 11 #include "core/html/HTMLHeadElement.h"
12 #include "core/html/HTMLHtmlElement.h" 12 #include "core/html/HTMLHtmlElement.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class EditorTest : public EditingTestBase { 16 class EditorTest : public EditingTestBase {
17 protected: 17 protected:
18 void makeDocumentEmpty(); 18 void makeDocumentEmpty();
19 }; 19 };
20 20
21 void EditorTest::makeDocumentEmpty() 21 void EditorTest::makeDocumentEmpty()
22 { 22 {
23 while (document().firstChild()) 23 while (document().firstChild())
24 document().removeChild(document().firstChild()); 24 document().removeChild(document().firstChild());
25 } 25 }
26 26
27 TEST_F(EditorTest, tidyUpHTMLStructureFromBody) 27 TEST_F(EditorTest, tidyUpHTMLStructureFromBody)
28 { 28 {
29 RefPtrWillBeRawPtr<Element> body = HTMLBodyElement::create(document()); 29 RawPtr<Element> body = HTMLBodyElement::create(document());
30 makeDocumentEmpty(); 30 makeDocumentEmpty();
31 document().setDesignMode("on"); 31 document().setDesignMode("on");
32 document().appendChild(body); 32 document().appendChild(body);
33 Editor::tidyUpHTMLStructure(document()); 33 Editor::tidyUpHTMLStructure(document());
34 34
35 EXPECT_TRUE(isHTMLHtmlElement(document().documentElement())); 35 EXPECT_TRUE(isHTMLHtmlElement(document().documentElement()));
36 EXPECT_EQ(body, document().body()); 36 EXPECT_EQ(body, document().body());
37 EXPECT_EQ(document().documentElement(), body->parentNode()); 37 EXPECT_EQ(document().documentElement(), body->parentNode());
38 } 38 }
39 39
40 TEST_F(EditorTest, tidyUpHTMLStructureFromDiv) 40 TEST_F(EditorTest, tidyUpHTMLStructureFromDiv)
41 { 41 {
42 RefPtrWillBeRawPtr<Element> div = HTMLDivElement::create(document()); 42 RawPtr<Element> div = HTMLDivElement::create(document());
43 makeDocumentEmpty(); 43 makeDocumentEmpty();
44 document().setDesignMode("on"); 44 document().setDesignMode("on");
45 document().appendChild(div); 45 document().appendChild(div);
46 Editor::tidyUpHTMLStructure(document()); 46 Editor::tidyUpHTMLStructure(document());
47 47
48 EXPECT_TRUE(isHTMLHtmlElement(document().documentElement())); 48 EXPECT_TRUE(isHTMLHtmlElement(document().documentElement()));
49 EXPECT_TRUE(isHTMLBodyElement(document().body())); 49 EXPECT_TRUE(isHTMLBodyElement(document().body()));
50 EXPECT_EQ(document().body(), div->parentNode()); 50 EXPECT_EQ(document().body(), div->parentNode());
51 } 51 }
52 52
53 TEST_F(EditorTest, tidyUpHTMLStructureFromHead) 53 TEST_F(EditorTest, tidyUpHTMLStructureFromHead)
54 { 54 {
55 RefPtrWillBeRawPtr<Element> head = HTMLHeadElement::create(document()); 55 RawPtr<Element> head = HTMLHeadElement::create(document());
56 makeDocumentEmpty(); 56 makeDocumentEmpty();
57 document().setDesignMode("on"); 57 document().setDesignMode("on");
58 document().appendChild(head); 58 document().appendChild(head);
59 Editor::tidyUpHTMLStructure(document()); 59 Editor::tidyUpHTMLStructure(document());
60 60
61 EXPECT_TRUE(isHTMLHtmlElement(document().documentElement())); 61 EXPECT_TRUE(isHTMLHtmlElement(document().documentElement()));
62 EXPECT_TRUE(isHTMLBodyElement(document().body())); 62 EXPECT_TRUE(isHTMLBodyElement(document().body()));
63 EXPECT_EQ(document().documentElement(), head->parentNode()); 63 EXPECT_EQ(document().documentElement(), head->parentNode());
64 } 64 }
65 65
66 } // namespace blink 66 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.cpp ('k') | third_party/WebKit/Source/core/editing/EphemeralRange.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698