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

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

Issue 2840593002: Remove usage of ScopedTaskScheduler. (Closed)
Patch Set: rebase Created 3 years, 7 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
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"
14 #include "base/run_loop.h" 13 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
16 #include "base/test/scoped_task_scheduler.h" 15 #include "base/test/scoped_task_environment.h"
16 #include "base/threading/thread_task_runner_handle.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "cc/surfaces/compositor_frame_sink_support.h" 18 #include "cc/surfaces/compositor_frame_sink_support.h"
19 #include "cc/surfaces/surface.h" 19 #include "cc/surfaces/surface.h"
20 #include "cc/surfaces/surface_manager.h" 20 #include "cc/surfaces/surface_manager.h"
21 #include "cc/surfaces/surface_sequence.h" 21 #include "cc/surfaces/surface_sequence.h"
22 #include "cc/test/begin_frame_args_test.h" 22 #include "cc/test/begin_frame_args_test.h"
23 #include "cc/test/fake_external_begin_frame_source.h" 23 #include "cc/test/fake_external_begin_frame_source.h"
24 #include "content/browser/compositor/test/no_transport_image_transport_factory.h " 24 #include "content/browser/compositor/test/no_transport_image_transport_factory.h "
25 #include "content/browser/frame_host/cross_process_frame_connector.h" 25 #include "content/browser/frame_host/cross_process_frame_connector.h"
26 #include "content/browser/gpu/compositor_util.h" 26 #include "content/browser/gpu/compositor_util.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return nullptr; 67 return nullptr;
68 } 68 }
69 69
70 cc::SurfaceInfo last_surface_info_; 70 cc::SurfaceInfo last_surface_info_;
71 }; 71 };
72 72
73 } // namespace 73 } // namespace
74 74
75 class RenderWidgetHostViewChildFrameTest : public testing::Test { 75 class RenderWidgetHostViewChildFrameTest : public testing::Test {
76 public: 76 public:
77 RenderWidgetHostViewChildFrameTest() : task_scheduler_(&message_loop_) {} 77 RenderWidgetHostViewChildFrameTest() = default;
78 78
79 void SetUp() override { 79 void SetUp() override {
80 browser_context_.reset(new TestBrowserContext); 80 browser_context_.reset(new TestBrowserContext);
81 81
82 // ImageTransportFactory doesn't exist on Android. 82 // ImageTransportFactory doesn't exist on Android.
83 #if !defined(OS_ANDROID) 83 #if !defined(OS_ANDROID)
84 ImageTransportFactory::InitializeForUnitTests( 84 ImageTransportFactory::InitializeForUnitTests(
85 base::WrapUnique(new NoTransportImageTransportFactory)); 85 base::WrapUnique(new NoTransportImageTransportFactory));
86 #endif 86 #endif
87 87
(...skipping 20 matching lines...) Expand all
108 } 108 }
109 109
110 void TearDown() override { 110 void TearDown() override {
111 if (view_) 111 if (view_)
112 view_->Destroy(); 112 view_->Destroy();
113 delete widget_host_; 113 delete widget_host_;
114 delete test_frame_connector_; 114 delete test_frame_connector_;
115 115
116 browser_context_.reset(); 116 browser_context_.reset();
117 117
118 message_loop_.task_runner()->DeleteSoon(FROM_HERE, 118 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
119 browser_context_.release()); 119 browser_context_.release());
120 base::RunLoop().RunUntilIdle(); 120 base::RunLoop().RunUntilIdle();
121 #if !defined(OS_ANDROID) 121 #if !defined(OS_ANDROID)
122 ImageTransportFactory::Terminate(); 122 ImageTransportFactory::Terminate();
123 #endif 123 #endif
124 } 124 }
125 125
126 cc::SurfaceId GetSurfaceId() const { 126 cc::SurfaceId GetSurfaceId() const {
127 return cc::SurfaceId(view_->frame_sink_id_, view_->local_surface_id_); 127 return cc::SurfaceId(view_->frame_sink_id_, view_->local_surface_id_);
128 } 128 }
129 129
130 cc::LocalSurfaceId GetLocalSurfaceId() const { 130 cc::LocalSurfaceId GetLocalSurfaceId() const {
131 return view_->local_surface_id_; 131 return view_->local_surface_id_;
132 } 132 }
133 133
134 void ClearCompositorSurfaceIfNecessary() { 134 void ClearCompositorSurfaceIfNecessary() {
135 view_->ClearCompositorSurfaceIfNecessary(); 135 view_->ClearCompositorSurfaceIfNecessary();
136 } 136 }
137 137
138 protected: 138 protected:
139 base::MessageLoopForUI message_loop_;
gab 2017/05/01 19:05:04 ForUI?
fdoray 2017/05/03 17:38:14 Done.
140
141 // TaskScheduler is used by RenderWidgetHostImpl constructor. 139 // TaskScheduler is used by RenderWidgetHostImpl constructor.
142 base::test::ScopedTaskScheduler task_scheduler_; 140 base::test::ScopedTaskEnvironment scoped_task_environment_;
143 141
144 std::unique_ptr<BrowserContext> browser_context_; 142 std::unique_ptr<BrowserContext> browser_context_;
145 MockRenderWidgetHostDelegate delegate_; 143 MockRenderWidgetHostDelegate delegate_;
146 144
147 // Tests should set these to NULL if they've already triggered their 145 // Tests should set these to NULL if they've already triggered their
148 // destruction. 146 // destruction.
149 RenderWidgetHostImpl* widget_host_; 147 RenderWidgetHostImpl* widget_host_;
150 RenderWidgetHostViewChildFrame* view_; 148 RenderWidgetHostViewChildFrame* view_;
151 MockCrossProcessFrameConnector* test_frame_connector_; 149 MockCrossProcessFrameConnector* test_frame_connector_;
152 std::unique_ptr<FakeRendererCompositorFrameSink> 150 std::unique_ptr<FakeRendererCompositorFrameSink>
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // Explicit ack through OnBeginFrameDidNotSwap is forwarded. 282 // Explicit ack through OnBeginFrameDidNotSwap is forwarded.
285 cc::BeginFrameAck ack(source_id, 6, 4, false); 283 cc::BeginFrameAck ack(source_id, 6, 4, false);
286 view_->OnBeginFrameDidNotSwap(ack); 284 view_->OnBeginFrameDidNotSwap(ack);
287 EXPECT_EQ(ack, source.LastAckForObserver(view_->support_.get())); 285 EXPECT_EQ(ack, source.LastAckForObserver(view_->support_.get()));
288 } 286 }
289 287
290 view_->SetNeedsBeginFrames(false); 288 view_->SetNeedsBeginFrames(false);
291 } 289 }
292 290
293 } // namespace content 291 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698