Fix layout for WebViewTest#testRequestChildRectangleOnScreen

Changed the layout from "wrap_content" to "match_parent"
according to the WebView's restriction below;
http://developer.android.com/reference/android/webkit/WebView.html
(Section:"Layout size")

By applying this fix, the fail of
"android.webkit.cts.WebViewTest#testRequestChildRectangleOnScreen"
test case on some products is resolved.

Change-Id: I23796454c0d0d92a478b1948bd01a804b5858164
diff --git a/libs/deviceutillegacy/src/android/webkit/cts/WebViewOnUiThread.java b/libs/deviceutillegacy/src/android/webkit/cts/WebViewOnUiThread.java
index b9d3af1..bcb8cb2 100644
--- a/libs/deviceutillegacy/src/android/webkit/cts/WebViewOnUiThread.java
+++ b/libs/deviceutillegacy/src/android/webkit/cts/WebViewOnUiThread.java
@@ -776,6 +776,17 @@
         });
     }
 
+    public void setLayoutToMatchParent() {
+        runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                setMatchParent((View) mWebView.getParent());
+                setMatchParent(mWebView);
+                mWebView.requestLayout();
+            }
+        });
+    }
+
     public void setAcceptThirdPartyCookies(final boolean accept) {
         runOnUiThread(new Runnable() {
             @Override
@@ -947,6 +958,18 @@
     }
 
     /**
+     * Set LayoutParams to MATCH_PARENT.
+     *
+     * @param view Target view
+     */
+    private void setMatchParent(View view) {
+        ViewGroup.LayoutParams params = view.getLayoutParams();
+        params.height = ViewGroup.LayoutParams.MATCH_PARENT;
+        params.width = ViewGroup.LayoutParams.MATCH_PARENT;
+        view.setLayoutParams(params);
+    }
+
+    /**
      * A WebChromeClient used to capture the onProgressChanged for use
      * in waitFor functions. If a test must override the WebChromeClient,
      * it can derive from this class or call onProgressChanged
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 6572285..561df3a 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -2122,6 +2122,10 @@
         if (!NullWebViewUtils.isWebViewAvailable()) {
             return;
         }
+
+        // It is needed to make test pass on some devices.
+        mOnUiThread.setLayoutToMatchParent();
+
         DisplayMetrics metrics = mOnUiThread.getDisplayMetrics();
         final int dimension = 2 * Math.max(metrics.widthPixels, metrics.heightPixels);
         String p = "<p style=\"height:" + dimension + "px;width:" + dimension + "px\">&nbsp;</p>";