summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorgarianov@google.com <garianov@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-16 20:59:23 +0000
committergarianov@google.com <garianov@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-16 20:59:23 +0000
commit52d2c8e0d85be3f3f6eca7b54e15b6e9d43a0182 (patch)
tree19097d31f50a93724cdbc93c29af94a044b900cd /ppapi
parent6497b9d91e37f3635c7ea51cd63494bead7d5911 (diff)
downloadchromium_src-52d2c8e0d85be3f3f6eca7b54e15b6e9d43a0182.zip
chromium_src-52d2c8e0d85be3f3f6eca7b54e15b6e9d43a0182.tar.gz
chromium_src-52d2c8e0d85be3f3f6eca7b54e15b6e9d43a0182.tar.bz2
Run Pepper unit tests in Native Client
copy of http://codereview.chromium.org/4991006/ had to do it again in 'commitable' version of chrome tree Review URL: http://codereview.chromium.org/4979006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66321 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/dev/ppb_char_set_dev.h2
-rw-r--r--ppapi/cpp/var.cc6
-rw-r--r--ppapi/cpp/var.h1
-rw-r--r--ppapi/tests/nacl.scons21
-rw-r--r--ppapi/tests/test_case.html45
-rw-r--r--ppapi/tests/testing_instance.cc18
-rw-r--r--ppapi/tests/testing_instance.h3
7 files changed, 81 insertions, 15 deletions
diff --git a/ppapi/c/dev/ppb_char_set_dev.h b/ppapi/c/dev/ppb_char_set_dev.h
index 9b9d8e5..a433c62 100644
--- a/ppapi/c/dev/ppb_char_set_dev.h
+++ b/ppapi/c/dev/ppb_char_set_dev.h
@@ -29,7 +29,7 @@ enum PP_CharSet_ConversionError {
// it will use the unicode "substitution character" U+FFFD. When converting
// to another character set, the character will be charset-specific. For
// many languages this will be the representation of the '?' character.
- PP_CHARSET_CONVERSIONERROR_SUBSTITUTE,
+ PP_CHARSET_CONVERSIONERROR_SUBSTITUTE
};
struct PPB_CharSet_Dev {
diff --git a/ppapi/cpp/var.cc b/ppapi/cpp/var.cc
index 5ade9b0..a6f30ca 100644
--- a/ppapi/cpp/var.cc
+++ b/ppapi/cpp/var.cc
@@ -61,6 +61,12 @@ Var::Var(int32_t i) {
needs_release_ = false;
}
+Var::Var(long i) {
+ var_.type = PP_VARTYPE_INT32;
+ var_.value.as_int = i;
+ needs_release_ = false;
+}
+
Var::Var(double d) {
var_.type = PP_VARTYPE_DOUBLE;
var_.value.as_double = d;
diff --git a/ppapi/cpp/var.h b/ppapi/cpp/var.h
index 9109fef..d67eb24 100644
--- a/ppapi/cpp/var.h
+++ b/ppapi/cpp/var.h
@@ -24,6 +24,7 @@ class Var {
Var(Null); // PP_Var of type Null.
Var(bool b);
Var(int32_t i);
+ Var(long i);
Var(double d);
Var(const char* utf8_str); // Must be encoded in UTF-8.
Var(const std::string& utf8_str); // Must be encoded in UTF-8.
diff --git a/ppapi/tests/nacl.scons b/ppapi/tests/nacl.scons
new file mode 100644
index 0000000..e4d0b9d
--- /dev/null
+++ b/ppapi/tests/nacl.scons
@@ -0,0 +1,21 @@
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+Import('env')
+
+ppapi_tests_nexe = env.ComponentProgram('ppapi_tests.nexe',
+ Glob('*.cc'),
+ EXTRA_LIBS=['ppruntime',
+ 'ppapi_cpp',
+ 'pthread',
+ 'srpc'])
+# Note that the html is required to run this program.
+# To run, load page with mode=nacl search string:
+# http://localhost:5103/scons-out/nacl-x86-32/staging/test_case.html?mode=nacl
+env.Publish('ppapi_tests.nexe', 'run',
+ ['test_case.html',
+ 'test_image_data',
+ 'test_page.css',
+ 'test_url_loader_data'])
+
diff --git a/ppapi/tests/test_case.html b/ppapi/tests/test_case.html
index 71c305a..cae02bf 100644
--- a/ppapi/tests/test_case.html
+++ b/ppapi/tests/test_case.html
@@ -48,21 +48,44 @@ function RunAll() {
LoadNext(0);
}
-onload = function() {
- var mimeType = "application/x-ppapi-tests";
- if (mimeType in navigator.mimeTypes) {
- var testcase = location.search.substring(1);
- document.title = 'Test ' + testcase;
+function ExtractSearchParameter(name) {
+ var nameIndex = location.search.indexOf(name + "=");
+ if (nameIndex != -1) {
+ var value = location.search.substring(nameIndex + name.length + 1);
+ var endIndex = value.indexOf("&");
+ if (endIndex != -1)
+ value = value.substring(0, endIndex);
+ return value;
+ }
+ return "";
+}
- var obj = document.createElement("OBJECT");
+onload = function() {
+ var testcase = ExtractSearchParameter("testcase");
+ var mode = ExtractSearchParameter("mode");
+ document.title = 'Test ' + testcase;
+ var obj;
+ if (mode == "nacl") {
+ var nexes = "ARM: ppapi_tests_arm.nexe \nx86-32: ppapi_tests.nexe \nx86-64: ppapi_tests_x86_64.";
+ obj = document.createElement("OBJECT");
+ obj.setAttribute("type", "application/x-ppapi-nacl-srpc");
+ obj.setAttribute("nexes", nexes);
+ obj.setAttribute("mode", mode);
+ } else {
+ var mimeType = "application/x-ppapi-tests";
+ if (mimeType in navigator.mimeTypes) {
+ obj = document.createElement("OBJECT");
+ obj.setAttribute("type", mimeType);
+ } else {
+ document.getElementById("console").innerHTML =
+ '<span class="fail">FAIL</span>: ' +
+ '<span class="err_msg">Test plug-in is not registered.</span>';
+ }
+ }
+ if (obj) {
obj.setAttribute("id", "plugin");
- obj.setAttribute("type", mimeType);
obj.setAttribute("testcase", testcase);
document.getElementById("container").appendChild(obj);
- } else {
- document.getElementById("console").innerHTML =
- '<span class="fail">FAIL</span>: ' +
- '<span class="err_msg">Test plug-in is not registered.</span>';
}
}
</script>
diff --git a/ppapi/tests/testing_instance.cc b/ppapi/tests/testing_instance.cc
index 9cdd942..3f42d415 100644
--- a/ppapi/tests/testing_instance.cc
+++ b/ppapi/tests/testing_instance.cc
@@ -18,11 +18,21 @@ TestCaseFactory* TestCaseFactory::head_ = NULL;
TestingInstance::TestingInstance(PP_Instance instance)
: pp::Instance(instance),
current_case_(NULL),
- executed_tests_(false) {
+ executed_tests_(false),
+ nacl_mode_(false) {
callback_factory_.Initialize(this);
}
-bool TestingInstance::Init(uint32_t argc, const char* argn[], const char* argv[]) {
+bool TestingInstance::Init(uint32_t argc,
+ const char* argn[],
+ const char* argv[]) {
+ for (uint32_t i = 0; i < argc; i++) {
+ if (strcmp(argn[i], "mode") == 0) {
+ if (strcmp(argv[i], "nacl") == 0)
+ nacl_mode_ = true;
+ break;
+ }
+ }
// Create the proper test case from the argument.
for (uint32_t i = 0; i < argc; i++) {
if (strcmp(argn[i], "testcase") == 0) {
@@ -128,8 +138,10 @@ void TestingInstance::LogAvailableTests() {
std::string html;
html.append("Available test cases: <dl>");
for (size_t i = 0; i < test_cases.size(); ++i) {
- html.append("<dd><a href='?");
+ html.append("<dd><a href='?testcase=");
html.append(test_cases[i]);
+ if (nacl_mode_)
+ html.append("&mode=nacl");
html.append("'>");
html.append(test_cases[i]);
html.append("</a></dd>");
diff --git a/ppapi/tests/testing_instance.h b/ppapi/tests/testing_instance.h
index 1f9257e..5eedf24 100644
--- a/ppapi/tests/testing_instance.h
+++ b/ppapi/tests/testing_instance.h
@@ -70,6 +70,9 @@ class TestingInstance : public pp::Instance {
// Collects all errors to send the the browser. Empty indicates no error yet.
std::string errors_;
+
+ // True if running in Native Client.
+ bool nacl_mode_;
};
#endif // PPAPI_TEST_TESTING_INSTANCE_H_