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

Side by Side Diff: content/browser/frame_host/render_widget_host_view_child_frame_unittest.cc

Issue 2779593002: [cc] Forward BeginFrameAcks through RWHVChildFrame. (Closed)
Patch Set: fix compile on android Created 3 years, 8 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 | « content/browser/frame_host/render_widget_host_view_child_frame.cc ('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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" 5 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "cc/surfaces/compositor_frame_sink_support.h"
17 #include "cc/surfaces/surface.h" 18 #include "cc/surfaces/surface.h"
18 #include "cc/surfaces/surface_factory.h" 19 #include "cc/surfaces/surface_factory.h"
19 #include "cc/surfaces/surface_manager.h" 20 #include "cc/surfaces/surface_manager.h"
20 #include "cc/surfaces/surface_sequence.h" 21 #include "cc/surfaces/surface_sequence.h"
22 #include "cc/test/begin_frame_args_test.h"
23 #include "cc/test/fake_external_begin_frame_source.h"
21 #include "content/browser/compositor/test/no_transport_image_transport_factory.h " 24 #include "content/browser/compositor/test/no_transport_image_transport_factory.h "
22 #include "content/browser/frame_host/cross_process_frame_connector.h" 25 #include "content/browser/frame_host/cross_process_frame_connector.h"
23 #include "content/browser/gpu/compositor_util.h" 26 #include "content/browser/gpu/compositor_util.h"
24 #include "content/browser/renderer_host/render_widget_host_delegate.h" 27 #include "content/browser/renderer_host/render_widget_host_delegate.h"
25 #include "content/browser/renderer_host/render_widget_host_impl.h" 28 #include "content/browser/renderer_host/render_widget_host_impl.h"
26 #include "content/common/view_messages.h" 29 #include "content/common/view_messages.h"
27 #include "content/public/browser/render_widget_host_view.h" 30 #include "content/public/browser/render_widget_host_view.h"
28 #include "content/public/test/mock_render_process_host.h" 31 #include "content/public/test/mock_render_process_host.h"
29 #include "content/public/test/test_browser_context.h" 32 #include "content/public/test/test_browser_context.h"
30 #include "content/test/test_render_view_host.h" 33 #include "content/test/test_render_view_host.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 229
227 // Submit another frame with the same local surface id. The same id should be 230 // Submit another frame with the same local surface id. The same id should be
228 // usable. 231 // usable.
229 view_->OnSwapCompositorFrame( 232 view_->OnSwapCompositorFrame(
230 0, kArbitraryLocalSurfaceId, 233 0, kArbitraryLocalSurfaceId,
231 CreateDelegatedFrame(scale_factor, view_size, view_rect)); 234 CreateDelegatedFrame(scale_factor, view_size, view_rect));
232 EXPECT_EQ(kArbitraryLocalSurfaceId, GetLocalSurfaceId()); 235 EXPECT_EQ(kArbitraryLocalSurfaceId, GetLocalSurfaceId());
233 EXPECT_TRUE(view_->has_frame()); 236 EXPECT_TRUE(view_->has_frame());
234 } 237 }
235 238
239 // Tests that BeginFrameAcks are forwarded correctly from the
240 // SwapCompositorFrame and OnBeginFrameDidNotSwap IPCs through the
241 // CompositorFrameSinkSupport.
242 TEST_F(RenderWidgetHostViewChildFrameTest, ForwardsBeginFrameAcks) {
243 gfx::Size view_size(100, 100);
244 gfx::Rect view_rect(view_size);
245 float scale_factor = 1.f;
246
247 view_->SetSize(view_size);
248 view_->Show();
249
250 // Replace BeginFrameSource so that we can observe acknowledgments.
251 cc::FakeExternalBeginFrameSource source(0.f, false);
252 uint32_t source_id = source.source_id();
253 static_cast<cc::SurfaceFactoryClient*>(view_->support_.get())
254 ->SetBeginFrameSource(&source);
255 view_->SetNeedsBeginFrames(true);
256
257 {
258 cc::BeginFrameArgs args =
259 cc::CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, source_id, 5u);
260 source.TestOnBeginFrame(args);
261
262 // Ack from CompositorFrame is forwarded.
263 cc::BeginFrameAck ack(source_id, 5, 4, true);
264 cc::CompositorFrame frame =
265 CreateDelegatedFrame(scale_factor, view_size, view_rect);
266 frame.metadata.begin_frame_ack = ack;
267 view_->OnSwapCompositorFrame(0, kArbitraryLocalSurfaceId, std::move(frame));
268 EXPECT_EQ(ack, source.LastAckForObserver(view_->support_.get()));
269 }
270
271 {
272 cc::BeginFrameArgs args =
273 cc::CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, source_id, 6u);
274 source.TestOnBeginFrame(args);
275
276 // Explicit ack through OnBeginFrameDidNotSwap is forwarded.
277 cc::BeginFrameAck ack(source_id, 6, 4, false);
278 view_->OnBeginFrameDidNotSwap(ack);
279 EXPECT_EQ(ack, source.LastAckForObserver(view_->support_.get()));
280 }
281
282 view_->SetNeedsBeginFrames(false);
283 }
284
236 } // namespace content 285 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_widget_host_view_child_frame.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698