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

Side by Side Diff: Source/web/tests/WebDocumentTest.cpp

Issue 545123002: Cleanup namespace usage in Source/web/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/tests/ViewportTest.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 6
7 #include "public/web/WebDocument.h" 7 #include "public/web/WebDocument.h"
8 8
9 #include "core/CSSPropertyNames.h" 9 #include "core/CSSPropertyNames.h"
10 #include "core/dom/NodeRenderStyle.h" 10 #include "core/dom/NodeRenderStyle.h"
11 #include "core/dom/StyleEngine.h" 11 #include "core/dom/StyleEngine.h"
12 #include "core/frame/LocalFrame.h" 12 #include "core/frame/LocalFrame.h"
13 #include "core/html/HTMLElement.h" 13 #include "core/html/HTMLElement.h"
14 #include "core/page/Page.h" 14 #include "core/page/Page.h"
15 #include "core/rendering/style/RenderStyle.h" 15 #include "core/rendering/style/RenderStyle.h"
16 #include "core/testing/URLTestHelpers.h" 16 #include "core/testing/URLTestHelpers.h"
17 #include "platform/graphics/Color.h" 17 #include "platform/graphics/Color.h"
18 #include "web/tests/FrameTestHelpers.h" 18 #include "web/tests/FrameTestHelpers.h"
19
20 #include <gtest/gtest.h> 19 #include <gtest/gtest.h>
21 20
22 using namespace blink;
23 using blink::Color;
24 using blink::Document;
25 using blink::HTMLElement;
26 using blink::RenderStyle;
27 using blink::FrameTestHelpers::WebViewHelper;
28 using blink::URLTestHelpers::toKURL;
29 using blink::WebDocument;
30
31 namespace { 21 namespace {
32 22
23 using blink::FrameTestHelpers::WebViewHelper;
24 using blink::URLTestHelpers::toKURL;
25 using namespace blink;
26
33 TEST(WebDocumentTest, InsertStyleSheet) 27 TEST(WebDocumentTest, InsertStyleSheet)
34 { 28 {
35 WebViewHelper webViewHelper; 29 WebViewHelper webViewHelper;
36 webViewHelper.initializeAndLoad("about:blank"); 30 webViewHelper.initializeAndLoad("about:blank");
37 31
38 WebDocument webDoc = webViewHelper.webView()->mainFrame()->document(); 32 WebDocument webDoc = webViewHelper.webView()->mainFrame()->document();
39 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr ame())->document(); 33 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr ame())->document();
40 34
41 webDoc.insertStyleSheet("body { color: green }"); 35 webDoc.insertStyleSheet("body { color: green }");
42 36
43 // Check insertStyleSheet did not cause a synchronous style recalc. 37 // Check insertStyleSheet did not cause a synchronous style recalc.
44 unsigned accessCount = coreDoc->styleEngine()->resolverAccessCount(); 38 unsigned accessCount = coreDoc->styleEngine()->resolverAccessCount();
45 ASSERT_EQ(0U, accessCount); 39 ASSERT_EQ(0U, accessCount);
46 40
47 HTMLElement* bodyElement = coreDoc->body(); 41 HTMLElement* bodyElement = coreDoc->body();
48 ASSERT(bodyElement); 42 ASSERT(bodyElement);
49 43
50 RenderStyle* style = bodyElement->renderStyle(); 44 RenderStyle* style = bodyElement->renderStyle();
51 ASSERT(style); 45 ASSERT(style);
52 46
53 // Inserted stylesheet not yet applied. 47 // Inserted stylesheet not yet applied.
54 ASSERT_EQ(Color(0, 0, 0), style->visitedDependentColor(blink::CSSPropertyCol or)); 48 ASSERT_EQ(Color(0, 0, 0), style->visitedDependentColor(CSSPropertyColor));
55 49
56 // Apply inserted stylesheet. 50 // Apply inserted stylesheet.
57 coreDoc->updateRenderTreeIfNeeded(); 51 coreDoc->updateRenderTreeIfNeeded();
58 52
59 style = bodyElement->renderStyle(); 53 style = bodyElement->renderStyle();
60 ASSERT(style); 54 ASSERT(style);
61 55
62 // Inserted stylesheet applied. 56 // Inserted stylesheet applied.
63 ASSERT_EQ(Color(0, 128, 0), style->visitedDependentColor(blink::CSSPropertyC olor)); 57 ASSERT_EQ(Color(0, 128, 0), style->visitedDependentColor(CSSPropertyColor));
64 } 58 }
65 59
66 TEST(WebDocumentTest, BeginExitTransition) 60 TEST(WebDocumentTest, BeginExitTransition)
67 { 61 {
68 std::string baseURL = "http://www.test.com:0/"; 62 std::string baseURL = "http://www.test.com:0/";
69 const char* htmlURL = "transition_exit.html"; 63 const char* htmlURL = "transition_exit.html";
70 const char* cssURL = "transition_exit.css"; 64 const char* cssURL = "transition_exit.css";
71 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + htmlURL), WebString:: fromUTF8(htmlURL)); 65 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + htmlURL), WebString:: fromUTF8(htmlURL));
72 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + cssURL), WebString::f romUTF8(cssURL)); 66 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + cssURL), WebString::f romUTF8(cssURL));
73 67
74 WebViewHelper webViewHelper; 68 WebViewHelper webViewHelper;
75 webViewHelper.initializeAndLoad(baseURL + htmlURL); 69 webViewHelper.initializeAndLoad(baseURL + htmlURL);
76 70
77 WebFrame* frame = webViewHelper.webView()->mainFrame(); 71 WebFrame* frame = webViewHelper.webView()->mainFrame();
78 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr ame())->document(); 72 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr ame())->document();
79 Element* transitionElement = coreDoc->getElementById("foo"); 73 Element* transitionElement = coreDoc->getElementById("foo");
80 ASSERT(transitionElement); 74 ASSERT(transitionElement);
81 75
82 RenderStyle* transitionStyle = transitionElement->renderStyle(); 76 RenderStyle* transitionStyle = transitionElement->renderStyle();
83 ASSERT(transitionStyle); 77 ASSERT(transitionStyle);
84 78
85 HTMLElement* bodyElement = coreDoc->body(); 79 HTMLElement* bodyElement = coreDoc->body();
86 ASSERT(bodyElement); 80 ASSERT(bodyElement);
87 81
88 RenderStyle* bodyStyle = bodyElement->renderStyle(); 82 RenderStyle* bodyStyle = bodyElement->renderStyle();
89 ASSERT(bodyStyle); 83 ASSERT(bodyStyle);
90 // The transition_exit.css stylesheet should not have been applied at this p oint. 84 // The transition_exit.css stylesheet should not have been applied at this p oint.
91 ASSERT_EQ(Color(0, 0, 0), bodyStyle->visitedDependentColor(blink::CSSPropert yColor)); 85 ASSERT_EQ(Color(0, 0, 0), bodyStyle->visitedDependentColor(CSSPropertyColor) );
92 86
93 frame->document().beginExitTransition("#foo"); 87 frame->document().beginExitTransition("#foo");
94 88
95 // Make sure the stylesheet load request gets processed. 89 // Make sure the stylesheet load request gets processed.
96 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); 90 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame);
97 coreDoc->updateRenderTreeIfNeeded(); 91 coreDoc->updateRenderTreeIfNeeded();
98 92
99 // The element should now be hidden. 93 // The element should now be hidden.
100 transitionStyle = transitionElement->renderStyle(); 94 transitionStyle = transitionElement->renderStyle();
101 ASSERT_TRUE(transitionStyle); 95 ASSERT_TRUE(transitionStyle);
102 ASSERT_EQ(transitionStyle->opacity(), 0); 96 ASSERT_EQ(transitionStyle->opacity(), 0);
103 97
104 // The stylesheet should now have been applied. 98 // The stylesheet should now have been applied.
105 bodyStyle = bodyElement->renderStyle(); 99 bodyStyle = bodyElement->renderStyle();
106 ASSERT(bodyStyle); 100 ASSERT(bodyStyle);
107 ASSERT_EQ(Color(0, 128, 0), bodyStyle->visitedDependentColor(blink::CSSPrope rtyColor)); 101 ASSERT_EQ(Color(0, 128, 0), bodyStyle->visitedDependentColor(CSSPropertyColo r));
108 } 102 }
109 103
110 } 104 }
OLDNEW
« no previous file with comments | « Source/web/tests/ViewportTest.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698