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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2154493002: FrameTestHelpers: support Settings-parameterized tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@rls-enable
Patch Set: Elminate unnecessary #include. Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/Source/web/tests/VisualViewportTest.cpp ('k') | no next file » | 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 Element* element = frame->frame()->document()->getElementById(id); 273 Element* element = frame->frame()->document()->getElementById(id);
274 DCHECK(element); 274 DCHECK(element);
275 element->remove(); 275 element->remove();
276 } 276 }
277 277
278 std::string m_baseURL; 278 std::string m_baseURL;
279 std::string m_notBaseURL; 279 std::string m_notBaseURL;
280 std::string m_chromeURL; 280 std::string m_chromeURL;
281 }; 281 };
282 282
283 enum ParameterizedWebFrameTestConfig {
284 Default,
285 RootLayerScrolls
286 };
287
288 class ParameterizedWebFrameTest 283 class ParameterizedWebFrameTest
289 : public WebFrameTest 284 : public WebFrameTest
290 , public ::testing::WithParamInterface<ParameterizedWebFrameTestConfig> 285 , public ::testing::WithParamInterface<FrameTestHelpers::SettingOverrideFunc tion>
291 , public FrameTestHelpers::SettingOverrider { 286 , public FrameTestHelpers::SettingOverrider {
292 public: 287 public:
293 288
294 void overrideSettings(WebSettings* settings) 289 void overrideSettings(WebSettings *settings) override
295 { 290 {
296 switch (GetParam()) { 291 GetParam()(settings);
297 case Default:
298 break;
299 case RootLayerScrolls:
300 settings->setRootLayerScrolls(true);
301 break;
302 }
303 } 292 }
304 }; 293 };
305 294
306 // Friendly string for gtest failure messages.
307 void PrintTo(ParameterizedWebFrameTestConfig config, ::std::ostream* os)
308 {
309 switch (config) {
310 case Default:
311 *os << "Default";
312 break;
313 case RootLayerScrolls:
314 *os << "RootLayerScrolls";
315 break;
316 }
317 }
318
319 INSTANTIATE_TEST_CASE_P(All, ParameterizedWebFrameTest, ::testing::Values( 295 INSTANTIATE_TEST_CASE_P(All, ParameterizedWebFrameTest, ::testing::Values(
320 ParameterizedWebFrameTestConfig::Default, 296 FrameTestHelpers::DefaultSettingOverride,
321 ParameterizedWebFrameTestConfig::RootLayerScrolls)); 297 FrameTestHelpers::RootLayerScrollsSettingOverride));
322 298
323 TEST_P(ParameterizedWebFrameTest, ContentText) 299 TEST_P(ParameterizedWebFrameTest, ContentText)
324 { 300 {
325 registerMockedHttpURLLoad("iframes_test.html"); 301 registerMockedHttpURLLoad("iframes_test.html");
326 registerMockedHttpURLLoad("visible_iframe.html"); 302 registerMockedHttpURLLoad("visible_iframe.html");
327 registerMockedHttpURLLoad("invisible_iframe.html"); 303 registerMockedHttpURLLoad("invisible_iframe.html");
328 registerMockedHttpURLLoad("zero_sized_iframe.html"); 304 registerMockedHttpURLLoad("zero_sized_iframe.html");
329 305
330 FrameTestHelpers::WebViewHelper webViewHelper(this); 306 FrameTestHelpers::WebViewHelper webViewHelper(this);
331 webViewHelper.initializeAndLoad(m_baseURL + "iframes_test.html"); 307 webViewHelper.initializeAndLoad(m_baseURL + "iframes_test.html");
(...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS caleFactor()); 2295 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS caleFactor());
2320 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra me()->scrollOffset()); 2296 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra me()->scrollOffset());
2321 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height * 0.8f)); 2297 webViewHelper.resize(WebSize(viewportSize.width, viewportSize.height * 0.8f));
2322 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS caleFactor()); 2298 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS caleFactor());
2323 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra me()->scrollOffset()); 2299 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra me()->scrollOffset());
2324 } 2300 }
2325 } 2301 }
2326 }; 2302 };
2327 2303
2328 INSTANTIATE_TEST_CASE_P(All, WebFrameResizeTest, ::testing::Values( 2304 INSTANTIATE_TEST_CASE_P(All, WebFrameResizeTest, ::testing::Values(
2329 ParameterizedWebFrameTestConfig::Default, 2305 FrameTestHelpers::DefaultSettingOverride,
2330 ParameterizedWebFrameTestConfig::RootLayerScrolls)); 2306 FrameTestHelpers::RootLayerScrollsSettingOverride));
2331 2307
2332 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForWidthEqualsDevice Width) 2308 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForWidthEqualsDevice Width)
2333 { 2309 {
2334 // With width=device-width, pageScaleFactor is preserved across resizes as 2310 // With width=device-width, pageScaleFactor is preserved across resizes as
2335 // long as the content adjusts according to the device-width. 2311 // long as the content adjusts according to the device-width.
2336 const char* url = "resize_scroll_mobile.html"; 2312 const char* url = "resize_scroll_mobile.html";
2337 const float initialPageScaleFactor = 1; 2313 const float initialPageScaleFactor = 1;
2338 const WebSize scrollOffset(0, 50); 2314 const WebSize scrollOffset(0, 50);
2339 const WebSize viewportSize(120, 160); 2315 const WebSize viewportSize(120, 160);
2340 const bool shouldScaleRelativeToViewportWidth = true; 2316 const bool shouldScaleRelativeToViewportWidth = true;
(...skipping 5673 matching lines...) Expand 10 before | Expand all | Expand 10 after
8014 runPendingTasks(); 7990 runPendingTasks();
8015 EXPECT_TRUE(callbackHelper.didComplete()); 7991 EXPECT_TRUE(callbackHelper.didComplete());
8016 return callbackHelper.stringValue(); 7992 return callbackHelper.stringValue();
8017 } 7993 }
8018 7994
8019 FixedLayoutTestWebViewClient m_client; 7995 FixedLayoutTestWebViewClient m_client;
8020 FrameTestHelpers::WebViewHelper m_webViewHelper; 7996 FrameTestHelpers::WebViewHelper m_webViewHelper;
8021 }; 7997 };
8022 7998
8023 INSTANTIATE_TEST_CASE_P(All, DeviceEmulationTest, ::testing::Values( 7999 INSTANTIATE_TEST_CASE_P(All, DeviceEmulationTest, ::testing::Values(
8024 ParameterizedWebFrameTestConfig::Default, 8000 FrameTestHelpers::DefaultSettingOverride,
8025 ParameterizedWebFrameTestConfig::RootLayerScrolls)); 8001 FrameTestHelpers::RootLayerScrollsSettingOverride));
8026 8002
8027 TEST_P(DeviceEmulationTest, DeviceSizeInvalidatedOnResize) 8003 TEST_P(DeviceEmulationTest, DeviceSizeInvalidatedOnResize)
8028 { 8004 {
8029 WebDeviceEmulationParams params; 8005 WebDeviceEmulationParams params;
8030 params.screenPosition = WebDeviceEmulationParams::Mobile; 8006 params.screenPosition = WebDeviceEmulationParams::Mobile;
8031 m_webViewHelper.webView()->enableDeviceEmulation(params); 8007 m_webViewHelper.webView()->enableDeviceEmulation(params);
8032 8008
8033 testResize(WebSize(700, 500), "300x300"); 8009 testResize(WebSize(700, 500), "300x300");
8034 testResize(WebSize(710, 500), "400x300"); 8010 testResize(WebSize(710, 500), "400x300");
8035 testResize(WebSize(690, 500), "200x300"); 8011 testResize(WebSize(690, 500), "200x300");
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
8813 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); 8789 request.setRequestorOrigin(WebSecurityOrigin::createUnique());
8814 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request); 8790 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request);
8815 8791
8816 // Normally, the result of the JS url replaces the existing contents on the 8792 // Normally, the result of the JS url replaces the existing contents on the
8817 // Document. However, if the JS triggers a navigation, the contents should 8793 // Document. However, if the JS triggers a navigation, the contents should
8818 // not be replaced. 8794 // not be replaced.
8819 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum ent()->documentElement()->innerText()); 8795 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum ent()->documentElement()->innerText());
8820 } 8796 }
8821 8797
8822 } // namespace blink 8798 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/VisualViewportTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698