Commit adc4e84b authored by chaopeng's avatar chaopeng Committed by Commit Bot

Call rAFs before checking the pinch zoom result

This test failing because it need some rAFs for commit.

Bug: 875097
Change-Id: I10aacf4a55ea8fe277fef1fc68b4d6c9ee287190
Reviewed-on: https://chromium-review.googlesource.com/1213545Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Jianpeng Chao <chaopeng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589562}
parent d7939507
...@@ -11,31 +11,33 @@ function runTest(t, testCase) { ...@@ -11,31 +11,33 @@ function runTest(t, testCase) {
return new Promise(t.step_func((resolve, reject) => { return new Promise(t.step_func((resolve, reject) => {
internals.setPageScaleFactor(testCase.startingScale); internals.setPageScaleFactor(testCase.startingScale);
internals.setVisualViewportOffset( internals.setVisualViewportOffset(
window.innerWidth * (1 - (1 / testCase.startingScale)) / 2, window.innerWidth * (1 - (1 / testCase.startingScale)) / 2,
window.innerHeight * (1 - (1 / testCase.startingScale)) / 2); window.innerHeight * (1 - (1 / testCase.startingScale)) / 2);
// Ensure the compositor knows the starting scale and offset. // Ensure the compositor knows the starting scale and offset.
waitForCompositorCommit().then(t.step_func(() => { waitForCompositorCommit().then(t.step_func(() => {
chrome.gpuBenchmarking.pinchBy( chrome.gpuBenchmarking.pinchBy(
testCase.scale, centerX, centerY, t.step_func(() => { testCase.scale, centerX, centerY, t.step_func(() => {
const expectedScale = testCase.startingScale * testCase.scale; waitForCompositorCommit().then(t.step_func(() => {
assert_approx_equals( const expectedScale = testCase.startingScale * testCase.scale;
window.visualViewport.scale, assert_approx_equals(
expectedScale, window.visualViewport.scale,
kScaleEpsilon, expectedScale,
testCase.msg + " has correct page scale factor."); kScaleEpsilon,
assert_approx_equals( testCase.msg + " has correct page scale factor.");
window.visualViewport.offsetLeft, assert_approx_equals(
window.innerWidth * (1 - (1 / expectedScale)) / 2, window.visualViewport.offsetLeft,
kOffsetEpsilon, window.innerWidth * (1 - (1 / expectedScale)) / 2,
testCase.msg + " has correct visual viewport offsetLeft."); kOffsetEpsilon,
assert_approx_equals( testCase.msg + " has correct visual viewport offsetLeft.");
window.visualViewport.offsetTop, assert_approx_equals(
window.innerHeight * (1 - (1 / expectedScale)) / 2, window.visualViewport.offsetTop,
kOffsetEpsilon, window.innerHeight * (1 - (1 / expectedScale)) / 2,
testCase.msg + " has correct visual viewport offsetTop."); kOffsetEpsilon,
resolve(); testCase.msg + " has correct visual viewport offsetTop.");
}), testCase.speed, testCase.gestureSource); resolve();
}))
}), testCase.speed, testCase.gestureSource);
})); }));
})); }));
} }
...@@ -56,21 +58,21 @@ function runTestDesktop(t, testCase) { ...@@ -56,21 +58,21 @@ function runTestDesktop(t, testCase) {
return new Promise(t.step_func((resolve, reject) => { return new Promise(t.step_func((resolve, reject) => {
internals.setPageScaleFactor(testCase.startingScale); internals.setPageScaleFactor(testCase.startingScale);
internals.setVisualViewportOffset( internals.setVisualViewportOffset(
window.innerWidth * (1 - (1 / testCase.startingScale)) / 2, window.innerWidth * (1 - (1 / testCase.startingScale)) / 2,
window.innerHeight * (1 - (1 / testCase.startingScale)) / 2); window.innerHeight * (1 - (1 / testCase.startingScale)) / 2);
// Ensure the compositor knows the starting scale and offset. // Ensure the compositor knows the starting scale and offset.
waitForCompositorCommit().then(t.step_func(() => { waitForCompositorCommit().then(t.step_func(() => {
chrome.gpuBenchmarking.pinchBy( chrome.gpuBenchmarking.pinchBy(
testCase.scale, centerX, centerY, t.step_func(() => { testCase.scale, centerX, centerY, t.step_func(() => {
const expectedScale = testCase.startingScale * testCase.scale; const expectedScale = testCase.startingScale * testCase.scale;
assert_approx_equals( assert_approx_equals(
window.visualViewport.scale, window.visualViewport.scale,
expectedScale, expectedScale,
kScaleEpsilon, kScaleEpsilon,
testCase.msg + " has correct page scale factor."); testCase.msg + " has correct page scale factor.");
resolve(); resolve();
}), testCase.speed, testCase.gestureSource); }), testCase.speed, testCase.gestureSource);
})); }));
})); }));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment