Refactor security interstitials, add SecurityInterstitialPage.
[chromium-blink-merge.git] / content / test / web_layer_tree_view_impl_for_testing.cc
blobe2cd55aacc948fff663728e22b248b859928038e
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/test/web_layer_tree_view_impl_for_testing.h"
7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/synchronization/lock.h"
10 #include "cc/base/switches.h"
11 #include "cc/blink/web_layer_impl.h"
12 #include "cc/input/input_handler.h"
13 #include "cc/layers/layer.h"
14 #include "cc/scheduler/begin_frame_source.h"
15 #include "cc/test/pixel_test_output_surface.h"
16 #include "cc/test/test_context_provider.h"
17 #include "cc/trees/layer_tree_host.h"
18 #include "content/test/test_blink_web_unit_test_support.h"
19 #include "third_party/WebKit/public/platform/Platform.h"
20 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
21 #include "third_party/WebKit/public/platform/WebLayer.h"
22 #include "third_party/WebKit/public/platform/WebLayerTreeView.h"
23 #include "third_party/WebKit/public/platform/WebSize.h"
24 #include "ui/gfx/frame_time.h"
26 using blink::WebColor;
27 using blink::WebGraphicsContext3D;
28 using blink::WebRect;
29 using blink::WebSize;
31 namespace content {
33 WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting() {}
35 WebLayerTreeViewImplForTesting::~WebLayerTreeViewImplForTesting() {}
37 void WebLayerTreeViewImplForTesting::Initialize() {
38 cc::LayerTreeSettings settings;
40 // For web contents, layer transforms should scale up the contents of layers
41 // to keep content always crisp when possible.
42 settings.layer_transforms_should_scale_layer_contents = true;
44 // Accelerated animations are enabled for unit tests.
45 settings.accelerated_animation_enabled = true;
46 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded(
47 this,
48 this,
49 nullptr,
50 nullptr,
51 settings,
52 base::MessageLoopProxy::current(),
53 nullptr);
54 DCHECK(layer_tree_host_);
57 void WebLayerTreeViewImplForTesting::setSurfaceReady() {
58 layer_tree_host_->SetLayerTreeHostClientReady();
61 void WebLayerTreeViewImplForTesting::setRootLayer(
62 const blink::WebLayer& root) {
63 layer_tree_host_->SetRootLayer(
64 static_cast<const cc_blink::WebLayerImpl*>(&root)->layer());
67 void WebLayerTreeViewImplForTesting::clearRootLayer() {
68 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>());
71 void WebLayerTreeViewImplForTesting::setViewportSize(
72 const WebSize& unused_deprecated,
73 const WebSize& device_viewport_size) {
74 layer_tree_host_->SetViewportSize(device_viewport_size);
77 void WebLayerTreeViewImplForTesting::setViewportSize(
78 const WebSize& device_viewport_size) {
79 layer_tree_host_->SetViewportSize(device_viewport_size);
82 WebSize WebLayerTreeViewImplForTesting::layoutViewportSize() const {
83 return layer_tree_host_->device_viewport_size();
86 WebSize WebLayerTreeViewImplForTesting::deviceViewportSize() const {
87 return layer_tree_host_->device_viewport_size();
90 void WebLayerTreeViewImplForTesting::setDeviceScaleFactor(
91 float device_scale_factor) {
92 layer_tree_host_->SetDeviceScaleFactor(device_scale_factor);
95 float WebLayerTreeViewImplForTesting::deviceScaleFactor() const {
96 return layer_tree_host_->device_scale_factor();
99 void WebLayerTreeViewImplForTesting::setBackgroundColor(WebColor color) {
100 layer_tree_host_->set_background_color(color);
103 void WebLayerTreeViewImplForTesting::setHasTransparentBackground(
104 bool transparent) {
105 layer_tree_host_->set_has_transparent_background(transparent);
108 void WebLayerTreeViewImplForTesting::setVisible(bool visible) {
109 layer_tree_host_->SetVisible(visible);
112 void WebLayerTreeViewImplForTesting::setPageScaleFactorAndLimits(
113 float page_scale_factor,
114 float minimum,
115 float maximum) {
116 layer_tree_host_->SetPageScaleFactorAndLimits(
117 page_scale_factor, minimum, maximum);
120 void WebLayerTreeViewImplForTesting::startPageScaleAnimation(
121 const blink::WebPoint& scroll,
122 bool use_anchor,
123 float new_page_scale,
124 double duration_sec) {}
126 void WebLayerTreeViewImplForTesting::setNeedsAnimate() {
127 layer_tree_host_->SetNeedsAnimate();
130 bool WebLayerTreeViewImplForTesting::commitRequested() const {
131 return layer_tree_host_->CommitRequested();
134 void WebLayerTreeViewImplForTesting::didStopFlinging() {}
136 void WebLayerTreeViewImplForTesting::finishAllRendering() {
137 layer_tree_host_->FinishAllRendering();
140 void WebLayerTreeViewImplForTesting::setDeferCommits(bool defer_commits) {
141 layer_tree_host_->SetDeferCommits(defer_commits);
144 void WebLayerTreeViewImplForTesting::Layout() {
147 void WebLayerTreeViewImplForTesting::ApplyViewportDeltas(
148 const gfx::Vector2d& inner_delta,
149 const gfx::Vector2d& outer_delta,
150 float page_scale,
151 float top_controls_delta) {}
153 void WebLayerTreeViewImplForTesting::ApplyViewportDeltas(
154 const gfx::Vector2d& scroll_delta,
155 float page_scale,
156 float top_controls_delta) {}
158 void WebLayerTreeViewImplForTesting::RequestNewOutputSurface(
159 bool fallback) {
160 bool flipped_output_surface = false;
161 layer_tree_host_->SetOutputSurface(
162 make_scoped_ptr(new cc::PixelTestOutputSurface(
163 cc::TestContextProvider::Create(), flipped_output_surface)));
166 void WebLayerTreeViewImplForTesting::registerViewportLayers(
167 const blink::WebLayer* pageScaleLayer,
168 const blink::WebLayer* innerViewportScrollLayer,
169 const blink::WebLayer* outerViewportScrollLayer) {
170 layer_tree_host_->RegisterViewportLayers(
171 static_cast<const cc_blink::WebLayerImpl*>(pageScaleLayer)->layer(),
172 static_cast<const cc_blink::WebLayerImpl*>(innerViewportScrollLayer)
173 ->layer(),
174 // The outer viewport layer will only exist when using pinch virtual
175 // viewports.
176 outerViewportScrollLayer ? static_cast<const cc_blink::WebLayerImpl*>(
177 outerViewportScrollLayer)->layer()
178 : NULL);
181 void WebLayerTreeViewImplForTesting::clearViewportLayers() {
182 layer_tree_host_->RegisterViewportLayers(scoped_refptr<cc::Layer>(),
183 scoped_refptr<cc::Layer>(),
184 scoped_refptr<cc::Layer>());
187 void WebLayerTreeViewImplForTesting::registerSelection(
188 const blink::WebSelectionBound& start,
189 const blink::WebSelectionBound& end) {
192 void WebLayerTreeViewImplForTesting::clearSelection() {
195 } // namespace content