OLD | NEW |
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 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 features.push_back(features::kRafAlignedMouseInputEvents.name); | 109 features.push_back(features::kRafAlignedMouseInputEvents.name); |
110 } else { | 110 } else { |
111 disabled_features.push_back(features::kRafAlignedMouseInputEvents.name); | 111 disabled_features.push_back(features::kRafAlignedMouseInputEvents.name); |
112 } | 112 } |
113 | 113 |
114 feature_list_.InitFromCommandLine(base::JoinString(features, ","), | 114 feature_list_.InitFromCommandLine(base::JoinString(features, ","), |
115 base::JoinString(disabled_features, ",")); | 115 base::JoinString(disabled_features, ",")); |
116 } | 116 } |
117 | 117 |
118 void SetUp() override { | 118 void SetUp() override { |
119 queue_ = | 119 queue_ = new MainThreadEventQueue(this, main_task_runner_, |
120 new MainThreadEventQueue(this, main_task_runner_, &renderer_scheduler_); | 120 &renderer_scheduler_, true); |
121 } | 121 } |
122 | 122 |
123 bool HandleEvent(WebInputEvent& event, InputEventAckState ack_result) { | 123 bool HandleEvent(WebInputEvent& event, InputEventAckState ack_result) { |
124 return queue_->HandleEvent(ui::WebInputEventTraits::Clone(event), | 124 return queue_->HandleEvent(ui::WebInputEventTraits::Clone(event), |
125 ui::LatencyInfo(), DISPATCH_TYPE_BLOCKING, | 125 ui::LatencyInfo(), DISPATCH_TYPE_BLOCKING, |
126 ack_result); | 126 ack_result); |
127 } | 127 } |
128 | 128 |
129 void RunClosure(unsigned closure_id) { | 129 void RunClosure(unsigned closure_id) { |
130 std::unique_ptr<HandledTask> closure(new HandledClosure(closure_id)); | 130 std::unique_ptr<HandledTask> closure(new HandledClosure(closure_id)); |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 std::unique_ptr<base::FieldTrialList> field_trial_list_; | 908 std::unique_ptr<base::FieldTrialList> field_trial_list_; |
909 }; | 909 }; |
910 | 910 |
911 TEST_F(MainThreadEventQueueInitializationTest, | 911 TEST_F(MainThreadEventQueueInitializationTest, |
912 MainThreadResponsivenessThresholdEnabled) { | 912 MainThreadResponsivenessThresholdEnabled) { |
913 feature_list_.InitFromCommandLine( | 913 feature_list_.InitFromCommandLine( |
914 features::kMainThreadBusyScrollIntervention.name, ""); | 914 features::kMainThreadBusyScrollIntervention.name, ""); |
915 | 915 |
916 base::FieldTrialList::CreateFieldTrial( | 916 base::FieldTrialList::CreateFieldTrial( |
917 "MainThreadResponsivenessScrollIntervention", "Enabled123"); | 917 "MainThreadResponsivenessScrollIntervention", "Enabled123"); |
918 queue_ = | 918 queue_ = new MainThreadEventQueue(this, main_task_runner_, |
919 new MainThreadEventQueue(this, main_task_runner_, &renderer_scheduler_); | 919 &renderer_scheduler_, true); |
920 EXPECT_TRUE(enable_non_blocking_due_to_main_thread_responsiveness_flag()); | 920 EXPECT_TRUE(enable_non_blocking_due_to_main_thread_responsiveness_flag()); |
921 EXPECT_EQ(base::TimeDelta::FromMilliseconds(123), | 921 EXPECT_EQ(base::TimeDelta::FromMilliseconds(123), |
922 main_thread_responsiveness_threshold()); | 922 main_thread_responsiveness_threshold()); |
923 } | 923 } |
924 | 924 |
925 TEST_F(MainThreadEventQueueInitializationTest, | 925 TEST_F(MainThreadEventQueueInitializationTest, |
926 MainThreadResponsivenessThresholdDisabled) { | 926 MainThreadResponsivenessThresholdDisabled) { |
927 base::FieldTrialList::CreateFieldTrial( | 927 base::FieldTrialList::CreateFieldTrial( |
928 "MainThreadResponsivenessScrollIntervention", "Control"); | 928 "MainThreadResponsivenessScrollIntervention", "Control"); |
929 queue_ = | 929 queue_ = new MainThreadEventQueue(this, main_task_runner_, |
930 new MainThreadEventQueue(this, main_task_runner_, &renderer_scheduler_); | 930 &renderer_scheduler_, true); |
931 EXPECT_FALSE(enable_non_blocking_due_to_main_thread_responsiveness_flag()); | 931 EXPECT_FALSE(enable_non_blocking_due_to_main_thread_responsiveness_flag()); |
932 EXPECT_EQ(base::TimeDelta::FromMilliseconds(0), | 932 EXPECT_EQ(base::TimeDelta::FromMilliseconds(0), |
933 main_thread_responsiveness_threshold()); | 933 main_thread_responsiveness_threshold()); |
934 } | 934 } |
935 | 935 |
936 TEST_P(MainThreadEventQueueTest, QueuingTwoClosures) { | 936 TEST_P(MainThreadEventQueueTest, QueuingTwoClosures) { |
937 EXPECT_FALSE(main_task_runner_->HasPendingTask()); | 937 EXPECT_FALSE(main_task_runner_->HasPendingTask()); |
938 EXPECT_EQ(0u, event_queue().size()); | 938 EXPECT_EQ(0u, event_queue().size()); |
939 | 939 |
940 QueueClosure(); | 940 QueueClosure(); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 static_cast<const WebTouchEvent&>( | 1086 static_cast<const WebTouchEvent&>( |
1087 handled_tasks_.at(0)->taskAsEvent()->Event()) | 1087 handled_tasks_.at(0)->taskAsEvent()->Event()) |
1088 .dispatch_type); | 1088 .dispatch_type); |
1089 EXPECT_EQ(WebInputEvent::kBlocking, | 1089 EXPECT_EQ(WebInputEvent::kBlocking, |
1090 static_cast<const WebTouchEvent&>( | 1090 static_cast<const WebTouchEvent&>( |
1091 handled_tasks_.at(1)->taskAsEvent()->Event()) | 1091 handled_tasks_.at(1)->taskAsEvent()->Event()) |
1092 .dispatch_type); | 1092 .dispatch_type); |
1093 } | 1093 } |
1094 | 1094 |
1095 } // namespace content | 1095 } // namespace content |
OLD | NEW |