| OLD | NEW |
| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 // Helper macro for calling functions implementing specific tests in the | 147 // Helper macro for calling functions implementing specific tests in the |
| 148 // RunTest function. This assumes the function name is TestFoo where Foo is the | 148 // RunTest function. This assumes the function name is TestFoo where Foo is the |
| 149 // test |name|. | 149 // test |name|. |
| 150 #define RUN_TEST(name, test_filter) \ | 150 #define RUN_TEST(name, test_filter) \ |
| 151 if (MatchesFilter(#name, test_filter)) { \ | 151 if (MatchesFilter(#name, test_filter)) { \ |
| 152 force_async_ = false; \ | 152 force_async_ = false; \ |
| 153 instance_->LogTest(#name, Test##name()); \ | 153 instance_->LogTest(#name, Test##name()); \ |
| 154 } | 154 } |
| 155 | 155 |
| 156 #define RUN_TEST_WITH_REFERENCE_CHECK(name, test_filter) \ |
| 157 if (MatchesFilter(#name, test_filter)) { \ |
| 158 force_async_ = false; \ |
| 159 uint32_t objects = testing_interface_->GetLiveObjectsForInstance( \ |
| 160 instance_->pp_instance()); \ |
| 161 std::string error_message = Test##name(); \ |
| 162 if (error_message.empty() && \ |
| 163 testing_interface_->GetLiveObjectsForInstance( \ |
| 164 instance_->pp_instance()) != objects) \ |
| 165 error_message = MakeFailureMessage(__FILE__, __LINE__, \ |
| 166 "reference leak check"); \ |
| 167 instance_->LogTest(#name, error_message); \ |
| 168 } |
| 169 |
| 156 // Like RUN_TEST above but forces functions taking callbacks to complete | 170 // Like RUN_TEST above but forces functions taking callbacks to complete |
| 157 // asynchronously on success or error. | 171 // asynchronously on success or error. |
| 158 #define RUN_TEST_FORCEASYNC(name, test_filter) \ | 172 #define RUN_TEST_FORCEASYNC(name, test_filter) \ |
| 159 if (MatchesFilter(#name"ForceAsync", test_filter)) { \ | 173 if (MatchesFilter(#name"ForceAsync", test_filter)) { \ |
| 160 force_async_ = true; \ | 174 force_async_ = true; \ |
| 161 instance_->LogTest(#name"ForceAsync", Test##name()); \ | 175 instance_->LogTest(#name"ForceAsync", Test##name()); \ |
| 162 } | 176 } |
| 163 | 177 |
| 164 #define RUN_TEST_FORCEASYNC_AND_NOT(name, test_filter) \ | 178 #define RUN_TEST_FORCEASYNC_AND_NOT(name, test_filter) \ |
| 165 do { \ | 179 do { \ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 177 #define ASSERT_FALSE(cmd) ASSERT_TRUE(!(cmd)) | 191 #define ASSERT_FALSE(cmd) ASSERT_TRUE(!(cmd)) |
| 178 #define ASSERT_EQ(a, b) ASSERT_TRUE((a) == (b)) | 192 #define ASSERT_EQ(a, b) ASSERT_TRUE((a) == (b)) |
| 179 #define ASSERT_NE(a, b) ASSERT_TRUE((a) != (b)) | 193 #define ASSERT_NE(a, b) ASSERT_TRUE((a) != (b)) |
| 180 | 194 |
| 181 #define ASSERT_DOUBLE_EQ(a, b) ASSERT_TRUE( \ | 195 #define ASSERT_DOUBLE_EQ(a, b) ASSERT_TRUE( \ |
| 182 std::fabs((a)-(b)) <= std::numeric_limits<double>::epsilon()) | 196 std::fabs((a)-(b)) <= std::numeric_limits<double>::epsilon()) |
| 183 | 197 |
| 184 #define PASS() return std::string() | 198 #define PASS() return std::string() |
| 185 | 199 |
| 186 #endif // PPAPI_TESTS_TEST_CASE_H_ | 200 #endif // PPAPI_TESTS_TEST_CASE_H_ |
| OLD | NEW |