Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

[Embeddingapi] Improve v6.XWalkViewTest.testSetInitialScale2 test case #3649

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -119,12 +117,12 @@ public void testSetInitialScale2() throws Throwable {
+ "<p style='height:" + height + "px;width:" + width + "px'>"
+ "testSetInitialScale</p></body></html>";
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -117,13 +118,14 @@ public void testSetInitialScale2() throws Throwable {
final String page = "<html><body>"
+ "<p style='height:" + height + "px;width:" + width + "px'>"
+ "testSetInitialScale</p></body></html>";

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);
Expand Down