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

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

Issue 2750623002: Avoid unnecessary LocalSurfaceId allocation in RenderWidgetHostViewChildFrame/Guest (Closed)
Patch Set: Added test Created 3 years, 9 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 // 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
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 base::RunLoop().RunUntilIdle(); 100 base::RunLoop().RunUntilIdle();
101 #if !defined(OS_ANDROID) 101 #if !defined(OS_ANDROID)
102 ImageTransportFactory::Terminate(); 102 ImageTransportFactory::Terminate();
103 #endif 103 #endif
104 } 104 }
105 105
106 cc::SurfaceId GetSurfaceId() const { 106 cc::SurfaceId GetSurfaceId() const {
107 return cc::SurfaceId(view_->frame_sink_id_, view_->local_surface_id_); 107 return cc::SurfaceId(view_->frame_sink_id_, view_->local_surface_id_);
108 } 108 }
109 109
110 void ClearCompositorSurfaceIfNecessary() {
111 view_->ClearCompositorSurfaceIfNecessary();
112 }
113
110 protected: 114 protected:
111 base::MessageLoopForUI message_loop_; 115 base::MessageLoopForUI message_loop_;
112 std::unique_ptr<BrowserContext> browser_context_; 116 std::unique_ptr<BrowserContext> browser_context_;
113 MockRenderWidgetHostDelegate delegate_; 117 MockRenderWidgetHostDelegate delegate_;
114 118
115 // Tests should set these to NULL if they've already triggered their 119 // Tests should set these to NULL if they've already triggered their
116 // destruction. 120 // destruction.
117 RenderWidgetHostImpl* widget_host_; 121 RenderWidgetHostImpl* widget_host_;
118 RenderWidgetHostViewChildFrame* view_; 122 RenderWidgetHostViewChildFrame* view_;
119 MockCrossProcessFrameConnector* test_frame_connector_; 123 MockCrossProcessFrameConnector* test_frame_connector_;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 EXPECT_EQ(1u, surface->GetDestructionDependencyCount()); 180 EXPECT_EQ(1u, surface->GetDestructionDependencyCount());
177 #endif 181 #endif
178 182
179 // Surface ID should have been passed to CrossProcessFrameConnector to 183 // Surface ID should have been passed to CrossProcessFrameConnector to
180 // be sent to the embedding renderer. 184 // be sent to the embedding renderer.
181 EXPECT_EQ(cc::SurfaceInfo(id, scale_factor, view_size), 185 EXPECT_EQ(cc::SurfaceInfo(id, scale_factor, view_size),
182 test_frame_connector_->last_surface_info_); 186 test_frame_connector_->last_surface_info_);
183 } 187 }
184 } 188 }
185 189
190 // Check that frame eviction does not trigger allocation of a new local surface
191 // id.
192 TEST_F(RenderWidgetHostViewChildFrameTest, FrameEvictionKeepsLocalSurfaceId) {
193 gfx::Size view_size(100, 100);
194 gfx::Rect view_rect(view_size);
195 float scale_factor = 1.f;
196
197 view_->SetSize(view_size);
198 view_->Show();
199
200 // Submit a frame. Remember the local surface id and check that has_frame()
201 // returns true.
202 view_->OnSwapCompositorFrame(
203 0, CreateDelegatedFrame(scale_factor, view_size, view_rect));
204
205 cc::SurfaceId surface_id = GetSurfaceId();
206 EXPECT_TRUE(surface_id.is_valid());
207 EXPECT_TRUE(view_->has_frame());
208
209 // Evict the frame. The surface id must remain the same but has_frame() should
210 // return false.
211 ClearCompositorSurfaceIfNecessary();
212 EXPECT_EQ(surface_id, GetSurfaceId());
213 EXPECT_FALSE(view_->has_frame());
214
215 // Submit another frame. Since it has the same size and scale as the first
216 // one, the same surface id must be used. has_frame() must return true.
217 view_->OnSwapCompositorFrame(
218 0, CreateDelegatedFrame(scale_factor, view_size, view_rect));
219 EXPECT_EQ(surface_id, GetSurfaceId());
220 EXPECT_TRUE(view_->has_frame());
221 }
222
186 } // namespace content 223 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698