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

Side by Side Diff: third_party/WebKit/Source/web/tests/FrameTestHelpers.h

Issue 2036403002: Always use the WebFrameWidget when attaching the root graphics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 class WebFrame; 52 class WebFrame;
53 class WebFrameWidget; 53 class WebFrameWidget;
54 class WebLocalFrame; 54 class WebLocalFrame;
55 class WebRemoteFrame; 55 class WebRemoteFrame;
56 class WebRemoteFrameImpl; 56 class WebRemoteFrameImpl;
57 enum class WebCachePolicy; 57 enum class WebCachePolicy;
58 58
59 namespace FrameTestHelpers { 59 namespace FrameTestHelpers {
60 60
61 class TestWebFrameClient; 61 class TestWebFrameClient;
62 using TestWebWidgetClient = WebWidgetClient; 62 class TestWebWidgetClient;
63 class TestWebViewClient;
63 64
64 // Loads a url into the specified WebFrame for testing purposes. Pumps any 65 // Loads a url into the specified WebFrame for testing purposes. Pumps any
65 // pending resource requests, as well as waiting for the threaded parser to 66 // pending resource requests, as well as waiting for the threaded parser to
66 // finish, before returning. 67 // finish, before returning.
67 void loadFrame(WebFrame*, const std::string& url); 68 void loadFrame(WebFrame*, const std::string& url);
68 // Same as above, but for WebFrame::loadHTMLString(). 69 // Same as above, but for WebFrame::loadHTMLString().
69 void loadHTMLString(WebFrame*, const std::string& html, const WebURL& baseURL); 70 void loadHTMLString(WebFrame*, const std::string& html, const WebURL& baseURL);
70 // Same as above, but for WebFrame::loadHistoryItem(). 71 // Same as above, but for WebFrame::loadHistoryItem().
71 void loadHistoryItem(WebFrame*, const WebHistoryItem&, WebHistoryLoadType, WebCa chePolicy); 72 void loadHistoryItem(WebFrame*, const WebHistoryItem&, WebHistoryLoadType, WebCa chePolicy);
72 // Same as above, but for WebFrame::reload(). 73 // Same as above, but for WebFrame::reload().
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 { 111 {
111 Settings::setMockScrollbarsEnabled(m_originalMockScrollbarEnabled); 112 Settings::setMockScrollbarsEnabled(m_originalMockScrollbarEnabled);
112 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(m_originalOverlayScr ollbarsEnabled); 113 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(m_originalOverlayScr ollbarsEnabled);
113 } 114 }
114 115
115 private: 116 private:
116 bool m_originalMockScrollbarEnabled; 117 bool m_originalMockScrollbarEnabled;
117 bool m_originalOverlayScrollbarsEnabled; 118 bool m_originalOverlayScrollbarsEnabled;
118 }; 119 };
119 120
121 class TestWebWidgetClient : public WebWidgetClient {
122 public:
123 virtual ~TestWebWidgetClient() {}
124 bool allowsBrokenNullLayerTreeView() const override { return true; }
125 };
126
127 class TestWebViewWidgetClient : public TestWebWidgetClient {
128 public:
129 TestWebViewWidgetClient(TestWebViewClient* testWebViewClient)
dcheng 2016/06/08 00:10:17 Nit: explicit
lfg 2016/06/08 21:09:47 Done.
130 : m_testWebViewClient(testWebViewClient)
131 {
132 }
133 virtual ~TestWebViewWidgetClient() {}
134
135 void initializeLayerTreeView() override;
136 WebLayerTreeView* layerTreeView() override;
137 void scheduleAnimation() override;
138
139 private:
140 TestWebViewClient* m_testWebViewClient;
141 };
142
120 class TestWebViewClient : public WebViewClient { 143 class TestWebViewClient : public WebViewClient {
121 public: 144 public:
122 TestWebViewClient() : m_animationScheduled(false) { } 145 TestWebViewClient()
146 : m_testWebWidgetClient(this)
147 , m_animationScheduled(false)
148 {
149 }
123 virtual ~TestWebViewClient() { } 150 virtual ~TestWebViewClient() { }
124 void initializeLayerTreeView() override; 151 void initializeLayerTreeView() override;
125 WebLayerTreeView* layerTreeView() override { return m_layerTreeView.get(); } 152 WebLayerTreeView* layerTreeView() override { return m_layerTreeView.get(); }
126 153
127 void scheduleAnimation() override { m_animationScheduled = true; } 154 void scheduleAnimation() override { m_animationScheduled = true; }
128 bool animationScheduled() { return m_animationScheduled; } 155 bool animationScheduled() { return m_animationScheduled; }
129 void clearAnimationScheduled() { m_animationScheduled = false; } 156 void clearAnimationScheduled() { m_animationScheduled = false; }
130 157
131 // TODO(lfg): This is a temporary method to retrieve the WebWidgetClient, 158 // TODO(lfg): This is a temporary method to retrieve the WebWidgetClient,
132 // while we refactor WebView to not inherit from Webwidget. 159 // while we refactor WebView to not inherit from Webwidget.
133 // Returns the WebWidgetClient. 160 // Returns the WebWidgetClient.
134 WebWidgetClient* widgetClient() { return this; } 161 TestWebWidgetClient* widgetClient() { return &m_testWebWidgetClient; }
135 162
136 private: 163 private:
164 TestWebViewWidgetClient m_testWebWidgetClient;
137 OwnPtr<WebLayerTreeView> m_layerTreeView; 165 OwnPtr<WebLayerTreeView> m_layerTreeView;
138 bool m_animationScheduled; 166 bool m_animationScheduled;
139 }; 167 };
140 168
141 // Convenience class for handling the lifetime of a WebView and its associated m ainframe in tests. 169 // Convenience class for handling the lifetime of a WebView and its associated m ainframe in tests.
142 class WebViewHelper { 170 class WebViewHelper {
143 WTF_MAKE_NONCOPYABLE(WebViewHelper); 171 WTF_MAKE_NONCOPYABLE(WebViewHelper);
144 public: 172 public:
145 WebViewHelper(SettingOverrider* = 0); 173 WebViewHelper(SettingOverrider* = 0);
146 ~WebViewHelper(); 174 ~WebViewHelper();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 WebDOMMessageEvent) override { } 234 WebDOMMessageEvent) override { }
207 235
208 private: 236 private:
209 Persistent<WebRemoteFrameImpl> const m_frame; 237 Persistent<WebRemoteFrameImpl> const m_frame;
210 }; 238 };
211 239
212 } // namespace FrameTestHelpers 240 } // namespace FrameTestHelpers
213 } // namespace blink 241 } // namespace blink
214 242
215 #endif // FrameTestHelpers_h 243 #endif // FrameTestHelpers_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698