aw: Fix testGetContentHeight() CTS test

This test was broken by change android:layout_height from wrap_content
to match_parent. [1] The viewport is larger than the actually content,
so getContentHeight() returns the height of viewport when match_parent.

This CL changes the pageHeight to a very large height so it will be
bigger than the viewport's height, so getContentHeight will return
the height of web content.

[1] https://android-review.googlesource.com/c/platform/cts/+/910193

Bug: 124826954, 129287096
Test: atest android.webkit.cts.WebViewTest#testGetContentHeight
Change-Id: I98b6bf97a1fcb8df9d93f29c64fae51a84081edd
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 83569aa..ef4ed3a 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -1734,7 +1734,14 @@
         assertEquals(mOnUiThread.getHeight(),
                 mOnUiThread.getContentHeight() * mOnUiThread.getScale(), 2f);
 
-        final int pageHeight = 600;
+        // Make pageHeight bigger than the larger dimension of the device, so the page is taller
+        // than viewport. Because when layout_height set to match_parent, getContentHeight() will
+        // give maximum value between the actual web content height and the viewport height. When
+        // viewport height is bigger, |extraSpace| below is not the extra space on the web page.
+        // Note that we are passing physical pixels rather than CSS pixels here, since screen
+        // density scale is generally greater than 1, it only makes the page content taller.
+        DisplayMetrics metrics = mOnUiThread.getDisplayMetrics();
+        final int pageHeight = Math.max(metrics.widthPixels, metrics.heightPixels);
         // set the margin to 0
         final String p = "<p style=\"height:" + pageHeight
                 + "px;margin:0px auto;\">Get the height of HTML content.</p>";