summaryrefslogtreecommitdiffstats
path: root/ppapi/tests/test_case.h
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-16 04:28:02 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-16 04:28:02 +0000
commit2622d6ba235013928ae0ea9ac542678ac445d71a (patch)
tree46cabffc9ead9facce66c9a6d8c4760d23d4d2f8 /ppapi/tests/test_case.h
parent4be70c824d3d9804b76e09051cf47ceae1cfc49c (diff)
downloadchromium_src-2622d6ba235013928ae0ea9ac542678ac445d71a.zip
chromium_src-2622d6ba235013928ae0ea9ac542678ac445d71a.tar.gz
chromium_src-2622d6ba235013928ae0ea9ac542678ac445d71a.tar.bz2
Reland http://codereview.chromium.org/8477015
Landed at r109114, Reverted at r109142 Make it possible to enable/disable specific ppapi tests. Migrate PostMessage tests. The testcase attribute now can include a 'filter'. If it's omitted, everything works the same as before. This way we can migrate tests over bit-by-bit if we want to. We can also still run the tests manually the same way as before. This only runs PostMessage testss the new way, and re-enables all oop PostMessage tests that pass on Windows. I can do the other tests in this CL if desired, but it might be easier to land in a few pieces. BUG=102885 TEST=N/A TBR=dmichael@chromium.org Review URL: http://codereview.chromium.org/8536031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110248 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests/test_case.h')
-rw-r--r--ppapi/tests/test_case.h31
1 files changed, 19 insertions, 12 deletions
diff --git a/ppapi/tests/test_case.h b/ppapi/tests/test_case.h
index 05e0d32..e974c50 100644
--- a/ppapi/tests/test_case.h
+++ b/ppapi/tests/test_case.h
@@ -37,9 +37,12 @@ class TestCase {
// Default implementation just returns true.
virtual bool Init();
- // Override to implement the test. It will be called after the plugin is
- // first displayed.
- virtual void RunTest() = 0;
+ // Override to implement the test case. It will be called after the plugin is
+ // first displayed, passing a string. If the string is empty, the
+ // should run all tests for this test case. Otherwise, it should run the test
+ // whose name matches test_filter exactly (if there is one). This should
+ // generally be implemented using the RUN_TEST* macros.
+ virtual void RunTests(const std::string& test_filter) = 0;
static std::string MakeFailureMessage(const char* file, int line,
const char* cmd);
@@ -83,6 +86,10 @@ class TestCase {
// Makes sure the test is run over HTTP.
bool EnsureRunningOverHTTP();
+ // Return true if the given test name matches the filter. This is true if
+ // (a) filter is empty or (b) test_name and filter match exactly.
+ bool MatchesFilter(const std::string& test_name, const std::string& filter);
+
// Pointer to the instance that owns us.
TestingInstance* instance_;
@@ -140,24 +147,24 @@ class TestCaseFactory {
// Helper macro for calling functions implementing specific tests in the
// RunTest function. This assumes the function name is TestFoo where Foo is the
// test |name|.
-#define RUN_TEST(name) \
- do { \
+#define RUN_TEST(name, test_filter) \
+ if (MatchesFilter(#name, test_filter)) { \
force_async_ = false; \
instance_->LogTest(#name, Test##name()); \
- } while (false)
+ }
// Like RUN_TEST above but forces functions taking callbacks to complete
// asynchronously on success or error.
-#define RUN_TEST_FORCEASYNC(name) \
- do { \
+#define RUN_TEST_FORCEASYNC(name, test_filter) \
+ if (MatchesFilter(#name"ForceAsync", test_filter)) { \
force_async_ = true; \
instance_->LogTest(#name"ForceAsync", Test##name()); \
- } while (false)
+ }
-#define RUN_TEST_FORCEASYNC_AND_NOT(name) \
+#define RUN_TEST_FORCEASYNC_AND_NOT(name, test_filter) \
do { \
- RUN_TEST_FORCEASYNC(name); \
- RUN_TEST(name); \
+ RUN_TEST_FORCEASYNC(name, test_filter); \
+ RUN_TEST(name, test_filter); \
} while (false)