diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-25 01:42:53 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-25 01:42:53 +0000 |
commit | b46661fefd56c2061e36a5a47a6c1289f7d6f6c5 (patch) | |
tree | e82d9b8527f9cab72d7d163a1fb21bfda4e8fbfd /ppapi | |
parent | 7f2f351c0198e698703a3703897a2ab86590fc05 (diff) | |
download | chromium_src-b46661fefd56c2061e36a5a47a6c1289f7d6f6c5.zip chromium_src-b46661fefd56c2061e36a5a47a6c1289f7d6f6c5.tar.gz chromium_src-b46661fefd56c2061e36a5a47a6c1289f7d6f6c5.tar.bz2 |
Try to reduce the flankness of the PPAPI UI tests.
Instead of a "started" and "completed" cookie, this now uses a separate
cookie for each test, so that the browser can monitor progress. Now it will
only time out if an individual test takes longer than the timeout, rather
than an entire test case.
TEST=this is
BUG=none
Review URL: http://codereview.chromium.org/7677031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98163 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/tests/testing_instance.cc | 21 | ||||
-rw-r--r-- | ppapi/tests/testing_instance.h | 23 |
2 files changed, 42 insertions, 2 deletions
diff --git a/ppapi/tests/testing_instance.cc b/ppapi/tests/testing_instance.cc index 138ef16..87c709f 100644 --- a/ppapi/tests/testing_instance.cc +++ b/ppapi/tests/testing_instance.cc @@ -6,6 +6,7 @@ #include <algorithm> #include <cstring> +#include <sstream> #include <vector> #include "ppapi/cpp/module.h" @@ -14,6 +15,10 @@ TestCaseFactory* TestCaseFactory::head_ = NULL; +// Cookie value we use to signal "we're still working." See the comment above +// the class declaration for how this works. +static const char kProgressSignal[] = "..."; + // Returns a new heap-allocated test case for the given test, or NULL on // failure. TestingInstance::TestingInstance(PP_Instance instance) @@ -23,6 +28,7 @@ TestingInstance::TestingInstance(PP_Instance instance) : pp::InstancePrivate(instance), #endif current_case_(NULL), + progress_cookie_number_(0), executed_tests_(false), nacl_mode_(false) { callback_factory_.Initialize(this); @@ -87,6 +93,9 @@ void TestingInstance::DidChangeView(const pp::Rect& position, void TestingInstance::LogTest(const std::string& test_name, const std::string& error_message) { + // Tell the browser we're still working. + ReportProgress(kProgressSignal); + std::string html; html.append("<div class=\"test_line\"><span class=\"test_name\">"); html.append(test_name); @@ -113,7 +122,7 @@ void TestingInstance::AppendError(const std::string& message) { } void TestingInstance::ExecuteTests(int32_t unused) { - SetCookie("STARTUP_COOKIE", "STARTED"); + ReportProgress(kProgressSignal); // Clear the console. PostMessage(pp::Var("TESTING_MESSAGE:ClearConsole")); @@ -134,7 +143,7 @@ void TestingInstance::ExecuteTests(int32_t unused) { } // Declare we're done by setting a cookie to either "PASS" or the errors. - SetCookie("COMPLETION_COOKIE", errors_.empty() ? "PASS" : errors_); + ReportProgress(errors_.empty() ? "PASS" : errors_); PostMessage(pp::Var("TESTING_MESSAGE:DidExecuteTests")); } @@ -189,6 +198,14 @@ void TestingInstance::LogHTML(const std::string& html) { PostMessage(pp::Var(message)); } +void TestingInstance::ReportProgress(const std::string& progress_value) { + // Use streams since nacl doesn't compile base yet (for StringPrintf). + std::ostringstream cookie_name; + cookie_name << "PPAPI_PROGRESS_" << progress_cookie_number_; + SetCookie(cookie_name.str(), progress_value); + progress_cookie_number_++; +} + void TestingInstance::SetCookie(const std::string& name, const std::string& value) { std::string message("TESTING_MESSAGE:SetCookie:"); diff --git a/ppapi/tests/testing_instance.h b/ppapi/tests/testing_instance.h index 9f42409..c0370a7 100644 --- a/ppapi/tests/testing_instance.h +++ b/ppapi/tests/testing_instance.h @@ -17,6 +17,23 @@ class TestCase; +// How signaling works: +// +// We want to signal to the Chrome UI test harness +// (chrome/test/ui/ppapi_uitest.cc) that we're making progress and when we're +// done. The easiest thing in the UI test infrastructure is to wait for a +// cookie to become nonempty. We don't want to have a big wait for all tests in +// a TestCase since they can take a while and it might timeout. So we set a +// series of cookies with an incrementing number in the name. +// +// If the value of the cookie is "..." then that tells the test runner that +// the test is progressing. It then waits for the next numbered cookie until +// it either times out or the value is something other than "...". In this +// case, the value will be either "PASS" or "FAIL [optional message]" +// corresponding to the outcome of the entire test case. Timeout will be +// treated just like a failure of the entire test case and the test will be +// terminated. +// // In trusted builds, we use InstancePrivate and allow tests that use // synchronous scripting. NaCl does not support synchronous scripting. class TestingInstance : public @@ -81,6 +98,8 @@ pp::InstancePrivate { // Appends the given HTML string to the console in the document. void LogHTML(const std::string& html); + void ReportProgress(const std::string& progress_value); + // Sets the given cookie in the current document. void SetCookie(const std::string& name, const std::string& value); @@ -89,6 +108,10 @@ pp::InstancePrivate { // Owning pointer to the current test case. Valid after Init has been called. TestCase* current_case_; + // The current step we're on starting at 0. This is incremented every time we + // report progress via a cookie. See comment above the class. + int progress_cookie_number_; + // Set once the tests are run so we know not to re-run when the view is sized. bool executed_tests_; |