Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5610)

Unified Diff: chrome/test/nacl/nacl_browsertest_util.cc

Issue 10918152: Port nacl_integration exit_status test to browser_tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/nacl/nacl_browsertest_util.cc
diff --git a/chrome/test/nacl/nacl_browsertest_util.cc b/chrome/test/nacl/nacl_browsertest_util.cc
index c2b7a0284c23e16482d53c4822f32ec46c1ee72c..d9048720bb855d399333228adbaf6e99b38b8f17 100644
--- a/chrome/test/nacl/nacl_browsertest_util.cc
+++ b/chrome/test/nacl/nacl_browsertest_util.cc
@@ -96,6 +96,62 @@ MessageResponse LoadTestMessageHandler::HandleStructuredMessage(
}
}
+// A message handler for nacl_integration tests ported to be browser_tests.
Mark Seaborn 2012/09/11 22:10:06 Commenting this based on where the code came from
Nick Bray (chromium) 2012/09/12 01:19:13 Done.
+class NaClIntegrationMessageHandler : public StructuredMessageHandler {
+ public:
+ NaClIntegrationMessageHandler();
+
+ void Log(const std::string& message);
+
+ virtual MessageResponse HandleStructuredMessage(
+ const std::string& type,
+ base::DictionaryValue* msg) OVERRIDE;
+
+ bool test_passed() const {
+ return test_passed_;
+ }
+
+ private:
+ bool test_passed_;
+
+ DISALLOW_COPY_AND_ASSIGN(NaClIntegrationMessageHandler);
+};
+
+NaClIntegrationMessageHandler::NaClIntegrationMessageHandler()
+ : test_passed_(false) {
+}
+
+void NaClIntegrationMessageHandler::Log(const std::string& message) {
+ // TODO(ncbray) better logging.
+ LOG(INFO) << "|||| " << message;
Mark Seaborn 2012/09/11 22:10:06 Aren't LOG(INFO) omitted from the buildbot logs (a
+}
+
+MessageResponse NaClIntegrationMessageHandler::HandleStructuredMessage(
+ const std::string& type,
Mark Seaborn 2012/09/11 22:10:06 Indent by 1 more space
Nick Bray (chromium) 2012/09/12 01:19:13 Done.
+ DictionaryValue* msg) {
+ if (type == "TestLog") {
+ std::string message;
+ if (!msg->GetString("message", &message))
+ return MissingField(type, "message");
+ Log(message);
+ return CONTINUE;
+ } else if (type == "Shutdown") {
+ std::string message;
+ if (!msg->GetString("message", &message))
+ return MissingField(type, "message");
+ if (!msg->GetBoolean("passed", &test_passed_))
+ return MissingField(type, "passed");
+ Log(message);
+ return DONE;
+ } else if (type == "Ping") {
+ return CONTINUE;
+ } else if (type == "JavaScriptIsAlive") {
+ return CONTINUE;
+ } else {
+ return InternalError("Unknown message type: " + type);
+ }
+}
+
// NaCl browser tests serve files out of the build directory because nexes and
// pexes are artifacts of the build. To keep things tidy, all test data is kept
// in a subdirectory. Several variants of a test may be run, for example when
@@ -137,9 +193,6 @@ void NaClBrowserTestBase::SetUpInProcessBrowserTestFixture() {
}
GURL NaClBrowserTestBase::TestURL(const FilePath::StringType& test_file) {
- FilePath real_path = test_server_->document_root().Append(test_file);
Mark Seaborn 2012/09/11 22:10:06 Why does this go? Comment in commit message. I d
Nick Bray (chromium) 2012/09/12 01:19:13 Because the new tests put a query string at the en
Mark Seaborn 2012/09/12 18:09:45 So please add a note in the commit message that yo
- EXPECT_TRUE(file_util::PathExists(real_path)) << real_path.value();
-
FilePath url_path = FilePath(FILE_PATH_LITERAL("files"));
url_path = url_path.Append(test_file);
return test_server_->GetURL(url_path.MaybeAsASCII());
@@ -161,6 +214,14 @@ void NaClBrowserTestBase::RunLoadTest(const FilePath::StringType& test_file) {
ASSERT_TRUE(handler.test_passed()) << "Test failed.";
}
+void NaClBrowserTestBase::RunNaClIntegrationTest(
+ const FilePath::StringType& test_file) {
+ NaClIntegrationMessageHandler handler;
+ bool ok = RunJavascriptTest(TestURL(test_file), &handler);
+ ASSERT_TRUE(ok) << handler.error_message();
+ ASSERT_TRUE(handler.test_passed()) << "Test failed.";
+}
+
bool NaClBrowserTestBase::StartTestServer() {
// Launch the web server.
FilePath document_root;

Powered by Google App Engine
This is Rietveld 408576698