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

Unified Diff: ppapi/tests/test_case.h

Issue 9937001: PPAPI: Refactor ppapi test callbacks to ease testing blocking callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 9 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
« no previous file with comments | « ppapi/proxy/ppb_network_monitor_private_proxy.cc ('k') | ppapi/tests/test_case.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_case.h
diff --git a/ppapi/tests/test_case.h b/ppapi/tests/test_case.h
index b4815a1a9dc54c36f82bc519a1ab80c654a4a355..297308489f58441da361e1dd3081ee4fb3c624c6 100644
--- a/ppapi/tests/test_case.h
+++ b/ppapi/tests/test_case.h
@@ -14,6 +14,7 @@
#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/cpp/dev/scrollbar_dev.h"
#include "ppapi/cpp/view.h"
+#include "ppapi/tests/test_utils.h"
#if (defined __native_client__)
#include "ppapi/cpp/var.h"
@@ -108,13 +109,28 @@ class TestCase {
// Pointer to the instance that owns us.
TestingInstance* instance_;
+ protected:
// NULL unless InitTestingInterface is called.
const PPB_Testing_Dev* testing_interface_;
- // Force asynchronous completion of any operation taking a callback.
+ // TODO(dmichael): Remove this, it's for temporary backwards compatibility so
+ // I don't have to change all the tests at once.
bool force_async_;
+ void set_callback_type(CallbackType callback_type) {
+ callback_type_ = callback_type;
+ // TODO(dmichael): Remove this; see comment on force_async_.
+ force_async_ = (callback_type_ == PP_REQUIRED);
+ }
+ CallbackType callback_type() const {
+ return callback_type_;
+ }
+
private:
+ // Passed when creating completion callbacks in some tests. This determines
+ // what kind of callback we use for the test.
+ CallbackType callback_type_;
+
// Var ids that should be ignored when checking for leaks on shutdown.
std::set<int64_t> ignored_leaked_vars_;
@@ -167,7 +183,7 @@ class TestCaseFactory {
// test |name|.
#define RUN_TEST(name, test_filter) \
if (MatchesFilter(#name, test_filter)) { \
- force_async_ = false; \
+ set_callback_type(PP_OPTIONAL); \
std::string error_message = Test##name(); \
if (error_message.empty()) \
error_message = CheckResourcesAndVars(); \
@@ -176,7 +192,7 @@ class TestCaseFactory {
#define RUN_TEST_WITH_REFERENCE_CHECK(name, test_filter) \
if (MatchesFilter(#name, test_filter)) { \
- force_async_ = false; \
+ set_callback_type(PP_OPTIONAL); \
uint32_t objects = testing_interface_->GetLiveObjectsForInstance( \
instance_->pp_instance()); \
std::string error_message = Test##name(); \
@@ -192,7 +208,7 @@ class TestCaseFactory {
// asynchronously on success or error.
#define RUN_TEST_FORCEASYNC(name, test_filter) \
if (MatchesFilter(#name"ForceAsync", test_filter)) { \
- force_async_ = true; \
+ set_callback_type(PP_REQUIRED); \
instance_->LogTest(#name"ForceAsync", Test##name()); \
}
« no previous file with comments | « ppapi/proxy/ppb_network_monitor_private_proxy.cc ('k') | ppapi/tests/test_case.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698