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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/MockLayoutHost.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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: chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/MockLayoutHost.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/MockLayoutHost.java b/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/MockLayoutHost.java
new file mode 100644
index 0000000000000000000000000000000000000000..cc50f6c14d89fc6e05d0101ab616a31d43fc4d66
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/MockLayoutHost.java
@@ -0,0 +1,151 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.compositor.layouts;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Rect;
+
+import org.chromium.chrome.browser.compositor.TitleCache;
+import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
+import org.chromium.content.browser.ContentViewCore;
+import org.chromium.ui.resources.ResourceManager;
+
+/**
+ * The {@link LayoutManagerHost} usually is based on a {@link android.view.View}. This
+ * implementation is stripped down with static sizes but still support 2 different orientations.
+ */
+class MockLayoutHost implements LayoutManagerHost, LayoutRenderHost {
+
+ public static final int LAYOUT_HOST_PORTRAIT_WIDTH = 320; // dp
+ public static final int LAYOUT_HOST_PORTRAIT_HEIGHT = 460; // dp
+
+ private final Context mContext;
+ private boolean mPortrait = true;
+
+ static class MockTitleCache implements TitleCache {
+ @Override
+ public void put(int tabId, Bitmap titleBitmap, Bitmap faviconBitmap, boolean isIncognito,
+ boolean isRtl) { }
+
+ @Override
+ public void remove(int tabId) { }
+
+ @Override
+ public void clearExcept(int tabId) { }
+ }
+
+ private final MockTitleCache mMockTitleCache = new MockTitleCache();
+
+ MockLayoutHost(Context context) {
+ mContext = context;
+ }
+
+ public void setOrientation(boolean portrait) {
+ mPortrait = portrait;
+ }
+
+ @Override
+ public void requestRender() { }
+
+ @Override
+ public void onCompositorLayout() { }
+
+ @Override
+ public void onSwapBuffersCompleted(int pendingSwapBuffersCount) { }
+
+ @Override
+ public void onSurfaceCreated() { }
+
+ @Override
+ public void onPhysicalBackingSizeChanged(int width, int height) { }
+
+ @Override
+ public void onOverdrawBottomHeightChanged(int overdrawHeight) {}
+
+ @Override
+ public int getCurrentOverdrawBottomHeight() {
+ return 0;
+ }
+
+ @Override
+ public Context getContext() {
+ return mContext;
+ }
+
+ @Override
+ public int getWidth() {
+ final float density = mContext.getResources().getDisplayMetrics().density;
+ final float size = mPortrait ? LAYOUT_HOST_PORTRAIT_WIDTH : LAYOUT_HOST_PORTRAIT_HEIGHT;
+ return (int) (density * size);
+ }
+
+ @Override
+ public int getHeight() {
+ final float density = mContext.getResources().getDisplayMetrics().density;
+ final float size = mPortrait ? LAYOUT_HOST_PORTRAIT_HEIGHT : LAYOUT_HOST_PORTRAIT_WIDTH;
+ return (int) (density * size);
+ }
+
+ @Override
+ public LayoutRenderHost getLayoutRenderHost() {
+ return this;
+ }
+
+ @Override
+ public void pushDebugRect(Rect rect, int color) { }
+
+ @Override
+ public void loadPersitentTextureDataIfNeeded() { }
+
+ @Override
+ public int getLayoutTabsDrawnCount() {
+ return 0;
+ }
+
+ @Override
+ public void setContentOverlayVisibility(boolean visible) { }
+
+ @Override
+ public TitleCache getTitleCache() {
+ return mMockTitleCache;
+ }
+
+ @Override
+ public ChromeFullscreenManager getFullscreenManager() {
+ return null;
+ }
+
+ @Override
+ public Rect getVisibleViewport(Rect rect) {
+ if (rect == null) rect = new Rect();
+ rect.set(0, 0, getWidth(), getHeight());
+ return rect;
+ }
+
+ @Override
+ public int getTopControlsHeightPixels() {
+ return 0;
+ }
+
+ @Override
+ public boolean areTopControlsPermanentlyHidden() {
+ return false;
+ }
+
+ @Override
+ public ResourceManager getResourceManager() {
+ return null;
+ }
+
+ @Override
+ public void invalidateAccessibilityProvider() { }
+
+ @Override
+ public void onContentViewCoreAdded(ContentViewCore content) { }
+
+ @Override
+ public void onContentChanged() { }
+}

Powered by Google App Engine
This is Rietveld 408576698