Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test that mimics the most basic "Activity loading its resources via setContent". #9003

Open
wants to merge 1 commit into
base: google
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -25,6 +25,7 @@
import org.robolectric.annotation.Implements;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowWindowManagerGlobal.WindowManagerGlobalReflector;
import org.robolectric.util.PerfStatsCollector;
import org.robolectric.util.reflector.Accessor;
import org.robolectric.util.reflector.Constructor;
import org.robolectric.util.reflector.ForType;
Expand Down Expand Up @@ -168,10 +169,18 @@ private static void takeScreenshot(View view, Bitmap screenshot, @Nullable Rect
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);

if (HardwareRenderingScreenshot.canTakeScreenshot()) {
HardwareRenderingScreenshot.takeScreenshot(view, bitmap);
PerfStatsCollector.getInstance()
.measure(
"ShadowPixelCopy-Hardware",
() -> HardwareRenderingScreenshot.takeScreenshot(view, bitmap));
} else {
Canvas screenshotCanvas = new Canvas(bitmap);
view.draw(screenshotCanvas);
PerfStatsCollector.getInstance()
.measure(
"ShadowPixelCopy-Software",
() -> {
Canvas screenshotCanvas = new Canvas(bitmap);
view.draw(screenshotCanvas);
});
}

Rect dst = new Rect(0, 0, screenshot.getWidth(), screenshot.getHeight());
Expand Down