forked from AppGyver/crosswalk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request crosswalk-project#3935 from chuan9/xwalk-7325-a
Add XWalkViewAsynchronousApisTest referring to upstream's implementation.
- Loading branch information
Showing
8 changed files
with
306 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 0 additions & 59 deletions
59
test/android/core/javatests/src/org/xwalk/core/xwview/test/FindAsyncTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
...roid/core/javatests/src/org/xwalk/core/xwview/test/XWalkViewAsynchronousFindApisTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
// Copyright 2012 The Chromium Authors. All rights reserved. | ||
// Copyright (c) 2016 Intel Corporation. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package org.xwalk.core.xwview.test; | ||
|
||
import android.test.suitebuilder.annotation.SmallTest; | ||
|
||
import org.chromium.base.test.util.Feature; | ||
/** | ||
* Test suite for asynchronous find APIs | ||
*/ | ||
public class XWalkViewAsynchronousFindApisTest extends XWalkViewFindApisTestBase { | ||
final String WOODCHUCK = | ||
"How much WOOD would a woodchuck chuck if a woodchuck could chuck wOoD?"; | ||
|
||
final String data = "<html><head></head><body>" + WOODCHUCK + "</body></html>"; | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testFindAllFinds() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testFindAllDouble() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
findAllAsyncOnUiThread("wood"); | ||
assertEquals(4, findAllAsyncOnUiThread("chuck")); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testFindAllDoubleNext() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
assertEquals(2, findNextOnUiThread(true)); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testFindAllDoesNotFind() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
assertEquals(0, findAllAsyncOnUiThread("foo")); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testFindAllEmptyPage() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
assertEquals(0, findAllAsyncOnUiThread("foo")); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testFindAllEmptyString() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
assertEquals(0, findAllAsyncOnUiThread("")); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testFindNextForward() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
|
||
for (int i = 2; i <= 4; i++) { | ||
assertEquals(i - 1, findNextOnUiThread(true)); | ||
} | ||
assertEquals(0, findNextOnUiThread(true)); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testFindNextBackward() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
|
||
for (int i = 4; i >= 1; i--) { | ||
assertEquals(i - 1, findNextOnUiThread(false)); | ||
} | ||
assertEquals(3, findNextOnUiThread(false)); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testFindNextBig() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
|
||
assertEquals(1, findNextOnUiThread(true)); | ||
assertEquals(0, findNextOnUiThread(false)); | ||
assertEquals(3, findNextOnUiThread(false)); | ||
for (int i = 1; i <= 4; i++) { | ||
assertEquals(i - 1, findNextOnUiThread(true)); | ||
} | ||
assertEquals(0, findNextOnUiThread(true)); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testFindAllEmptyNext() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
assertEquals(1, findNextOnUiThread(true)); | ||
assertEquals(0, findAllAsyncOnUiThread("")); | ||
assertEquals(0, findNextOnUiThread(true)); | ||
assertEquals(0, findAllAsyncOnUiThread("")); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
assertEquals(1, findNextOnUiThread(true)); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testClearMatches() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
clearMatchesOnUiThread(); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testClearFindNext() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
clearMatchesOnUiThread(); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
assertEquals(1, findNextOnUiThread(true)); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testFindEmptyNext() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
assertEquals(0, findAllAsyncOnUiThread("")); | ||
assertEquals(0, findNextOnUiThread(true)); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
} | ||
|
||
@SmallTest | ||
@Feature({"XWalkView", "FindInPage"}) | ||
public void testFindNextFirst() throws Throwable { | ||
loadDataSync(null, data, "text/html", false); | ||
runTestOnUiThread(new Runnable() { | ||
@Override | ||
public void run() { | ||
getXWalkView().findNext(true); | ||
} | ||
}); | ||
assertEquals(4, findAllAsyncOnUiThread("wood")); | ||
assertEquals(1, findNextOnUiThread(true)); | ||
assertEquals(0, findNextOnUiThread(false)); | ||
assertEquals(3, findNextOnUiThread(false)); | ||
} | ||
} |
Oops, something went wrong.