Index: ppapi/tests/test_case.h |
=================================================================== |
--- ppapi/tests/test_case.h (revision 77426) |
+++ ppapi/tests/test_case.h (working copy) |
@@ -1,10 +1,12 @@ |
-// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
polina
2011/03/17 02:59:28
I don't know about open source code, but in other
|
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef PPAPI_TEST_TEST_CASE_H_ |
-#define PPAPI_TEST_TEST_CASE_H_ |
+#ifndef PPAPI_TESTS_TEST_CASE_H_ |
+#define PPAPI_TESTS_TEST_CASE_H_ |
+#include <cmath> |
+#include <limits> |
#include <string> |
#include "ppapi/c/pp_resource.h" |
@@ -22,7 +24,7 @@ |
// Individual classes of tests derive from this generic test case. |
class TestCase { |
public: |
- TestCase(TestingInstance* instance) : instance_(instance) {} |
+ explicit TestCase(TestingInstance* instance) : instance_(instance) {} |
virtual ~TestCase() {} |
// Optionally override to do testcase specific initialization. |
@@ -38,6 +40,12 @@ |
// Internally, this uses CreateTestObject which each test overrides. |
pp::Var GetTestObject(); |
+ // A function that is invoked whenever HandleMessage is called on the |
+ // associated TestingInstance. Default implementation does nothing. TestCases |
+ // that want to handle incoming postMessage events should override this |
+ // method. |
+ virtual void HandleMessage(const pp::Var& message_data); |
+ |
protected: |
// Overridden by each test to supply a ScriptableObject corresponding to the |
// test. There can only be one object created for all test in a given class |
@@ -115,6 +123,10 @@ |
#define ASSERT_EQ(a, b) ASSERT_TRUE((a) == (b)) |
#define ASSERT_NE(a, b) ASSERT_TRUE((a) != (b)) |
+#define ASSERT_DOUBLE_EQ(a, b) ASSERT_TRUE( \ |
+ std::fabs((a)-(b)) <= std::numeric_limits<double>::epsilon()) |
+ |
#define PASS() return std::string() |
-#endif // PPAPI_TEST_TEST_CASE_H_ |
+#endif // PPAPI_TESTS_TEST_CASE_H_ |
+ |