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

[Embeddingapi] Fix canZoomInOnUiThread fail issue #3661

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 @@ -558,7 +558,7 @@ public boolean isSatisfied() {
return false;
}
}
});
}, WAIT_TIMEOUT_MS, CHECK_INTERVAL);
}

protected void checkHistoryItemList(XWalkView restoreXWalkView) throws Throwable {
Expand Down Expand Up @@ -1529,4 +1529,13 @@ public String call() throws Exception {
}
});
}

protected void waitForScaleToBecome(final float expectedScale) throws Throwable {
pollOnUiThread(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return expectedScale == getPixelScale();
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.xwalk.embedding.base.XWalkViewTestBase;
import android.annotation.SuppressLint;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.MediumTest;
import android.util.Pair;


Expand Down Expand Up @@ -146,16 +145,10 @@ public void testOnCanZoomInAndOut() {
try {
final float mPageMinimumScale = 0.5f;
String url = "file:///android_asset/zoom.html";
setUseWideViewPortOnUiThreadByXWalkView(true, mXWalkView);
assertFalse("Should not be able to zoom in", canZoomInOnUiThread());
loadUrlSync(url);
pollOnUiThread(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mPageMinimumScale == mTestHelperBridge.getOnScaleChangedHelper().getNewScale();
}
});

Thread.sleep(500);
waitForScaleToBecome(mPageMinimumScale);

assertTrue("Should be able to zoom in", canZoomInOnUiThread());
assertFalse("Should not be able to zoom out", canZoomOutOnUiThread());
Expand All @@ -164,7 +157,6 @@ public Boolean call() throws Exception {
assertTrue(false);
e.printStackTrace();
} catch (Throwable e) {
// TODO: handle exception
assertTrue(false);
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,10 @@ public void testOnCanZoomInAndOut() {
try {
final float mPageMinimumScale = 0.5f;
String url = "file:///android_asset/zoom.html";
setUseWideViewPortOnUiThreadByXWalkView(true, mXWalkView);
assertFalse("Should not be able to zoom in", canZoomInOnUiThread());
loadUrlSync(url);
pollOnUiThread(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mPageMinimumScale == mTestHelperBridge.getOnScaleChangedHelper().getNewScale();
}
});

Thread.sleep(500);
waitForScaleToBecome(mPageMinimumScale);

assertTrue("Should be able to zoom in", canZoomInOnUiThread());
assertFalse("Should not be able to zoom out", canZoomOutOnUiThread());
Expand All @@ -164,7 +158,6 @@ public Boolean call() throws Exception {
assertTrue(false);
e.printStackTrace();
} catch (Throwable e) {
// TODO: handle exception
assertTrue(false);
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public boolean isSatisfied() {
return false;
}
}
});
}, WAIT_TIMEOUT_MS, CHECK_INTERVAL);
}

protected void checkHistoryItemList(XWalkView restoreXWalkView) throws Throwable {
Expand Down Expand Up @@ -1497,4 +1497,13 @@ public String call() throws Exception {
}
});
}

protected void waitForScaleToBecome(final float expectedScale) throws Throwable {
pollOnUiThread(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return expectedScale == getPixelScale();
}
});
}
}