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

Side by Side Diff: content/browser/renderer_host/input/input_router_impl_perftest.cc

Issue 2846933002: Use ScopedTaskEnvironment instead of MessageLoopForUI in content tests. (Closed)
Patch Set: self-review 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/test/scoped_task_environment.h"
12 #include "content/browser/renderer_host/input/input_ack_handler.h" 13 #include "content/browser/renderer_host/input/input_ack_handler.h"
13 #include "content/browser/renderer_host/input/input_router_client.h" 14 #include "content/browser/renderer_host/input/input_router_client.h"
14 #include "content/browser/renderer_host/input/input_router_impl.h" 15 #include "content/browser/renderer_host/input/input_router_impl.h"
15 #include "content/common/input_messages.h" 16 #include "content/common/input_messages.h"
16 #include "content/common/view_messages.h" 17 #include "content/common/view_messages.h"
17 #include "content/public/common/content_features.h" 18 #include "content/public/common/content_features.h"
18 #include "ipc/ipc_sender.h" 19 #include "ipc/ipc_sender.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include "testing/perf/perf_test.h" 21 #include "testing/perf/perf_test.h"
21 #include "ui/events/base_event_utils.h" 22 #include "ui/events/base_event_utils.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 bool ShouldBlockEventStream(const blink::WebInputEvent& event) { 211 bool ShouldBlockEventStream(const blink::WebInputEvent& event) {
211 return ui::WebInputEventTraits::ShouldBlockEventStream( 212 return ui::WebInputEventTraits::ShouldBlockEventStream(
212 event, 213 event,
213 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)); 214 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents));
214 } 215 }
215 216
216 } // namespace 217 } // namespace
217 218
218 class InputRouterImplPerfTest : public testing::Test { 219 class InputRouterImplPerfTest : public testing::Test {
219 public: 220 public:
220 InputRouterImplPerfTest() : last_input_id_(0) {} 221 InputRouterImplPerfTest()
222 : scoped_task_environment_(
223 base::test::ScopedTaskEnvironment::MainThreadType::UI),
224 last_input_id_(0) {}
221 ~InputRouterImplPerfTest() override {} 225 ~InputRouterImplPerfTest() override {}
222 226
223 protected: 227 protected:
224 // testing::Test 228 // testing::Test
225 void SetUp() override { 229 void SetUp() override {
226 sender_.reset(new NullIPCSender()); 230 sender_.reset(new NullIPCSender());
227 client_.reset(new NullInputRouterClient()); 231 client_.reset(new NullInputRouterClient());
228 ack_handler_.reset(new NullInputAckHandler()); 232 ack_handler_.reset(new NullInputAckHandler());
229 input_router_.reset(new InputRouterImpl(sender_.get(), 233 input_router_.reset(new InputRouterImpl(sender_.get(),
230 client_.get(), 234 client_.get(),
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 345 }
342 346
343 SendEvent(gestures[i], CreateLatencyInfo()); 347 SendEvent(gestures[i], CreateLatencyInfo());
344 SendEventAckIfNecessary(gestures[i], INPUT_EVENT_ACK_STATE_CONSUMED); 348 SendEventAckIfNecessary(gestures[i], INPUT_EVENT_ACK_STATE_CONSUMED);
345 EXPECT_EQ(2U, GetAndResetAckCount()); 349 EXPECT_EQ(2U, GetAndResetAckCount());
346 } 350 }
347 } 351 }
348 } 352 }
349 353
350 private: 354 private:
355 base::test::ScopedTaskEnvironment scoped_task_environment_;
351 int64_t last_input_id_; 356 int64_t last_input_id_;
352 std::unique_ptr<NullIPCSender> sender_; 357 std::unique_ptr<NullIPCSender> sender_;
353 std::unique_ptr<NullInputRouterClient> client_; 358 std::unique_ptr<NullInputRouterClient> client_;
354 std::unique_ptr<NullInputAckHandler> ack_handler_; 359 std::unique_ptr<NullInputAckHandler> ack_handler_;
355 std::unique_ptr<InputRouterImpl> input_router_; 360 std::unique_ptr<InputRouterImpl> input_router_;
356 base::MessageLoopForUI message_loop_;
357 }; 361 };
358 362
359 const size_t kDefaultSteps(100); 363 const size_t kDefaultSteps(100);
360 const size_t kDefaultIterations(100); 364 const size_t kDefaultIterations(100);
361 const gfx::Vector2dF kDefaultOrigin(100, 100); 365 const gfx::Vector2dF kDefaultOrigin(100, 100);
362 const gfx::Vector2dF kDefaultDistance(500, 500); 366 const gfx::Vector2dF kDefaultDistance(500, 500);
363 367
364 TEST_F(InputRouterImplPerfTest, TouchSwipe) { 368 TEST_F(InputRouterImplPerfTest, TouchSwipe) {
365 SimulateEventSequence( 369 SimulateEventSequence(
366 "TouchSwipe ", 370 "TouchSwipe ",
(...skipping 28 matching lines...) Expand all
395 399
396 TEST_F(InputRouterImplPerfTest, TouchSwipeToGestureScroll) { 400 TEST_F(InputRouterImplPerfTest, TouchSwipeToGestureScroll) {
397 SimulateTouchAndScrollEventSequence("TouchSwipeToGestureScroll ", 401 SimulateTouchAndScrollEventSequence("TouchSwipeToGestureScroll ",
398 kDefaultSteps, 402 kDefaultSteps,
399 kDefaultOrigin, 403 kDefaultOrigin,
400 kDefaultDistance, 404 kDefaultDistance,
401 kDefaultIterations); 405 kDefaultIterations);
402 } 406 }
403 407
404 } // namespace content 408 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698