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

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

Issue 1328773002: Make classes and structures in web fast-allocated. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
« no previous file with comments | « Source/web/tests/FakeWebPlugin.h ('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) 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 22 matching lines...) Expand all
33 33
34 #include "core/frame/Settings.h" 34 #include "core/frame/Settings.h"
35 #include "platform/RuntimeEnabledFeatures.h" 35 #include "platform/RuntimeEnabledFeatures.h"
36 #include "platform/scroll/ScrollbarTheme.h" 36 #include "platform/scroll/ScrollbarTheme.h"
37 #include "public/platform/WebURLRequest.h" 37 #include "public/platform/WebURLRequest.h"
38 #include "public/web/WebFrameClient.h" 38 #include "public/web/WebFrameClient.h"
39 #include "public/web/WebHistoryItem.h" 39 #include "public/web/WebHistoryItem.h"
40 #include "public/web/WebRemoteFrameClient.h" 40 #include "public/web/WebRemoteFrameClient.h"
41 #include "public/web/WebViewClient.h" 41 #include "public/web/WebViewClient.h"
42 #include "web/WebViewImpl.h" 42 #include "web/WebViewImpl.h"
43 #include "wtf/Allocator.h"
43 #include "wtf/PassOwnPtr.h" 44 #include "wtf/PassOwnPtr.h"
44 #include <gmock/gmock.h> 45 #include <gmock/gmock.h>
45 #include <gtest/gtest.h> 46 #include <gtest/gtest.h>
46 #include <string> 47 #include <string>
47 48
48 namespace blink { 49 namespace blink {
49 50
50 namespace FrameTestHelpers { 51 namespace FrameTestHelpers {
51 52
52 class TestWebFrameClient; 53 class TestWebFrameClient;
(...skipping 14 matching lines...) Expand all
67 // this. Use one of the above helpers. 68 // this. Use one of the above helpers.
68 void pumpPendingRequestsDoNotUse(WebFrame*); 69 void pumpPendingRequestsDoNotUse(WebFrame*);
69 70
70 class SettingOverrider { 71 class SettingOverrider {
71 public: 72 public:
72 virtual void overrideSettings(WebSettings*) = 0; 73 virtual void overrideSettings(WebSettings*) = 0;
73 }; 74 };
74 75
75 // Convenience class for handling the lifetime of a WebView and its associated m ainframe in tests. 76 // Convenience class for handling the lifetime of a WebView and its associated m ainframe in tests.
76 class WebViewHelper { 77 class WebViewHelper {
78 DISALLOW_ALLOCATION();
77 WTF_MAKE_NONCOPYABLE(WebViewHelper); 79 WTF_MAKE_NONCOPYABLE(WebViewHelper);
78 public: 80 public:
79 WebViewHelper(SettingOverrider* = 0); 81 WebViewHelper(SettingOverrider* = 0);
80 ~WebViewHelper(); 82 ~WebViewHelper();
81 83
82 // Creates and initializes the WebView. Implicitly calls reset() first. IF a 84 // Creates and initializes the WebView. Implicitly calls reset() first. IF a
83 // WebFrameClient or a WebViewClient are passed in, they must outlive the 85 // WebFrameClient or a WebViewClient are passed in, they must outlive the
84 // WebViewHelper. 86 // WebViewHelper.
85 WebViewImpl* initialize(bool enableJavascript = false, TestWebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0); 87 WebViewImpl* initialize(bool enableJavascript = false, TestWebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0);
86 88
87 // Same as initialize() but also performs the initial load of the url. Only 89 // Same as initialize() but also performs the initial load of the url. Only
88 // returns once the load is complete. 90 // returns once the load is complete.
89 WebViewImpl* initializeAndLoad(const std::string& url, bool enableJavascript = false, TestWebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc )(WebSettings*) = 0); 91 WebViewImpl* initializeAndLoad(const std::string& url, bool enableJavascript = false, TestWebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc )(WebSettings*) = 0);
90 92
91 void reset(); 93 void reset();
92 94
93 WebView* webView() const { return m_webView; } 95 WebView* webView() const { return m_webView; }
94 WebViewImpl* webViewImpl() const { return m_webView; } 96 WebViewImpl* webViewImpl() const { return m_webView; }
95 97
96 private: 98 private:
97 WebViewImpl* m_webView; 99 WebViewImpl* m_webView;
98 SettingOverrider* m_settingOverrider; 100 SettingOverrider* m_settingOverrider;
99 }; 101 };
100 102
101 // Minimal implementation of WebFrameClient needed for unit tests that load fram es. Tests that load 103 // Minimal implementation of WebFrameClient needed for unit tests that load fram es. Tests that load
102 // frames and need further specialization of WebFrameClient behavior should subc lass this. 104 // frames and need further specialization of WebFrameClient behavior should subc lass this.
103 class TestWebFrameClient : public WebFrameClient { 105 class TestWebFrameClient : public WebFrameClient {
106 WTF_MAKE_FAST_ALLOCATED(TestWebFrameClient);
104 public: 107 public:
105 TestWebFrameClient(); 108 TestWebFrameClient();
106 109
107 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType, const We bString& frameName, WebSandboxFlags) override; 110 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType, const We bString& frameName, WebSandboxFlags) override;
108 void frameDetached(WebFrame*, DetachType) override; 111 void frameDetached(WebFrame*, DetachType) override;
109 void didStartLoading(bool) override; 112 void didStartLoading(bool) override;
110 void didStopLoading() override; 113 void didStopLoading() override;
111 114
112 bool isLoading() { return m_loadsInProgress > 0; } 115 bool isLoading() { return m_loadsInProgress > 0; }
113 void waitForLoadToComplete(); 116 void waitForLoadToComplete();
114 117
115 private: 118 private:
116 int m_loadsInProgress; 119 int m_loadsInProgress;
117 }; 120 };
118 121
119 // Minimal implementation of WebRemoteFrameClient needed for unit tests that loa d remote frames. Tests that load 122 // Minimal implementation of WebRemoteFrameClient needed for unit tests that loa d remote frames. Tests that load
120 // frames and need further specialization of WebFrameClient behavior should subc lass this. 123 // frames and need further specialization of WebFrameClient behavior should subc lass this.
121 class TestWebRemoteFrameClient : public WebRemoteFrameClient { 124 class TestWebRemoteFrameClient : public WebRemoteFrameClient {
125 DISALLOW_ALLOCATION();
122 public: 126 public:
123 TestWebRemoteFrameClient(); 127 TestWebRemoteFrameClient();
124 128
125 WebRemoteFrame* frame() const { return m_frame; } 129 WebRemoteFrame* frame() const { return m_frame; }
126 130
127 // WebRemoteFrameClient overrides: 131 // WebRemoteFrameClient overrides:
128 void frameDetached(DetachType) override; 132 void frameDetached(DetachType) override;
129 void postMessageEvent( 133 void postMessageEvent(
130 WebLocalFrame* sourceFrame, 134 WebLocalFrame* sourceFrame,
131 WebRemoteFrame* targetFrame, 135 WebRemoteFrame* targetFrame,
132 WebSecurityOrigin targetOrigin, 136 WebSecurityOrigin targetOrigin,
133 WebDOMMessageEvent) override { } 137 WebDOMMessageEvent) override { }
134 138
135 private: 139 private:
136 WebRemoteFrame* const m_frame; 140 WebRemoteFrame* const m_frame;
137 }; 141 };
138 142
139 class TestWebViewClient : public WebViewClient { 143 class TestWebViewClient : public WebViewClient {
144 WTF_MAKE_FAST_ALLOCATED(TestWebViewClient);
140 public: 145 public:
141 virtual ~TestWebViewClient() { } 146 virtual ~TestWebViewClient() { }
142 void initializeLayerTreeView() override; 147 void initializeLayerTreeView() override;
143 WebLayerTreeView* layerTreeView() override { return m_layerTreeView.get(); } 148 WebLayerTreeView* layerTreeView() override { return m_layerTreeView.get(); }
144 149
145 private: 150 private:
146 OwnPtr<WebLayerTreeView> m_layerTreeView; 151 OwnPtr<WebLayerTreeView> m_layerTreeView;
147 }; 152 };
148 153
149 class UseMockScrollbarSettings { 154 class UseMockScrollbarSettings {
155 DISALLOW_ALLOCATION();
150 public: 156 public:
151 UseMockScrollbarSettings() 157 UseMockScrollbarSettings()
152 { 158 {
153 Settings::setMockScrollbarsEnabled(true); 159 Settings::setMockScrollbarsEnabled(true);
154 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); 160 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true);
155 EXPECT_TRUE(ScrollbarTheme::theme()->usesOverlayScrollbars()); 161 EXPECT_TRUE(ScrollbarTheme::theme()->usesOverlayScrollbars());
156 } 162 }
157 163
158 ~UseMockScrollbarSettings() 164 ~UseMockScrollbarSettings()
159 { 165 {
160 Settings::setMockScrollbarsEnabled(false); 166 Settings::setMockScrollbarsEnabled(false);
161 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); 167 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false);
162 } 168 }
163 }; 169 };
164 170
165 } // namespace FrameTestHelpers 171 } // namespace FrameTestHelpers
166 } // namespace blink 172 } // namespace blink
167 173
168 #endif // FrameTestHelpers_h 174 #endif // FrameTestHelpers_h
OLDNEW
« no previous file with comments | « Source/web/tests/FakeWebPlugin.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698