diff --git a/embeddingapi/embedding-api-android-tests/embeddingapi/src/org/xwalk/embedding/base/XWalkViewTestBase.java b/embeddingapi/embedding-api-android-tests/embeddingapi/src/org/xwalk/embedding/base/XWalkViewTestBase.java index fa4a4d0eb..ccd8e4331 100644 --- a/embeddingapi/embedding-api-android-tests/embeddingapi/src/org/xwalk/embedding/base/XWalkViewTestBase.java +++ b/embeddingapi/embedding-api-android-tests/embeddingapi/src/org/xwalk/embedding/base/XWalkViewTestBase.java @@ -1527,4 +1527,13 @@ public String call() throws Exception { } }); } + + protected void setQuirksMode(final boolean value) throws Exception { + getInstrumentation().runOnMainSync(new Runnable() { + @Override + public void run() { + mXWalkView.getSettings().setSupportQuirksMode(value); + } + }); + } } diff --git a/embeddingapi/embedding-api-android-tests/embeddingapi/src/org/xwalk/embedding/test/v6/XWalkViewTest.java b/embeddingapi/embedding-api-android-tests/embeddingapi/src/org/xwalk/embedding/test/v6/XWalkViewTest.java index eed807821..77c44addf 100644 --- a/embeddingapi/embedding-api-android-tests/embeddingapi/src/org/xwalk/embedding/test/v6/XWalkViewTest.java +++ b/embeddingapi/embedding-api-android-tests/embeddingapi/src/org/xwalk/embedding/test/v6/XWalkViewTest.java @@ -19,12 +19,10 @@ import org.apache.http.Header; import org.apache.http.HttpRequest; import org.chromium.content.browser.test.util.CallbackHelper; - import org.xwalk.embedding.base.XWalkViewTestBase; import org.xwalk.embedding.util.CommonResources; import android.annotation.SuppressLint; import android.content.Context; -import android.os.SystemClock; import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.MediumTest; import android.view.WindowManager; @@ -107,7 +105,7 @@ public void testSetInitialScale1() throws Throwable { @SmallTest public void testSetInitialScale2() throws Throwable { - + setQuirksMode(false); WindowManager wm = (WindowManager) getInstrumentation().getTargetContext() .getSystemService(Context.WINDOW_SERVICE); Point screenSize = new Point(); @@ -119,12 +117,12 @@ public void testSetInitialScale2() throws Throwable { + "

" + "testSetInitialScale

"; final float defaultScaleFactor = 0; - final float defaultScale = 0.5f; - final float scaleFactor = 0.25f; + final float defaultScale = getInstrumentation().getTargetContext( + ).getResources().getDisplayMetrics().density; assertEquals(defaultScaleFactor, getScaleFactor(), .01f); loadDataSync(null, page, "text/html", false); - assertEquals(scaleFactor, getScaleFactor(), .01f); + assertEquals(defaultScale, getPixelScale(), .01f); int onScaleChangedCallCount = mTestHelperBridge.getOnScaleChangedHelper().getCallCount(); setInitialScale(60); diff --git a/embeddingapi/embedding-asyncapi-android-tests/embeddingapi/src/org/xwalk/embedding/base/XWalkViewTestBase.java b/embeddingapi/embedding-asyncapi-android-tests/embeddingapi/src/org/xwalk/embedding/base/XWalkViewTestBase.java index a77a2f9a5..df8fe4ed4 100644 --- a/embeddingapi/embedding-asyncapi-android-tests/embeddingapi/src/org/xwalk/embedding/base/XWalkViewTestBase.java +++ b/embeddingapi/embedding-asyncapi-android-tests/embeddingapi/src/org/xwalk/embedding/base/XWalkViewTestBase.java @@ -1495,4 +1495,13 @@ public String call() throws Exception { } }); } + + protected void setQuirksMode(final boolean value) throws Exception { + getInstrumentation().runOnMainSync(new Runnable() { + @Override + public void run() { + mXWalkView.getSettings().setSupportQuirksMode(value); + } + }); + } } diff --git a/embeddingapi/embedding-asyncapi-android-tests/embeddingapi/src/org/xwalk/embedding/test/v6/XWalkViewTestAsync.java b/embeddingapi/embedding-asyncapi-android-tests/embeddingapi/src/org/xwalk/embedding/test/v6/XWalkViewTestAsync.java index 767ec2694..ce98e4518 100644 --- a/embeddingapi/embedding-asyncapi-android-tests/embeddingapi/src/org/xwalk/embedding/test/v6/XWalkViewTestAsync.java +++ b/embeddingapi/embedding-asyncapi-android-tests/embeddingapi/src/org/xwalk/embedding/test/v6/XWalkViewTestAsync.java @@ -22,6 +22,7 @@ import org.xwalk.embedding.base.XWalkViewTestBase; import org.xwalk.embedding.util.CommonResources; + import android.annotation.SuppressLint; import android.content.Context; import android.test.suitebuilder.annotation.SmallTest; @@ -106,7 +107,7 @@ public void testSetInitialScale1() throws Throwable { @SmallTest public void testSetInitialScale2() throws Throwable { - + setQuirksMode(false); WindowManager wm = (WindowManager) getInstrumentation().getTargetContext() .getSystemService(Context.WINDOW_SERVICE); Point screenSize = new Point(); @@ -117,13 +118,14 @@ public void testSetInitialScale2() throws Throwable { final String page = "" + "

" + "testSetInitialScale

"; + final float defaultScaleFactor = 0; - final float defaultScale = 0.5f; - final float scaleFactor = 0.25f; + final float defaultScale = getInstrumentation().getTargetContext( + ).getResources().getDisplayMetrics().density; assertEquals(defaultScaleFactor, getScaleFactor(), .01f); loadDataSync(null, page, "text/html", false); - assertEquals(scaleFactor, getScaleFactor(), .01f); + assertEquals(defaultScale, getPixelScale(), .01f); int onScaleChangedCallCount = mTestHelperBridge.getOnScaleChangedHelper().getCallCount(); setInitialScale(60);