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

Side by Side Diff: content/renderer/input/main_thread_event_queue_unittest.cc

Issue 2581243004: Pass main thread responsiveness threshold via Finch (Closed)
Patch Set: Use EXPECT_FALSE/TRUE - avoids compile error. Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 6
7 #include <new> 7 #include <new>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/metrics/field_trial.h"
12 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
13 #include "base/test/histogram_tester.h" 14 #include "base/test/histogram_tester.h"
14 #include "base/test/scoped_feature_list.h" 15 #include "base/test/scoped_feature_list.h"
15 #include "base/test/test_simple_task_runner.h" 16 #include "base/test/test_simple_task_runner.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 #include "content/common/input/synthetic_web_input_event_builders.h" 18 #include "content/common/input/synthetic_web_input_event_builders.h"
18 #include "content/renderer/input/main_thread_event_queue.h" 19 #include "content/renderer/input/main_thread_event_queue.h"
19 #include "content/renderer/render_thread_impl.h" 20 #include "content/renderer/render_thread_impl.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/WebKit/public/platform/scheduler/test/mock_renderer_schedu ler.h" 22 #include "third_party/WebKit/public/platform/scheduler/test/mock_renderer_schedu ler.h"
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 } 705 }
705 706
706 // The boolean parameterized test varies whether rAF aligned input 707 // The boolean parameterized test varies whether rAF aligned input
707 // is enabled or not. 708 // is enabled or not.
708 INSTANTIATE_TEST_CASE_P( 709 INSTANTIATE_TEST_CASE_P(
709 MainThreadEventQueueTests, 710 MainThreadEventQueueTests,
710 MainThreadEventQueueTest, 711 MainThreadEventQueueTest,
711 testing::Range(0u, 712 testing::Range(0u,
712 (kRafAlignedEnabledTouch | kRafAlignedEnabledMouse) + 1)); 713 (kRafAlignedEnabledTouch | kRafAlignedEnabledMouse) + 1));
713 714
715 class DummyMainThreadEventQueueClient : public MainThreadEventQueueClient {
716 void HandleEventOnMainThread(int routing_id,
717 const blink::WebCoalescedInputEvent* event,
718 const ui::LatencyInfo& latency,
719 InputEventDispatchType dispatch_type) override {}
720
721 void SendInputEventAck(int routing_id,
722 blink::WebInputEvent::Type type,
723 InputEventAckState ack_result,
724 uint32_t touch_event_id) override {}
725
726 void NeedsMainFrame(int routing_id) override {}
727 };
728
729 class MainThreadEventQueueInitializationTest
730 : public testing::Test {
731 public:
732 MainThreadEventQueueInitializationTest()
733 : field_trial_list_(new base::FieldTrialList(nullptr)) {}
734
735 base::TimeDelta main_thread_responsiveness_threshold() {
736 return queue_->main_thread_responsiveness_threshold_;
737 }
738
739 bool enable_non_blocking_due_to_main_thread_responsiveness_flag() {
740 return queue_->enable_non_blocking_due_to_main_thread_responsiveness_flag_;
741 }
742
743 protected:
744 scoped_refptr<MainThreadEventQueue> queue_;
745 base::test::ScopedFeatureList feature_list_;
746 blink::scheduler::MockRendererScheduler renderer_scheduler_;
747 scoped_refptr<base::TestSimpleTaskRunner> main_task_runner_;
748 std::unique_ptr<base::FieldTrialList> field_trial_list_;
749 DummyMainThreadEventQueueClient dummy_main_thread_event_queue_client_;
750 };
751
752 TEST_F(MainThreadEventQueueInitializationTest,
753 MainThreadResponsivenessThresholdEnabled) {
754 feature_list_.InitFromCommandLine(
755 features::kMainThreadBusyScrollIntervention.name, "");
756
757 base::FieldTrialList::CreateFieldTrial(
758 "MainThreadResponsivenessScrollIntervention", "Enabled123");
759 queue_ = new MainThreadEventQueue(kTestRoutingID,
760 &dummy_main_thread_event_queue_client_,
761 main_task_runner_, &renderer_scheduler_);
762 EXPECT_TRUE(enable_non_blocking_due_to_main_thread_responsiveness_flag());
763 EXPECT_EQ(base::TimeDelta::FromMilliseconds(123),
764 main_thread_responsiveness_threshold());
765 }
766
767 TEST_F(MainThreadEventQueueInitializationTest,
768 MainThreadResponsivenessThresholdDisabled) {
769 base::FieldTrialList::CreateFieldTrial(
770 "MainThreadResponsivenessScrollIntervention", "Control");
771 queue_ = new MainThreadEventQueue(kTestRoutingID,
772 &dummy_main_thread_event_queue_client_,
773 main_task_runner_, &renderer_scheduler_);
774 EXPECT_FALSE(enable_non_blocking_due_to_main_thread_responsiveness_flag());
775 EXPECT_EQ(base::TimeDelta::FromMilliseconds(0),
776 main_thread_responsiveness_threshold());
777 }
778
714 } // namespace content 779 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698