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

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

Issue 2654933003: platform/testing/{URL|Unit}TestHelpers improvements (Closed)
Patch Set: cleanup Created 3 years, 10 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 /* 1 /*
2 * Copyright (C) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 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 18 matching lines...) Expand all
29 */ 29 */
30 #include "core/frame/BrowserControls.h" 30 #include "core/frame/BrowserControls.h"
31 31
32 #include "core/dom/ClientRect.h" 32 #include "core/dom/ClientRect.h"
33 #include "core/frame/FrameHost.h" 33 #include "core/frame/FrameHost.h"
34 #include "core/frame/FrameView.h" 34 #include "core/frame/FrameView.h"
35 #include "core/frame/LocalFrame.h" 35 #include "core/frame/LocalFrame.h"
36 #include "core/frame/VisualViewport.h" 36 #include "core/frame/VisualViewport.h"
37 #include "core/page/Page.h" 37 #include "core/page/Page.h"
38 #include "platform/testing/URLTestHelpers.h" 38 #include "platform/testing/URLTestHelpers.h"
39 #include "platform/testing/UnitTestHelpers.h"
39 #include "public/platform/Platform.h" 40 #include "public/platform/Platform.h"
40 #include "public/platform/WebURLLoaderMockFactory.h" 41 #include "public/platform/WebURLLoaderMockFactory.h"
41 #include "public/web/WebCache.h" 42 #include "public/web/WebCache.h"
42 #include "public/web/WebElement.h" 43 #include "public/web/WebElement.h"
43 #include "public/web/WebSettings.h" 44 #include "public/web/WebSettings.h"
44 #include "testing/gmock/include/gmock/gmock.h" 45 #include "testing/gmock/include/gmock/gmock.h"
45 #include "testing/gtest/include/gtest/gtest.h" 46 #include "testing/gtest/include/gtest/gtest.h"
46 #include "web/WebLocalFrameImpl.h" 47 #include "web/WebLocalFrameImpl.h"
47 #include "web/tests/FrameTestHelpers.h" 48 #include "web/tests/FrameTestHelpers.h"
48 49
49 namespace blink { 50 namespace blink {
50 51
51 // These tests cover browser controls scrolling on main-thread. 52 // These tests cover browser controls scrolling on main-thread.
52 // The animation for completing a partial show/hide is done in compositor so 53 // The animation for completing a partial show/hide is done in compositor so
53 // it is not covered here. 54 // it is not covered here.
54 class BrowserControlsTest : public testing::Test { 55 class BrowserControlsTest : public ::testing::Test {
55 public: 56 public:
56 BrowserControlsTest() : m_baseURL("http://www.test.com/") { 57 BrowserControlsTest() : m_baseURL("http://www.test.com/") {
57 registerMockedHttpURLLoad("large-div.html"); 58 registerMockedHttpURLLoad("large-div.html");
58 registerMockedHttpURLLoad("overflow-scrolling.html"); 59 registerMockedHttpURLLoad("overflow-scrolling.html");
59 registerMockedHttpURLLoad("iframe-scrolling.html"); 60 registerMockedHttpURLLoad("iframe-scrolling.html");
60 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); 61 registerMockedHttpURLLoad("iframe-scrolling-inner.html");
61 registerMockedHttpURLLoad("percent-height.html"); 62 registerMockedHttpURLLoad("percent-height.html");
62 registerMockedHttpURLLoad("vh-height.html"); 63 registerMockedHttpURLLoad("vh-height.html");
63 registerMockedHttpURLLoad("vh-height-width-800.html"); 64 registerMockedHttpURLLoad("vh-height-width-800.html");
64 registerMockedHttpURLLoad("vh-height-width-800-extra-wide.html"); 65 registerMockedHttpURLLoad("vh-height-width-800-extra-wide.html");
(...skipping 21 matching lines...) Expand all
86 settings->setAcceleratedCompositingEnabled(true); 87 settings->setAcceleratedCompositingEnabled(true);
87 settings->setPreferCompositingToLCDTextEnabled(true); 88 settings->setPreferCompositingToLCDTextEnabled(true);
88 // Android settings 89 // Android settings
89 settings->setViewportEnabled(true); 90 settings->setViewportEnabled(true);
90 settings->setViewportMetaEnabled(true); 91 settings->setViewportMetaEnabled(true);
91 settings->setShrinksViewportContentToFit(true); 92 settings->setShrinksViewportContentToFit(true);
92 settings->setMainFrameResizesAreOrientationChanges(true); 93 settings->setMainFrameResizesAreOrientationChanges(true);
93 } 94 }
94 95
95 void registerMockedHttpURLLoad(const std::string& fileName) { 96 void registerMockedHttpURLLoad(const std::string& fileName) {
96 URLTestHelpers::registerMockedURLFromBaseURL( 97 URLTestHelpers::registerMockedURLLoadFromBase(
97 WebString::fromUTF8(m_baseURL.c_str()), 98 WebString::fromUTF8(m_baseURL.c_str()), testing::webTestDataPath(),
Takashi Toyoshima 2017/01/26 10:57:57 removing c_str()
98 WebString::fromUTF8(fileName.c_str())); 99 WebString::fromUTF8(fileName.c_str()));
99 } 100 }
100 101
101 WebCoalescedInputEvent generateEvent(WebInputEvent::Type type, 102 WebCoalescedInputEvent generateEvent(WebInputEvent::Type type,
102 int deltaX = 0, 103 int deltaX = 0,
103 int deltaY = 0) { 104 int deltaY = 0) {
104 WebGestureEvent event(type, WebInputEvent::NoModifiers, 105 WebGestureEvent event(type, WebInputEvent::NoModifiers,
105 WebInputEvent::TimeStampForTesting); 106 WebInputEvent::TimeStampForTesting);
106 event.sourceDevice = WebGestureDeviceTouchscreen; 107 event.sourceDevice = WebGestureDeviceTouchscreen;
107 event.x = 100; 108 event.x = 100;
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 view->setScrollOffset(view->getScrollOffset(), ProgrammaticScroll); 1000 view->setScrollOffset(view->getScrollOffset(), ProgrammaticScroll);
1000 1001
1001 ASSERT_EQ(80.f, webView->browserControls().contentOffset()); 1002 ASSERT_EQ(80.f, webView->browserControls().contentOffset());
1002 EXPECT_EQ(expectedRootOffset, rootViewport->getScrollOffset().height()); 1003 EXPECT_EQ(expectedRootOffset, rootViewport->getScrollOffset().height());
1003 1004
1004 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); 1005 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd));
1005 } 1006 }
1006 } 1007 }
1007 1008
1008 } // namespace blink 1009 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698