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

Side by Side Diff: ppapi/tests/test_case.h

Issue 6899055: PPAPI: Force async callback invocation option. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/arch_dependent_sizes_64.h ('k') | ppapi/tests/test_case.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PPAPI_TESTS_TEST_CASE_H_ 5 #ifndef PPAPI_TESTS_TEST_CASE_H_
6 #define PPAPI_TESTS_TEST_CASE_H_ 6 #define PPAPI_TESTS_TEST_CASE_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 // Makes sure the test is run over HTTP. 63 // Makes sure the test is run over HTTP.
64 bool EnsureRunningOverHTTP(); 64 bool EnsureRunningOverHTTP();
65 65
66 // Pointer to the instance that owns us. 66 // Pointer to the instance that owns us.
67 TestingInstance* instance_; 67 TestingInstance* instance_;
68 68
69 // NULL unless InitTestingInterface is called. 69 // NULL unless InitTestingInterface is called.
70 const PPB_Testing_Dev* testing_interface_; 70 const PPB_Testing_Dev* testing_interface_;
71 71
72 // Force asynchronous completion of any operation taking a callback.
73 bool force_async_;
74
72 private: 75 private:
73 // Holds the test object, if any was retrieved from CreateTestObject. 76 // Holds the test object, if any was retrieved from CreateTestObject.
74 pp::Var test_object_; 77 pp::Var test_object_;
75 }; 78 };
76 79
77 // This class is an implementation detail. 80 // This class is an implementation detail.
78 class TestCaseFactory { 81 class TestCaseFactory {
79 public: 82 public:
80 typedef TestCase* (*Method)(TestingInstance* instance); 83 typedef TestCase* (*Method)(TestingInstance* instance);
81 84
(...skipping 25 matching lines...) Expand all
107 #define REGISTER_TEST_CASE(name) \ 110 #define REGISTER_TEST_CASE(name) \
108 static TestCase* Test##name##_FactoryMethod(TestingInstance* instance) { \ 111 static TestCase* Test##name##_FactoryMethod(TestingInstance* instance) { \
109 return new Test##name(instance); \ 112 return new Test##name(instance); \
110 } \ 113 } \
111 static TestCaseFactory g_Test##name_factory( \ 114 static TestCaseFactory g_Test##name_factory( \
112 #name, &Test##name##_FactoryMethod \ 115 #name, &Test##name##_FactoryMethod \
113 ) 116 )
114 117
115 // Helper macro for calling functions implementing specific tests in the 118 // Helper macro for calling functions implementing specific tests in the
116 // RunTest function. This assumes the function name is TestFoo where Foo is the 119 // RunTest function. This assumes the function name is TestFoo where Foo is the
117 // test name, 120 // test |name|.
118 #define RUN_TEST(name) \ 121 #define RUN_TEST(name) \
122 force_async_ = false; \
119 instance_->LogTest(#name, Test##name()); 123 instance_->LogTest(#name, Test##name());
120 124
125 // Like RUN_TEST above but forces functions taking callbacks to complete
126 // asynchronously on success or error.
127 #define RUN_TEST_FORCEASYNC(name) \
128 force_async_ = true; \
129 instance_->LogTest(#name"ForceAsync", Test##name());
130
131 #define RUN_TEST_FORCEASYNC_AND_NOT(name) \
132 RUN_TEST_FORCEASYNC(name); \
133 RUN_TEST(name);
134
135
121 // Helper macros for checking values in tests, and returning a location 136 // Helper macros for checking values in tests, and returning a location
122 // description of the test fails. 137 // description of the test fails.
123 #define ASSERT_TRUE(cmd) \ 138 #define ASSERT_TRUE(cmd) \
124 if (!(cmd)) { \ 139 if (!(cmd)) { \
125 return MakeFailureMessage(__FILE__, __LINE__, #cmd); \ 140 return MakeFailureMessage(__FILE__, __LINE__, #cmd); \
126 } 141 }
127 #define ASSERT_FALSE(cmd) ASSERT_TRUE(!(cmd)) 142 #define ASSERT_FALSE(cmd) ASSERT_TRUE(!(cmd))
128 #define ASSERT_EQ(a, b) ASSERT_TRUE((a) == (b)) 143 #define ASSERT_EQ(a, b) ASSERT_TRUE((a) == (b))
129 #define ASSERT_NE(a, b) ASSERT_TRUE((a) != (b)) 144 #define ASSERT_NE(a, b) ASSERT_TRUE((a) != (b))
130 145
131 #define ASSERT_DOUBLE_EQ(a, b) ASSERT_TRUE( \ 146 #define ASSERT_DOUBLE_EQ(a, b) ASSERT_TRUE( \
132 std::fabs((a)-(b)) <= std::numeric_limits<double>::epsilon()) 147 std::fabs((a)-(b)) <= std::numeric_limits<double>::epsilon())
133 148
134 #define PASS() return std::string() 149 #define PASS() return std::string()
135 150
136 #endif // PPAPI_TESTS_TEST_CASE_H_ 151 #endif // PPAPI_TESTS_TEST_CASE_H_
OLDNEW
« no previous file with comments | « ppapi/tests/arch_dependent_sizes_64.h ('k') | ppapi/tests/test_case.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698