All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openqa.selenium.devtools.v88.layertree.LayerTree Maven / Gradle / Ivy

package org.openqa.selenium.devtools.v88.layertree;

import org.openqa.selenium.Beta;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.ConverterFunctions;
import com.google.common.collect.ImmutableMap;
import org.openqa.selenium.json.JsonInput;

@Beta()
public class LayerTree {

    public static class CompositingReasonsResponse {

        private final java.util.List compositingReasons;

        private final java.util.List compositingReasonIds;

        public CompositingReasonsResponse(java.util.List compositingReasons, java.util.List compositingReasonIds) {
            this.compositingReasons = java.util.Objects.requireNonNull(compositingReasons, "compositingReasons is required");
            this.compositingReasonIds = java.util.Objects.requireNonNull(compositingReasonIds, "compositingReasonIds is required");
        }

        /**
         * A list of strings specifying reasons for the given layer to become composited.
         */
        public java.util.List getCompositingReasons() {
            return compositingReasons;
        }

        /**
         * A list of strings specifying reason IDs for the given layer to become composited.
         */
        public java.util.List getCompositingReasonIds() {
            return compositingReasonIds;
        }

        private static CompositingReasonsResponse fromJson(JsonInput input) {
            java.util.List compositingReasons = null;
            java.util.List compositingReasonIds = null;
            input.beginObject();
            while (input.hasNext()) {
                switch(input.nextName()) {
                    case "compositingReasons":
                        compositingReasons = input.read(new com.google.common.reflect.TypeToken>() {
                        }.getType());
                        break;
                    case "compositingReasonIds":
                        compositingReasonIds = input.read(new com.google.common.reflect.TypeToken>() {
                        }.getType());
                        break;
                    default:
                        input.skipValue();
                        break;
                }
            }
            input.endObject();
            return new CompositingReasonsResponse(compositingReasons, compositingReasonIds);
        }
    }

    /**
     * Provides the reasons why the given layer was composited.
     */
    public static Command compositingReasons(org.openqa.selenium.devtools.v88.layertree.model.LayerId layerId) {
        java.util.Objects.requireNonNull(layerId, "layerId is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("layerId", layerId);
        return new Command<>("LayerTree.compositingReasons", params.build(), input -> input.read(org.openqa.selenium.devtools.v88.layertree.LayerTree.CompositingReasonsResponse.class));
    }

    /**
     * Disables compositing tree inspection.
     */
    public static Command disable() {
        ImmutableMap.Builder params = ImmutableMap.builder();
        return new Command<>("LayerTree.disable", params.build());
    }

    /**
     * Enables compositing tree inspection.
     */
    public static Command enable() {
        ImmutableMap.Builder params = ImmutableMap.builder();
        return new Command<>("LayerTree.enable", params.build());
    }

    /**
     * Returns the snapshot identifier.
     */
    public static Command loadSnapshot(java.util.List tiles) {
        java.util.Objects.requireNonNull(tiles, "tiles is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("tiles", tiles);
        return new Command<>("LayerTree.loadSnapshot", params.build(), ConverterFunctions.map("snapshotId", org.openqa.selenium.devtools.v88.layertree.model.SnapshotId.class));
    }

    /**
     * Returns the layer snapshot identifier.
     */
    public static Command makeSnapshot(org.openqa.selenium.devtools.v88.layertree.model.LayerId layerId) {
        java.util.Objects.requireNonNull(layerId, "layerId is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("layerId", layerId);
        return new Command<>("LayerTree.makeSnapshot", params.build(), ConverterFunctions.map("snapshotId", org.openqa.selenium.devtools.v88.layertree.model.SnapshotId.class));
    }

    public static Command> profileSnapshot(org.openqa.selenium.devtools.v88.layertree.model.SnapshotId snapshotId, java.util.Optional minRepeatCount, java.util.Optional minDuration, java.util.Optional clipRect) {
        java.util.Objects.requireNonNull(snapshotId, "snapshotId is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("snapshotId", snapshotId);
        minRepeatCount.ifPresent(p -> params.put("minRepeatCount", p));
        minDuration.ifPresent(p -> params.put("minDuration", p));
        clipRect.ifPresent(p -> params.put("clipRect", p));
        return new Command<>("LayerTree.profileSnapshot", params.build(), ConverterFunctions.map("timings", new com.google.common.reflect.TypeToken>() {
        }.getType()));
    }

    /**
     * Releases layer snapshot captured by the back-end.
     */
    public static Command releaseSnapshot(org.openqa.selenium.devtools.v88.layertree.model.SnapshotId snapshotId) {
        java.util.Objects.requireNonNull(snapshotId, "snapshotId is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("snapshotId", snapshotId);
        return new Command<>("LayerTree.releaseSnapshot", params.build());
    }

    /**
     * Replays the layer snapshot and returns the resulting bitmap.
     */
    public static Command replaySnapshot(org.openqa.selenium.devtools.v88.layertree.model.SnapshotId snapshotId, java.util.Optional fromStep, java.util.Optional toStep, java.util.Optional scale) {
        java.util.Objects.requireNonNull(snapshotId, "snapshotId is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("snapshotId", snapshotId);
        fromStep.ifPresent(p -> params.put("fromStep", p));
        toStep.ifPresent(p -> params.put("toStep", p));
        scale.ifPresent(p -> params.put("scale", p));
        return new Command<>("LayerTree.replaySnapshot", params.build(), ConverterFunctions.map("dataURL", java.lang.String.class));
    }

    /**
     * Replays the layer snapshot and returns canvas log.
     */
    public static Command>> snapshotCommandLog(org.openqa.selenium.devtools.v88.layertree.model.SnapshotId snapshotId) {
        java.util.Objects.requireNonNull(snapshotId, "snapshotId is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("snapshotId", snapshotId);
        return new Command<>("LayerTree.snapshotCommandLog", params.build(), ConverterFunctions.map("commandLog", new com.google.common.reflect.TypeToken>>() {
        }.getType()));
    }

    public static Event layerPainted() {
        return new Event<>("LayerTree.layerPainted", input -> input.read(org.openqa.selenium.devtools.v88.layertree.model.LayerPainted.class));
    }

    public static Event> layerTreeDidChange() {
        return new Event<>("LayerTree.layerTreeDidChange", ConverterFunctions.map("layers", new com.google.common.reflect.TypeToken>() {
        }.getType()));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy