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

Commit

Permalink
[Embeddingapi] Fix canZoomInOnUiThread fail issue
Browse files Browse the repository at this point in the history
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 2, fail 0, block 0

BUG=https://crosswalk-project.org/jira/browse/CTS-1769
  • Loading branch information
zhuyongyong committed Jun 17, 2016
1 parent e3aea44 commit de73076
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
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 @@ -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();
}
});
}
}
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

0 comments on commit de73076

Please sign in to comment.