summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorjvoung <jvoung@chromium.org>2015-04-02 22:04:38 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-03 05:05:50 +0000
commitbcf51e8a8147633694fa75853592d1a74e56dc6f (patch)
treef98dc1bf6393e42377aa6f95c1e36fb5c8f128a5 /chrome/test
parentcf78967cb40c1f7c27230c1fa995b5da21b5b788 (diff)
downloadchromium_src-bcf51e8a8147633694fa75853592d1a74e56dc6f.zip
chromium_src-bcf51e8a8147633694fa75853592d1a74e56dc6f.tar.gz
chromium_src-bcf51e8a8147633694fa75853592d1a74e56dc6f.tar.bz2
Enhance the pnacl_nmf_options/simple.cc test a bit (post message and reply).
This checks that the app actually does something (vs just getting the load progress event) from chrome. Otherwise, if the app crashes it will still pass. We want the test to be more interesting since it's testing different compilers and different optimization levels where things could go wrong. Followup to Nick's comment in: https://codereview.chromium.org/1005173006 BUG= https://code.google.com/p/nativeclient/issues/detail?id=4091 CQ_EXTRA_TRYBOTS=tryserver.chromium.linux:linux_chromium_dbg_32_ng Review URL: https://codereview.chromium.org/1051963002 Cr-Commit-Position: refs/heads/master@{#323596}
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.html1
-rw-r--r--chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.js11
-rw-r--r--chrome/test/data/nacl/nacl_load_test.html20
-rw-r--r--chrome/test/data/nacl/nacl_test_data.gyp2
-rw-r--r--chrome/test/data/nacl/pnacl_nmf_options/pnacl_options.html22
-rw-r--r--chrome/test/data/nacl/simple.cc11
-rw-r--r--chrome/test/data/nacl/simple_cc.js42
7 files changed, 64 insertions, 45 deletions
diff --git a/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.html b/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.html
index ab8d08e..dc4dfcb 100644
--- a/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.html
+++ b/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.html
@@ -7,6 +7,7 @@ found in the LICENSE file.
<head>
<script type="text/javascript" src="nacltest.js"></script>
<script type="text/javascript" src="load_util.js"></script>
+ <script type="text/javascript" src="simple_cc.js"></script>
<script type="text/javascript" src="extension_validation_cache.js"></script>
<title>NaCl Extension nexe-load validation cache test</title>
</head>
diff --git a/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.js b/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.js
index 1913f22..2c0fd5a 100644
--- a/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.js
+++ b/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.js
@@ -4,16 +4,7 @@
function create(manifest_url) {
var embed = load_util.embed(manifest_url);
-
- embed.addEventListener("load", function(evt) {
- load_util.shutdown("1 test passed.", true);
- }, true);
-
- embed.addEventListener("error", function(evt) {
- load_util.log("Load error: " + embed.lastError);
- load_util.shutdown("1 test failed.", false);
- }, true);
-
+ simple_test.addTestListeners(embed);
document.body.appendChild(embed);
}
diff --git a/chrome/test/data/nacl/nacl_load_test.html b/chrome/test/data/nacl/nacl_load_test.html
index 9574abf..2737cf3 100644
--- a/chrome/test/data/nacl/nacl_load_test.html
+++ b/chrome/test/data/nacl/nacl_load_test.html
@@ -11,15 +11,10 @@ found in the LICENSE file.
<h2>NaCl Load Test</h2>
</body>
<script type="text/javascript" src="nacltest.js"> </script>
+<script type="text/javascript" src="load_util.js"> </script>
+<script type="text/javascript" src="simple_cc.js"> </script>
<script>
-function report(msg) {
- domAutomationController.setAutomationId(0);
- // The automation controller seems to choke on Objects, so turn them into
- // strings.
- domAutomationController.send(JSON.stringify(msg));
-}
-
function create(manifest_url) {
var embed = document.createElement("embed");
embed.src = manifest_url;
@@ -27,16 +22,7 @@ function create(manifest_url) {
if (getTestArguments()["pnacl"] !== undefined) {
embed.type = "application/x-pnacl";
}
-
- embed.addEventListener("load", function(evt) {
- report({type: "Shutdown", message: "1 test passed.", passed: true});
- }, true);
-
- embed.addEventListener("error", function(evt) {
- report({type: "Log", message: "Load error: " + embed.lastError});
- report({type: "Shutdown", message: "1 test failed.", passed: false});
- }, true);
-
+ simple_test.addTestListeners(embed);
document.body.appendChild(embed);
}
diff --git a/chrome/test/data/nacl/nacl_test_data.gyp b/chrome/test/data/nacl/nacl_test_data.gyp
index 33cc739..0372000 100644
--- a/chrome/test/data/nacl/nacl_test_data.gyp
+++ b/chrome/test/data/nacl/nacl_test_data.gyp
@@ -38,6 +38,7 @@
'load_util.js',
'manifest_file/test_file.txt',
'progress_event_listener.js',
+ 'simple_cc.js',
],
},
'conditions': [
@@ -122,6 +123,7 @@
# Note that the .nexe names are embedded in this file.
'extension_validation_cache/manifest.json',
'load_util.js',
+ 'simple_cc.js',
],
},
'dependencies': [
diff --git a/chrome/test/data/nacl/pnacl_nmf_options/pnacl_options.html b/chrome/test/data/nacl/pnacl_nmf_options/pnacl_options.html
index 3f9ca65..8267dff9 100644
--- a/chrome/test/data/nacl/pnacl_nmf_options/pnacl_options.html
+++ b/chrome/test/data/nacl/pnacl_nmf_options/pnacl_options.html
@@ -5,37 +5,23 @@ Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<head>
-<title>NaCl Load Test</title>
+<title>PNaCl Load Options Test</title>
<script type="text/javascript" src="nacltest.js"></script>
+<script type="text/javascript" src="load_util.js"></script>
+<script type="text/javascript" src="simple_cc.js"></script>
</head>
<body>
<h2>PNaCl Load Options Test</h2>
</body>
<script>
-function report(msg) {
- domAutomationController.setAutomationId(0);
- // The automation controller seems to choke on Objects, so turn them into
- // strings.
- domAutomationController.send(JSON.stringify(msg));
-}
-
function create(manifest_prefix, manifest_opt) {
var embed = document.createElement("embed");
var nmf_url = manifest_prefix + manifest_opt + ".nmf";
embed.src = nmf_url;
embed.type = "application/x-pnacl";
-
- embed.addEventListener("load", function(evt) {
- report({type: "Shutdown", message: "1 test passed.", passed: true});
- }, true);
-
- embed.addEventListener("error", function(evt) {
- report({type: "Log", message: "Load error: " + embed.lastError});
- report({type: "Shutdown", message: "1 test failed.", passed: false});
- }, true);
-
+ simple_test.addTestListeners(embed);
document.body.appendChild(embed);
}
diff --git a/chrome/test/data/nacl/simple.cc b/chrome/test/data/nacl/simple.cc
index c539fbb..bd7c651 100644
--- a/chrome/test/data/nacl/simple.cc
+++ b/chrome/test/data/nacl/simple.cc
@@ -2,13 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
+
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/var.h"
class SimpleInstance : public pp::Instance {
public:
explicit SimpleInstance(PP_Instance instance) : pp::Instance(instance) {
}
+
+ virtual void HandleMessage(const pp::Var& var_message) {
+ if (var_message.is_string() && var_message.AsString() == "ping") {
+ PostMessage(pp::Var("pong"));
+ return;
+ }
+ PostMessage(pp::Var("failed"));
+ }
};
class SimpleModule : public pp::Module {
diff --git a/chrome/test/data/nacl/simple_cc.js b/chrome/test/data/nacl/simple_cc.js
new file mode 100644
index 0000000..52c4ea3
--- /dev/null
+++ b/chrome/test/data/nacl/simple_cc.js
@@ -0,0 +1,42 @@
+// Copyright 2015 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.
+
+// Set up listeners and test expectations for tests which use simple.cc
+// This depends on load_util.js for reporting.
+var simple_test = {
+ addTestListeners: function(embed) {
+ embed.addEventListener("load", function(evt) {
+ embed.postMessage("ping");
+ }, true);
+
+ embed.addEventListener("message", function(message) {
+ var expected_message = "pong";
+ if (message.data === expected_message) {
+ load_util.report({type: "Shutdown",
+ message: "1 test passed.", passed: true});
+ } else {
+ load_util.report(
+ {type: "Log",
+ message: "Error: expected reply (" + expected_message +
+ "), actual reply (" + message + ")"});
+ load_util.report({type: "Shutdown",
+ message: "1 test failed.", passed: false});
+ }
+ }, true);
+
+ embed.addEventListener("error", function(evt) {
+ load_util.report({type: "Log",
+ message: "Load error: " + embed.lastError});
+ load_util.report({type: "Shutdown",
+ message: "1 test failed.", passed: false});
+ }, true);
+
+ embed.addEventListener("crash", function(evt) {
+ load_util.report({type: "Log",
+ message: "Crashed with status: " + embed.exitStatus});
+ load_util.report({type: "Shutdown",
+ message: "1 test failed.", passed: false});
+ }, true);
+ }
+};