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

Unified Diff: content/renderer/gpu/gpu_benchmarking_extension.cc

Issue 2348183003: Test synthetic pointer action on pointer event tests (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/gpu/gpu_benchmarking_extension.cc
diff --git a/content/renderer/gpu/gpu_benchmarking_extension.cc b/content/renderer/gpu/gpu_benchmarking_extension.cc
index e8d968e399bfe277861e8d0591df65e7c8ea121a..e1cc7f9c52cf129c73eb69f4e98a05a81bb6007a 100644
--- a/content/renderer/gpu/gpu_benchmarking_extension.cc
+++ b/content/renderer/gpu/gpu_benchmarking_extension.cc
@@ -20,6 +20,8 @@
#include "content/common/child_process_messages.h"
#include "content/common/input/synthetic_gesture_params.h"
#include "content/common/input/synthetic_pinch_gesture_params.h"
+#include "content/common/input/synthetic_pointer_action_list_params.h"
+#include "content/common/input/synthetic_pointer_action_params.h"
#include "content/common/input/synthetic_smooth_drag_gesture_params.h"
#include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
#include "content/common/input/synthetic_tap_gesture_params.h"
@@ -509,6 +511,7 @@ gin::ObjectTemplateBuilder GpuBenchmarking::GetObjectTemplateBuilder(
.SetMethod("visualViewportHeight", &GpuBenchmarking::VisualViewportHeight)
.SetMethod("visualViewportWidth", &GpuBenchmarking::VisualViewportWidth)
.SetMethod("tap", &GpuBenchmarking::Tap)
+ .SetMethod("touchActionSequence", &GpuBenchmarking::TouchActionSequence)
.SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache)
.SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark)
.SetMethod("sendMessageToMicroBenchmark",
@@ -929,6 +932,75 @@ bool GpuBenchmarking::Tap(gin::Arguments* args) {
return true;
}
+bool GpuBenchmarking::TouchActionSequence(gin::Arguments* args) {
+ GpuBenchmarkingContext context;
+ if (!context.Init(false))
+ return false;
+
+ v8::Local<v8::Function> callback;
+ // pass a two-dimensional list of actions.
+ int pointer_action_type_int;
+ int index;
+ float position_x = 0;
+ float position_y = 0;
+ int gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT;
+ SyntheticPointerActionParams::PointerActionType pointer_action_type;
+ if (!GetArg(args, &pointer_action_type_int)) {
+ return false;
+ }
+ pointer_action_type =
+ static_cast<SyntheticPointerActionParams::PointerActionType>(
+ pointer_action_type_int);
+ SyntheticPointerActionParams gesture_params(pointer_action_type);
+ if (pointer_action_type !=
+ SyntheticPointerActionParams::PointerActionType::PROCESS &&
+ pointer_action_type !=
+ SyntheticPointerActionParams::PointerActionType::FINISH) {
+ if (!GetArg(args, &index)) {
+ return false;
+ }
+ gesture_params.set_index(index);
+ if (pointer_action_type ==
+ SyntheticPointerActionParams::PointerActionType::PRESS ||
+ pointer_action_type ==
+ SyntheticPointerActionParams::PointerActionType::MOVE) {
+ if (!GetArg(args, &position_x) || !GetArg(args, &position_y)) {
+ return false;
+ }
+ gesture_params.set_position(gfx::PointF(position_x, position_y));
+ }
+ }
+
+ if (!GetOptionalArg(args, &gesture_source_type) ||
+ !GetOptionalArg(args, &callback)) {
+ return false;
+ }
+
+ if (gesture_source_type < 0 ||
+ gesture_source_type > SyntheticGestureParams::GESTURE_SOURCE_TYPE_MAX) {
+ return false;
+ }
+ gesture_params.gesture_source_type =
+ static_cast<SyntheticGestureParams::GestureSourceType>(
+ gesture_source_type);
+
+ std::unique_ptr<SyntheticPointerActionListParams> gesture_params_list(
+ new SyntheticPointerActionListParams(gesture_params));
+
+ // At the end, we will send a 'FINISH' action and need a callback.
+ scoped_refptr<CallbackAndContext> callback_and_context =
+ new CallbackAndContext(args->isolate(), callback,
+ context.web_frame()->mainWorldScriptContext());
+ // TODO(nduca): If the render_view_impl is destroyed while the gesture is in
+ // progress, we will leak the callback and context. This needs to be fixed,
+ // somehow.
+ context.render_view_impl()->GetWidget()->QueueSyntheticGesture(
+ std::move(gesture_params_list),
+ base::Bind(&OnSyntheticGestureCompleted,
+ base::RetainedRef(callback_and_context)));
+ return true;
+}
+
void GpuBenchmarking::ClearImageCache() {
WebImageCache::clear();
}

Powered by Google App Engine
This is Rietveld 408576698