summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/BrowserTestPlugin/jni/PluginObject.h2
-rw-r--r--tests/BrowserTestPlugin/jni/event/EventPlugin.cpp2
-rw-r--r--tests/BrowserTestPlugin/jni/event/EventPlugin.h2
-rw-r--r--tests/BrowserTestPlugin/jni/main.cpp20
-rwxr-xr-xtests/DumpRenderTree/assets/run_layout_tests.py2
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java25
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java11
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java34
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java15
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java130
10 files changed, 138 insertions, 105 deletions
diff --git a/tests/BrowserTestPlugin/jni/PluginObject.h b/tests/BrowserTestPlugin/jni/PluginObject.h
index a058d4a..037367e 100644
--- a/tests/BrowserTestPlugin/jni/PluginObject.h
+++ b/tests/BrowserTestPlugin/jni/PluginObject.h
@@ -65,7 +65,7 @@ class SubPlugin {
public:
SubPlugin(NPP inst) : m_inst(inst) {}
virtual ~SubPlugin() {}
- virtual int16 handleEvent(const ANPEvent* evt) = 0;
+ virtual int16_t handleEvent(const ANPEvent* evt) = 0;
NPP inst() const { return m_inst; }
diff --git a/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp b/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp
index 2eff394..91f1b3d 100644
--- a/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp
+++ b/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp
@@ -138,7 +138,7 @@ void EventPlugin::printToDiv(const char* text, int length) {
browser->memfree(beginMem);
}
-int16 EventPlugin::handleEvent(const ANPEvent* evt) {
+int16_t EventPlugin::handleEvent(const ANPEvent* evt) {
switch (evt->eventType) {
case kDraw_ANPEventType: {
diff --git a/tests/BrowserTestPlugin/jni/event/EventPlugin.h b/tests/BrowserTestPlugin/jni/event/EventPlugin.h
index 88b7c9d..043be85 100644
--- a/tests/BrowserTestPlugin/jni/event/EventPlugin.h
+++ b/tests/BrowserTestPlugin/jni/event/EventPlugin.h
@@ -32,7 +32,7 @@ class EventPlugin : public SubPlugin {
public:
EventPlugin(NPP inst);
virtual ~EventPlugin();
- virtual int16 handleEvent(const ANPEvent* evt);
+ virtual int16_t handleEvent(const ANPEvent* evt);
private:
void drawPlugin(const ANPBitmap& bitmap, const ANPRectI& clip);
diff --git a/tests/BrowserTestPlugin/jni/main.cpp b/tests/BrowserTestPlugin/jni/main.cpp
index 402a7e2..511180c 100644
--- a/tests/BrowserTestPlugin/jni/main.cpp
+++ b/tests/BrowserTestPlugin/jni/main.cpp
@@ -34,19 +34,19 @@
NPNetscapeFuncs* browser;
#define EXPORT __attribute__((visibility("default")))
-NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
+NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc,
char* argn[], char* argv[], NPSavedData* saved);
NPError NPP_Destroy(NPP instance, NPSavedData** save);
NPError NPP_SetWindow(NPP instance, NPWindow* window);
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
- NPBool seekable, uint16* stype);
+ NPBool seekable, uint16_t* stype);
NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
-int32 NPP_WriteReady(NPP instance, NPStream* stream);
-int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
+int32_t NPP_WriteReady(NPP instance, NPStream* stream);
+int32_t NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len,
void* buffer);
void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
void NPP_Print(NPP instance, NPPrint* platformPrint);
-int16 NPP_HandleEvent(NPP instance, void* event);
+int16_t NPP_HandleEvent(NPP instance, void* event);
void NPP_URLNotify(NPP instance, const char* URL, NPReason reason,
void* notifyData);
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value);
@@ -129,7 +129,7 @@ const char *NP_GetMIMEDescription(void)
return "application/x-browsertestplugin:btp:Android Browser Test Plugin";
}
-NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
+NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc,
char* argn[], char* argv[], NPSavedData* saved)
{
@@ -188,7 +188,7 @@ NPError NPP_SetWindow(NPP instance, NPWindow* window)
return NPERR_NO_ERROR;
}
-NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
+NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype)
{
*stype = NP_ASFILEONLY;
return NPERR_NO_ERROR;
@@ -199,12 +199,12 @@ NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
return NPERR_NO_ERROR;
}
-int32 NPP_WriteReady(NPP instance, NPStream* stream)
+int32_t NPP_WriteReady(NPP instance, NPStream* stream)
{
return 0;
}
-int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
+int32_t NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer)
{
return 0;
}
@@ -217,7 +217,7 @@ void NPP_Print(NPP instance, NPPrint* platformPrint)
{
}
-int16 NPP_HandleEvent(NPP instance, void* event)
+int16_t NPP_HandleEvent(NPP instance, void* event)
{
PluginObject *obj = reinterpret_cast<PluginObject*>(instance->pdata);
const ANPEvent* evt = reinterpret_cast<const ANPEvent*>(event);
diff --git a/tests/DumpRenderTree/assets/run_layout_tests.py b/tests/DumpRenderTree/assets/run_layout_tests.py
index b6e7bf3..ceac5d2 100755
--- a/tests/DumpRenderTree/assets/run_layout_tests.py
+++ b/tests/DumpRenderTree/assets/run_layout_tests.py
@@ -176,7 +176,7 @@ def main(options, args):
# Count crashed tests.
crashed_tests = []
- timeout_ms = '30000'
+ timeout_ms = '15000'
if options.time_out_ms:
timeout_ms = options.time_out_ms
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
index 77fd3ed..8bdf77c 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
@@ -73,30 +73,40 @@ public class FileFilter {
static final String[] ignoreTestList = {
"editing/selection/move-left-right.html", // Causes DumpRenderTree to hang
+ "fast/js/excessive-comma-usage.html", // Tests huge initializer list, causes OOM.
"fast/js/regexp-charclass-crash.html", // RegExp is too large, causing OOM
"fast/regex/test1.html", // Causes DumpRenderTree to hang with V8
"fast/regex/slow.html" // Causes DumpRenderTree to hang with V8
};
static void fillIgnoreResultList() {
- // This first block of tests are for HTML5 features, for which Android
+ // This first block of tests are for features for which Android
// should pass all tests. They are skipped only temporarily.
// TODO: Fix these failing tests and remove them from this list.
+ ignoreResultList.add("fast/events/touch/basic-multi-touch-events.html"); // Requires multi-touch
+ ignoreResultList.add("fast/events/touch/touch-target.html"); // Requires multi-touch
ignoreResultList.add("http/tests/appcache/empty-manifest.html"); // flaky
+ ignoreResultList.add("http/tests/appcache/fallback.html"); // http://b/issue?id=2713004
ignoreResultList.add("http/tests/appcache/foreign-iframe-main.html"); // flaky - skips states
ignoreResultList.add("http/tests/appcache/manifest-with-empty-file.html"); // flaky
ignoreResultList.add("storage/database-lock-after-reload.html"); // Succeeds but DumpRenderTree does not read result correctly
ignoreResultList.add("storage/hash-change-with-xhr.html"); // Succeeds but DumpRenderTree does not read result correctly
-
- // Will always fail
- ignoreResultList.add("dom/svg/level3/xpath"); // XPath not supported
+ ignoreResultList.add("storage/open-database-creation-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
+ ignoreResultList.add("storage/statement-error-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
+ ignoreResultList.add("storage/statement-success-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
+ ignoreResultList.add("storage/transaction-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
+ ignoreResultList.add("storage/transaction-error-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
+ ignoreResultList.add("storage/transaction-success-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
+
+ // Expected failures due to unsupported features.
+ ignoreResultList.add("fast/events/touch/touch-coords-in-zoom-and-scroll.html"); // Requires eventSender.zoomPageIn(),zoomPageOut()
ignoreResultList.add("fast/workers"); // workers not supported
- ignoreResultList.add("fast/xpath"); // XPath not supported
ignoreResultList.add("http/tests/eventsource/workers"); // workers not supported
ignoreResultList.add("http/tests/workers"); // workers not supported
ignoreResultList.add("http/tests/xmlhttprequest/workers"); // workers not supported
ignoreResultList.add("storage/domstorage/localstorage/private-browsing-affects-storage.html"); // private browsing not supported
ignoreResultList.add("storage/domstorage/sessionstorage/private-browsing-affects-storage.html"); // private browsing not supported
+ ignoreResultList.add("storage/indexeddb"); // indexeddb not supported
ignoreResultList.add("storage/private-browsing-readonly.html"); // private browsing not supported
ignoreResultList.add("websocket/tests/workers"); // workers not supported
@@ -104,12 +114,9 @@ public class FileFilter {
ignoreResultList.add("fast/css/case-transform.html"); // will not fix #619707
ignoreResultList.add("fast/dom/Element/offsetLeft-offsetTop-body-quirk.html"); // different screen size result in extra spaces in Apple compared to us
ignoreResultList.add("fast/dom/Window/Plug-ins.html"); // need test plugin
- ignoreResultList.add("fast/dom/Window/window-properties.html"); // xslt and xpath elements missing from property list
ignoreResultList.add("fast/dom/Window/window-screen-properties.html"); // pixel depth
ignoreResultList.add("fast/dom/Window/window-xy-properties.html"); // requires eventSender.mouseDown(),mouseUp()
ignoreResultList.add("fast/dom/attribute-namespaces-get-set.html"); // http://b/733229
- ignoreResultList.add("fast/dom/gc-9.html"); // requires xpath support
- ignoreResultList.add("fast/dom/global-constructors.html"); // requires xslt and xpath support
ignoreResultList.add("fast/dom/object-embed-plugin-scripting.html"); // dynamic plugins not supported
ignoreResultList.add("fast/dom/tabindex-clamp.html"); // there is extra spacing in the file due to multiple input boxes fitting on one line on Apple, ours are wrapped. Space at line ends are stripped.
ignoreResultList.add("fast/events/anchor-image-scrolled-x-y.html"); // requires eventSender.mouseDown(),mouseUp()
@@ -172,8 +179,6 @@ public class FileFilter {
ignoreResultList.add("fast/replaced/image-map.html"); // requires eventSender.mouseDown(),mouseUp()
ignoreResultList.add("fast/text/plain-text-line-breaks.html"); // extra spacing because iFrames rendered next to each other on Apple
ignoreResultList.add("profiler"); // profiler is not supported
- ignoreResultList.add("svg"); // svg is not supported
-
}
}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
index 322b0d2..0883387 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
@@ -42,8 +42,13 @@ public class FsUtils {
//no creation of instances
}
- public static void findLayoutTestsRecursively(BufferedOutputStream bos,
+ /**
+ * @return the number of tests in the list.
+ */
+ public static int writeLayoutTestListRecursively(BufferedOutputStream bos,
String dir, boolean ignoreResultsInDir) throws IOException {
+
+ int testCount = 0;
Log.v(LOGTAG, "Searching tests under " + dir);
File d = new File(dir);
@@ -61,7 +66,7 @@ public class FsUtils {
// If this is not a test directory, we don't recurse into it.
if (!FileFilter.isNonTestDir(s)) {
Log.v(LOGTAG, "Recursing on " + s);
- findLayoutTestsRecursively(bos, s, ignoreResultsInDir);
+ testCount += writeLayoutTestListRecursively(bos, s, ignoreResultsInDir);
}
continue;
}
@@ -81,8 +86,10 @@ public class FsUtils {
bos.write((" IGNORE_RESULT").getBytes());
}
bos.write('\n');
+ testCount++;
}
}
+ return testCount;
}
public static void updateTestStatus(String statusFile, String s) {
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
index 042158a..fabbf89 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
@@ -18,12 +18,9 @@ package com.android.dumprendertree;
import com.android.dumprendertree.TestShellActivity.DumpDataType;
import com.android.dumprendertree.forwarder.AdbUtils;
-import com.android.dumprendertree.forwarder.ForwardServer;
import com.android.dumprendertree.forwarder.ForwardService;
-import android.app.Instrumentation;
import android.content.Intent;
-import android.os.Bundle;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
@@ -156,18 +153,11 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
private String mJsEngine;
private String mTestPathPrefix;
private boolean mFinished;
+ private int mTestCount;
+ private int mResumeIndex;
public LayoutTestsAutoTest() {
- super("com.android.dumprendertree", TestShellActivity.class);
- }
-
- // This function writes the result of the layout test to
- // Am status so that it can be picked up from a script.
- private void passOrFailCallback(String file, boolean result) {
- Instrumentation inst = getInstrumentation();
- Bundle bundle = new Bundle();
- bundle.putBoolean(file, result);
- inst.sendStatus(0, bundle);
+ super(TestShellActivity.class);
}
private void getTestList() {
@@ -188,6 +178,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
} catch (Exception e) {
Log.e(LOGTAG, "Error while reading test list : " + e.getMessage());
}
+ mTestCount = mTestList.size();
}
private void resumeTestList() {
@@ -198,6 +189,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
if (mTestList.elementAt(i).equals(line)) {
mTestList = new Vector<String>(mTestList.subList(i+1, mTestList.size()));
mTestListIgnoreResult = new Vector<Boolean>(mTestListIgnoreResult.subList(i+1, mTestListIgnoreResult.size()));
+ mResumeIndex = i + 1;
break;
}
}
@@ -298,7 +290,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
}
}
- private void runTestAndWaitUntilDone(TestShellActivity activity, String test, int timeout, boolean ignoreResult) {
+ private void runTestAndWaitUntilDone(TestShellActivity activity, String test, int timeout, boolean ignoreResult, int testNumber) {
activity.setCallback(new TestShellCallback() {
public void finished() {
synchronized (LayoutTestsAutoTest.this) {
@@ -334,6 +326,8 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
intent.putExtra(TestShellActivity.TEST_URL, FsUtils.getTestUrl(test));
intent.putExtra(TestShellActivity.RESULT_FILE, resultFile);
intent.putExtra(TestShellActivity.TIMEOUT_IN_MILLIS, timeout);
+ intent.putExtra(TestShellActivity.TOTAL_TEST_COUNT, mTestCount);
+ intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, testNumber);
activity.startActivity(intent);
// Wait until done.
@@ -373,8 +367,8 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
// Read settings
mTestPathPrefix = (new File(LAYOUT_TESTS_ROOT + runner.mTestPath)).getAbsolutePath();
mRebaselineResults = runner.mRebaseline;
- // JSC is the default JavaScript engine.
- mJsEngine = runner.mJsEngine == null ? "jsc" : runner.mJsEngine;
+ // V8 is the default JavaScript engine.
+ mJsEngine = runner.mJsEngine == null ? "v8" : runner.mJsEngine;
int timeout = runner.mTimeoutInMillis;
if (timeout <= 0) {
@@ -391,7 +385,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
resumeTestList();
TestShellActivity activity = getActivity();
- activity.setDefaultDumpDataType(DumpDataType.DUMP_AS_TEXT);
+ activity.setDefaultDumpDataType(DumpDataType.EXT_REPR);
// Run tests.
int addr = -1;
@@ -408,7 +402,9 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
boolean ignoreResult = mTestListIgnoreResult.elementAt(i);
FsUtils.updateTestStatus(TEST_STATUS_FILE, s);
// Run tests
- runTestAndWaitUntilDone(activity, s, runner.mTimeoutInMillis, ignoreResult);
+ // i is 0 based, but test count is 1 based so add 1 to i here.
+ runTestAndWaitUntilDone(activity, s, runner.mTimeoutInMillis, ignoreResult,
+ i + 1 + mResumeIndex);
}
FsUtils.updateTestStatus(TEST_STATUS_FILE, "#DONE");
@@ -433,7 +429,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
try {
File tests_list = new File(LAYOUT_TESTS_LIST_FILE);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false));
- FsUtils.findLayoutTestsRecursively(bos, getTestPath(), false); // Don't ignore results
+ FsUtils.writeLayoutTestListRecursively(bos, getTestPath(), false); // Don't ignore results
bos.flush();
bos.close();
} catch (Exception e) {
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java b/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java
index 82671eb..5ffe6b0 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java
@@ -51,29 +51,38 @@ public class Menu extends FileList {
intent.setClass(this, TestShellActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(TestShellActivity.TEST_URL, "file://" + filename);
+ intent.putExtra(TestShellActivity.TOTAL_TEST_COUNT, 1);
+ intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, 1);
startActivity(intent);
}
@Override
void processDirectory(String path, boolean selection) {
- generateTestList(path);
+ int testCount = generateTestList(path);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClass(this, TestShellActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(TestShellActivity.UI_AUTO_TEST, LAYOUT_TESTS_LIST_FILE);
+ intent.putExtra(TestShellActivity.TOTAL_TEST_COUNT, testCount);
+ // TestShellActivity will process this intent once and increment the test index
+ // before running the first test, so pass 0 here to allow for that.
+ intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, 0);
startActivity(intent);
}
- private void generateTestList(String path) {
+ private int generateTestList(String path) {
+ int testCount = 0;
try {
File tests_list = new File(LAYOUT_TESTS_LIST_FILE);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false));
- FsUtils.findLayoutTestsRecursively(bos, path, false); // Don't ignore results
+ testCount = FsUtils.writeLayoutTestListRecursively(
+ bos, path, false); // Don't ignore results
bos.flush();
bos.close();
} catch (Exception e) {
Log.e(LOGTAG, "Error when creating test list: " + e.getMessage());
}
+ return testCount;
}
}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
index 81d5b08..e6f7a27 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
@@ -34,6 +34,8 @@ import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.ViewGroup;
+import android.view.Window;
+import android.webkit.ConsoleMessage;
import android.webkit.GeolocationPermissions;
import android.webkit.HttpAuthHandler;
import android.webkit.JsPromptResult;
@@ -116,6 +118,7 @@ public class TestShellActivity extends Activity implements LayoutTestController
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ requestWindowFeature(Window.FEATURE_PROGRESS);
LinearLayout contentView = new LinearLayout(this);
contentView.setOrientation(LinearLayout.VERTICAL);
@@ -158,6 +161,9 @@ public class TestShellActivity extends Activity implements LayoutTestController
return;
}
+ mTotalTestCount = intent.getIntExtra(TOTAL_TEST_COUNT, mTotalTestCount);
+ mCurrentTestNumber = intent.getIntExtra(CURRENT_TEST_NUMBER, mCurrentTestNumber);
+
mTestUrl = intent.getStringExtra(TEST_URL);
if (mTestUrl == null) {
mUiAutoTestPath = intent.getStringExtra(UI_AUTO_TEST);
@@ -171,6 +177,10 @@ public class TestShellActivity extends Activity implements LayoutTestController
mTimeoutInMillis = intent.getIntExtra(TIMEOUT_IN_MILLIS, 0);
mGetDrawtime = intent.getBooleanExtra(GET_DRAW_TIME, false);
mSaveImagePath = intent.getStringExtra(SAVE_IMAGE);
+ setTitle("Test " + mCurrentTestNumber + " of " + mTotalTestCount);
+ float ratio = (float)mCurrentTestNumber / mTotalTestCount;
+ int progress = (int)(ratio * Window.PROGRESS_END);
+ getWindow().setFeatureInt(Window.FEATURE_PROGRESS, progress);
Log.v(LOGTAG, " Loading " + mTestUrl);
mWebView.loadUrl(mTestUrl);
@@ -236,6 +246,7 @@ public class TestShellActivity extends Activity implements LayoutTestController
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(TestShellActivity.TEST_URL, FsUtils.getTestUrl(url));
+ intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, ++mCurrentTestNumber);
intent.putExtra(TIMEOUT_IN_MILLIS, 10000);
executeIntent(intent);
}
@@ -347,7 +358,9 @@ public class TestShellActivity extends Activity implements LayoutTestController
Log.v(LOGTAG, "notifyDone called: " + url);
if (mWaitUntilDone) {
mWaitUntilDone = false;
- mChromeClient.onProgressChanged(mWebView, 101);
+ if (!mRequestedWebKitData && !mTimedOut && !finished()) {
+ requestWebKitData();
+ }
}
}
@@ -489,11 +502,30 @@ public class TestShellActivity extends Activity implements LayoutTestController
drawPageToFile(mSaveImagePath + "/" + name + ".png", mWebView);
}
}
+
// Calling finished() will check if we've met all the conditions for completing
- // this test and move to the next one if we are ready.
+ // this test and move to the next one if we are ready. Otherwise we ask WebCore to
+ // dump the page.
if (finished()) {
return;
}
+
+ if (!mWaitUntilDone && !mRequestedWebKitData && !mTimedOut) {
+ requestWebKitData();
+ } else {
+ if (mWaitUntilDone) {
+ Log.v(LOGTAG, "page finished loading but waiting for notifyDone to be called: " + url);
+ }
+
+ if (mRequestedWebKitData) {
+ Log.v(LOGTAG, "page finished loading but webkit data has already been requested: " + url);
+ }
+
+ if (mTimedOut) {
+ Log.v(LOGTAG, "page finished loading but already timed out: " + url);
+ }
+ }
+
super.onPageFinished(view, url);
}
@@ -535,44 +567,8 @@ public class TestShellActivity extends Activity implements LayoutTestController
private final WebChromeClient mChromeClient = new WebChromeClient() {
@Override
- public void onProgressChanged(WebView view, int newProgress) {
-
- // notifyDone calls this with 101%. We only want to update this flag if this
- // is the real call from WebCore.
- if (newProgress == 100) {
- mOneHundredPercentComplete = true;
- }
-
- // With the flag updated, we can now proceed as normal whether the progress update came from
- // WebCore or notifyDone.
- if (newProgress >= 100) {
- // finished() will check if we are ready to move to the next test and do so if we are.
- if (finished()) {
- return;
- }
-
- if (!mTimedOut && !mWaitUntilDone && !mRequestedWebKitData) {
- String url = mWebView.getUrl();
- Log.v(LOGTAG, "Finished: "+ url);
- requestWebKitData();
- } else {
- String url = mWebView.getUrl();
- if (mTimedOut) {
- Log.v(LOGTAG, "Timed out before finishing: " + url);
- } else if (mWaitUntilDone) {
- Log.v(LOGTAG, "Waiting for notifyDone: " + url);
- } else if (mRequestedWebKitData) {
- Log.v(LOGTAG, "Requested webkit data ready: " + url);
- }
- }
- }
- }
-
- @Override
public void onReceivedTitle(WebView view, String title) {
- if (title.length() > 30)
- title = "..."+title.substring(title.length()-30);
- setTitle(title);
+ setTitle("Test " + mCurrentTestNumber + " of " + mTotalTestCount + ": "+ title);
if (mDumpTitleChanges) {
mTitleChanges.append("TITLE CHANGED: ");
mTitleChanges.append(title);
@@ -675,15 +671,28 @@ public class TestShellActivity extends Activity implements LayoutTestController
}
@Override
- public void onConsoleMessage(String message, int lineNumber,
- String sourceID) {
+ public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
+ String msg = "CONSOLE MESSAGE: line " + consoleMessage.lineNumber() + ": "
+ + consoleMessage.message() + "\n";
if (mConsoleMessages == null) {
mConsoleMessages = new StringBuffer();
}
- String consoleMessage = "CONSOLE MESSAGE: line "
- + lineNumber +": "+ message +"\n";
- mConsoleMessages.append(consoleMessage);
- Log.v(LOGTAG, "LOG: "+consoleMessage);
+ mConsoleMessages.append(msg);
+ Log.v(LOGTAG, "LOG: " + msg);
+ // the rationale here is that if there's an error of either type, and the test was
+ // waiting for "notifyDone" signal to finish, then there's no point in waiting
+ // anymore because the JS execution is already terminated at this point and a
+ // "notifyDone" will never come out so it's just wasting time till timeout kicks in
+ if (msg.contains("Uncaught ReferenceError:") || msg.contains("Uncaught TypeError:")
+ && mWaitUntilDone) {
+ Log.w(LOGTAG, "Terminating test case on uncaught ReferenceError or TypeError.");
+ mHandler.postDelayed(new Runnable() {
+ public void run() {
+ notifyDone();
+ }
+ }, 500);
+ }
+ return true;
}
@Override
@@ -738,10 +747,10 @@ public class TestShellActivity extends Activity implements LayoutTestController
mEventSender.clearTouchPoints();
mEventSender.clearTouchMetaState();
mPageFinished = false;
- mOneHundredPercentComplete = false;
mDumpWebKitData = false;
mGetDrawtime = false;
mSaveImagePath = null;
+ setDefaultWebSettings(mWebView);
}
private long[] getDrawWebViewTime(WebView view, int count) {
@@ -778,7 +787,7 @@ public class TestShellActivity extends Activity implements LayoutTestController
}
private boolean canMoveToNextTest() {
- return (mDumpWebKitData && mOneHundredPercentComplete && mPageFinished && !mWaitUntilDone) || mTimedOut;
+ return (mDumpWebKitData && mPageFinished && !mWaitUntilDone) || mTimedOut;
}
private void setupWebViewForLayoutTests(WebView webview, CallbackProxy callbackProxy) {
@@ -786,6 +795,19 @@ public class TestShellActivity extends Activity implements LayoutTestController
return;
}
+ setDefaultWebSettings(webview);
+
+ webview.setWebChromeClient(mChromeClient);
+ webview.setWebViewClient(mViewClient);
+ // Setting a touch interval of -1 effectively disables the optimisation in WebView
+ // that stops repeated touch events flooding WebCore. The Event Sender only sends a
+ // single event rather than a stream of events (like what would generally happen in
+ // a real use of touch events in a WebView) and so if the WebView drops the event,
+ // the test will fail as the test expects one callback for every touch it synthesizes.
+ webview.setTouchInterval(-1);
+ }
+
+ public void setDefaultWebSettings(WebView webview) {
WebSettings settings = webview.getSettings();
settings.setAppCacheEnabled(true);
settings.setAppCachePath(getApplicationContext().getCacheDir().getPath());
@@ -798,15 +820,6 @@ public class TestShellActivity extends Activity implements LayoutTestController
settings.setDatabasePath(getDir("databases",0).getAbsolutePath());
settings.setDomStorageEnabled(true);
settings.setWorkersEnabled(false);
-
- webview.setWebChromeClient(mChromeClient);
- webview.setWebViewClient(mViewClient);
- // Setting a touch interval of -1 effectively disables the optimisation in WebView
- // that stops repeated touch events flooding WebCore. The Event Sender only sends a
- // single event rather than a stream of events (like what would generally happen in
- // a real use of touch events in a WebView) and so if the WebView drops the event,
- // the test will fail as the test expects one callback for every touch it synthesizes.
- webview.setTouchInterval(-1);
}
private WebView mWebView;
@@ -823,6 +836,8 @@ public class TestShellActivity extends Activity implements LayoutTestController
private String mSaveImagePath;
private BufferedReader mTestListReader;
private boolean mGetDrawtime;
+ private int mTotalTestCount;
+ private int mCurrentTestNumber;
// States
private boolean mTimedOut;
@@ -845,7 +860,6 @@ public class TestShellActivity extends Activity implements LayoutTestController
private boolean mPageFinished = false;
private boolean mDumpWebKitData = false;
- private boolean mOneHundredPercentComplete = false;
static final String TIMEOUT_STR = "**Test timeout";
@@ -860,6 +874,8 @@ public class TestShellActivity extends Activity implements LayoutTestController
static final String UI_AUTO_TEST = "UiAutoTest";
static final String GET_DRAW_TIME = "GetDrawTime";
static final String SAVE_IMAGE = "SaveImage";
+ static final String TOTAL_TEST_COUNT = "TestCount";
+ static final String CURRENT_TEST_NUMBER = "TestNumber";
static final int DRAW_RUNS = 5;
static final String DRAW_TIME_LOG = "/sdcard/android/page_draw_time.txt";