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

Side by Side Diff: Source/web/tests/ViewportTest.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/TouchActionTest.cpp ('k') | Source/web/tests/WebDocumentTest.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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "public/web/WebFrame.h" 48 #include "public/web/WebFrame.h"
49 #include "public/web/WebScriptSource.h" 49 #include "public/web/WebScriptSource.h"
50 #include "public/web/WebSettings.h" 50 #include "public/web/WebSettings.h"
51 #include "public/web/WebViewClient.h" 51 #include "public/web/WebViewClient.h"
52 #include "web/tests/FrameTestHelpers.h" 52 #include "web/tests/FrameTestHelpers.h"
53 #include <gmock/gmock.h> 53 #include <gmock/gmock.h>
54 #include <gtest/gtest.h> 54 #include <gtest/gtest.h>
55 55
56 #include <vector> 56 #include <vector>
57 57
58 namespace {
59
60 using blink::FrameTestHelpers::runPendingTasks;
58 using namespace blink; 61 using namespace blink;
59 using blink::LocalFrame;
60 using blink::FrameView;
61 using blink::IntPoint;
62 using blink::IntRect;
63 using blink::IntSize;
64 using blink::Page;
65 using blink::PageScaleConstraints;
66 using blink::ViewportDescription;
67 using blink::FrameTestHelpers::runPendingTasks;
68
69 namespace {
70 62
71 class ViewportTest : public testing::Test { 63 class ViewportTest : public testing::Test {
72 protected: 64 protected:
73 ViewportTest() 65 ViewportTest()
74 : m_baseURL("http://www.test.com/") 66 : m_baseURL("http://www.test.com/")
75 , m_chromeURL("chrome://") 67 , m_chromeURL("chrome://")
76 { 68 {
77 } 69 }
78 70
79 virtual ~ViewportTest() 71 virtual ~ViewportTest()
(...skipping 18 matching lines...) Expand all
98 } 90 }
99 91
100 std::string m_baseURL; 92 std::string m_baseURL;
101 std::string m_chromeURL; 93 std::string m_chromeURL;
102 }; 94 };
103 95
104 class UseMockScrollbarSettings { 96 class UseMockScrollbarSettings {
105 public: 97 public:
106 UseMockScrollbarSettings() 98 UseMockScrollbarSettings()
107 { 99 {
108 blink::Settings::setMockScrollbarsEnabled(true); 100 Settings::setMockScrollbarsEnabled(true);
109 blink::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); 101 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true);
110 EXPECT_TRUE(blink::ScrollbarTheme::theme()->usesOverlayScrollbars()); 102 EXPECT_TRUE(ScrollbarTheme::theme()->usesOverlayScrollbars());
111 } 103 }
112 104
113 ~UseMockScrollbarSettings() 105 ~UseMockScrollbarSettings()
114 { 106 {
115 blink::Settings::setMockScrollbarsEnabled(false); 107 Settings::setMockScrollbarsEnabled(false);
116 blink::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); 108 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false);
117 } 109 }
118 }; 110 };
119 111
120 static void setViewportSettings(WebSettings* settings) 112 static void setViewportSettings(WebSettings* settings)
121 { 113 {
122 settings->setViewportEnabled(true); 114 settings->setViewportEnabled(true);
123 settings->setViewportMetaEnabled(true); 115 settings->setViewportMetaEnabled(true);
124 settings->setMainFrameResizesAreOrientationChanges(true); 116 settings->setMainFrameResizesAreOrientationChanges(true);
125 } 117 }
126 118
127 static PageScaleConstraints runViewportTest(Page* page, int initialWidth, int in itialHeight) 119 static PageScaleConstraints runViewportTest(Page* page, int initialWidth, int in itialHeight)
128 { 120 {
129 IntSize initialViewportSize(initialWidth, initialHeight); 121 IntSize initialViewportSize(initialWidth, initialHeight);
130 toLocalFrame(page->mainFrame())->view()->setFrameRect(IntRect(IntPoint::zero (), initialViewportSize)); 122 toLocalFrame(page->mainFrame())->view()->setFrameRect(IntRect(IntPoint::zero (), initialViewportSize));
131 ViewportDescription description = page->viewportDescription(); 123 ViewportDescription description = page->viewportDescription();
132 PageScaleConstraints constraints = description.resolve(initialViewportSize, blink::Length(980, blink::Fixed)); 124 PageScaleConstraints constraints = description.resolve(initialViewportSize, Length(980, blink::Fixed));
133 125
134 constraints.fitToContentsWidth(constraints.layoutSize.width(), initialWidth) ; 126 constraints.fitToContentsWidth(constraints.layoutSize.width(), initialWidth) ;
135 return constraints; 127 return constraints;
136 } 128 }
137 129
138 TEST_F(ViewportTest, viewport1) 130 TEST_F(ViewportTest, viewport1)
139 { 131 {
140 UseMockScrollbarSettings mockScrollbarSettings; 132 UseMockScrollbarSettings mockScrollbarSettings;
141 registerMockedHttpURLLoad("viewport/viewport-1.html"); 133 registerMockedHttpURLLoad("viewport/viewport-1.html");
142 134
(...skipping 3030 matching lines...) Expand 10 before | Expand all | Expand 10 after
3173 FrameTestHelpers::WebViewHelper webViewHelper; 3165 FrameTestHelpers::WebViewHelper webViewHelper;
3174 webViewHelper.initializeAndLoad(m_baseURL + "viewport/viewport-warnings-7.ht ml", true, &webFrameClient, 0, setViewportSettings); 3166 webViewHelper.initializeAndLoad(m_baseURL + "viewport/viewport-warnings-7.ht ml", true, &webFrameClient, 0, setViewportSettings);
3175 3167
3176 Page* page = webViewHelper.webViewImpl()->page(); 3168 Page* page = webViewHelper.webViewImpl()->page();
3177 runViewportTest(page, 320, 352); 3169 runViewportTest(page, 320, 352);
3178 3170
3179 EXPECT_EQ(0U, webFrameClient.messages.size()); 3171 EXPECT_EQ(0U, webFrameClient.messages.size());
3180 } 3172 }
3181 3173
3182 } // namespace 3174 } // namespace
OLDNEW
« no previous file with comments | « Source/web/tests/TouchActionTest.cpp ('k') | Source/web/tests/WebDocumentTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698