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

Commit

Permalink
[Embeddingapi] Improve v6.XWalkViewTest.testSetInitialScale2 test case
Browse files Browse the repository at this point in the history
- Fail Analyse: Need to confirm with developer for the feature support area

Impacted tests(approved): new 0, update 2, delete 0
Unit test platform: Crosswalk Project for Android 21.50.537.0
Unit test result summary: pass 0, fail 2, block 0

BUG=https://crosswalk-project.org/jira/browse/CTS-848
  • Loading branch information
zhuyongyong committed Jun 12, 2016
1 parent 8179514 commit 424ba91
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
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 @@ -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

0 comments on commit 424ba91

Please sign in to comment.