summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-24 01:10:23 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-24 01:10:23 +0000
commit6d8528630b4841afa5a9b0c09be17d9f74d779db (patch)
treea7d2a4d2eec7887003e1eed884ff6e760aa4d0a1 /ppapi
parent71c10c5ae000e72154770f4e467928a15a05297a (diff)
downloadchromium_src-6d8528630b4841afa5a9b0c09be17d9f74d779db.zip
chromium_src-6d8528630b4841afa5a9b0c09be17d9f74d779db.tar.gz
chromium_src-6d8528630b4841afa5a9b0c09be17d9f74d779db.tar.bz2
PPAPI: Make ASSERT macros print values of operands
With this patch, if one of our ASSERT macros fails, the error string will contain the expected and actual values. I made a browser test for it. I would prefer a unit test, but I didn't want to have to mix test_case.h with our unit tests. BUG=None Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=246129 Review URL: https://codereview.chromium.org/123463007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246757 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/ppapi_sources.gypi2
-rw-r--r--ppapi/tests/test_case.h369
-rw-r--r--ppapi/tests/test_file_io.cc8
-rw-r--r--ppapi/tests/test_flash_clipboard.cc18
-rw-r--r--ppapi/tests/test_flash_file.cc8
-rw-r--r--ppapi/tests/test_flash_message_loop.cc4
-rw-r--r--ppapi/tests/test_graphics_3d.cc10
-rw-r--r--ppapi/tests/test_net_address_private.cc4
-rw-r--r--ppapi/tests/test_network_monitor.cc8
-rw-r--r--ppapi/tests/test_pdf.cc2
-rw-r--r--ppapi/tests/test_platform_verification_private.cc2
-rw-r--r--ppapi/tests/test_post_message.cc76
-rw-r--r--ppapi/tests/test_test_internals.cc277
-rw-r--r--ppapi/tests/test_test_internals.h28
-rw-r--r--ppapi/tests/test_url_loader.cc108
-rw-r--r--ppapi/tests/test_websocket.cc2
16 files changed, 792 insertions, 134 deletions
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi
index f47d3f97..faff951 100644
--- a/ppapi/ppapi_sources.gypi
+++ b/ppapi/ppapi_sources.gypi
@@ -484,6 +484,8 @@
'tests/test_tcp_socket.h',
'tests/test_tcp_socket_private.cc',
'tests/test_tcp_socket_private.h',
+ 'tests/test_test_internals.cc',
+ 'tests/test_test_internals.h',
'tests/test_trace_event.cc',
'tests/test_trace_event.h',
'tests/test_truetype_font.cc',
diff --git a/ppapi/tests/test_case.h b/ppapi/tests/test_case.h
index 0a96c9b..948d2b7 100644
--- a/ppapi/tests/test_case.h
+++ b/ppapi/tests/test_case.h
@@ -9,6 +9,7 @@
#include <limits>
#include <map>
#include <set>
+#include <sstream>
#include <string>
#include "ppapi/c/pp_resource.h"
@@ -273,6 +274,326 @@ class TestCaseFactory {
static TestCaseFactory* head_;
};
+namespace internal {
+
+// The internal namespace contains implementation details that are used by
+// the ASSERT macros.
+
+// This base class provides a ToString that works for classes that can be
+// converted to a string using std::stringstream. Later, we'll do
+// specializations for types that we know will work with this approach.
+template <class T>
+struct StringinatorBase {
+ static std::string ToString(const T& value) {
+ std::stringstream stream;
+ stream << value;
+ return stream.str();
+ }
+ protected:
+ // Not implemented, do not use.
+ // Note, these are protected because Windows complains if I make these private
+ // and then inherit StringinatorBase (even though they're never used).
+ StringinatorBase();
+ ~StringinatorBase();
+};
+
+// This default class template is for types that we don't recognize as
+// something we can convert into a string using stringstream. Types that we
+// know *can* be turned to a string should have specializations below.
+template <class T>
+struct Stringinator {
+ static std::string ToString(const T& value) {
+ return std::string();
+ }
+ private:
+ // Not implemented, do not use.
+ Stringinator();
+ ~Stringinator();
+};
+
+// Define some full specializations for types that can just use stringstream.
+#define DEFINE_STRINGINATOR_FOR_TYPE(type) \
+template <> \
+struct Stringinator<type> : public StringinatorBase<type> {};
+DEFINE_STRINGINATOR_FOR_TYPE(int32_t);
+DEFINE_STRINGINATOR_FOR_TYPE(uint32_t);
+DEFINE_STRINGINATOR_FOR_TYPE(int64_t);
+DEFINE_STRINGINATOR_FOR_TYPE(uint64_t);
+DEFINE_STRINGINATOR_FOR_TYPE(float);
+DEFINE_STRINGINATOR_FOR_TYPE(double);
+DEFINE_STRINGINATOR_FOR_TYPE(bool);
+DEFINE_STRINGINATOR_FOR_TYPE(std::string);
+#undef DEFINE_STRINGINATOR_FOR_TYPE
+
+template <class T>
+std::string ToString(const T& param) {
+ return Stringinator<T>::ToString(param);
+}
+
+// This overload is necessary to allow enum values (such as those from
+// pp_errors.h, including PP_OK) to work. They won't automatically convert to
+// an integral type to instantiate the above function template.
+inline std::string ToString(int32_t param) {
+ return Stringinator<int32_t>::ToString(param);
+}
+
+inline std::string ToString(const char* c_string) {
+ return std::string(c_string);
+}
+
+// This overload deals with pointers.
+template <class T>
+std::string ToString(const T* ptr) {
+ uintptr_t ptr_val = reinterpret_cast<uintptr_t>(ptr);
+ std::stringstream stream;
+ stream << ptr_val;
+ return stream.str();
+}
+
+// ComparisonHelper classes wrap the left-hand parameter of a binary comparison
+// ASSERT. The correct class gets chosen based on whether or not it's a NULL or
+// 0 literal. If it is a NULL/0 literal, we use NullLiteralComparisonHelper.
+// For all other parameters, we use ComparisonHelper. There's also a
+// specialization of ComparisonHelper for int below (see below for why
+// that is.)
+//
+// ComparisonHelper does two things for the left param:
+// 1) Provides all the appropriate CompareXX functions (CompareEQ, etc).
+// 2) Provides ToString.
+template <class T>
+struct ComparisonHelper {
+ explicit ComparisonHelper(const T& param) : value(param) {}
+ template <class U>
+ bool CompareEQ(const U& right) const {
+ return value == right;
+ }
+ template <class U>
+ bool CompareNE(const U& right) const {
+ return value != right;
+ }
+ template <class U>
+ bool CompareLT(const U& right) const {
+ return value < right;
+ }
+ template <class U>
+ bool CompareGT(const U& right) const {
+ return value > right;
+ }
+ template <class U>
+ bool CompareLE(const U& right) const {
+ return value <= right;
+ }
+ template <class U>
+ bool CompareGE(const U& right) const {
+ return value >= right;
+ }
+ std::string ToString() const {
+ return internal::ToString(value);
+ }
+ const T& value;
+};
+
+// Used for NULL or 0.
+struct NullLiteralComparisonHelper {
+ NullLiteralComparisonHelper() : value(0) {}
+ template <class U>
+ bool CompareEQ(const U& right) const {
+ return 0 == right;
+ }
+ template <class U>
+ bool CompareNE(const U& right) const {
+ return 0 != right;
+ }
+ template <class U>
+ bool CompareLT(const U& right) const {
+ return 0 < right;
+ }
+ template <class U>
+ bool CompareGT(const U& right) const {
+ return 0 > right;
+ }
+ template <class U>
+ bool CompareLE(const U& right) const {
+ return 0 <= right;
+ }
+ template <class U>
+ bool CompareGE(const U& right) const {
+ return 0 >= right;
+ }
+ std::string ToString() const {
+ return std::string("0");
+ }
+ const int value;
+};
+
+// This class makes it safe to use an integer literal (like 5, or 123) when
+// comparing with an unsigned. For example:
+// ASSERT_EQ(1, some_vector.size());
+// We do a lot of those comparisons, so this makes it easy to get it right
+// (rather than forcing assertions to use unsigned literals like 5u or 123u).
+//
+// This is slightly risky; we're static_casting an int to whatever's on the
+// right. If the left value is negative and the right hand side is a large
+// unsigned value, it's possible that the comparison will succeed when maybe
+// it shouldn't have.
+// TODO(dmichael): It should be possible to fix this and upgrade int32_t and
+// uint32_t to int64_t for the comparison, and make any unsafe
+// comparisons into compile errors.
+template <>
+struct ComparisonHelper<int> {
+ explicit ComparisonHelper(int param) : value(param) {}
+ template <class U>
+ bool CompareEQ(const U& right) const {
+ return static_cast<U>(value) == right;
+ }
+ template <class U>
+ bool CompareNE(const U& right) const {
+ return static_cast<U>(value) != right;
+ }
+ template <class U>
+ bool CompareLT(const U& right) const {
+ return static_cast<U>(value) < right;
+ }
+ template <class U>
+ bool CompareGT(const U& right) const {
+ return static_cast<U>(value) > right;
+ }
+ template <class U>
+ bool CompareLE(const U& right) const {
+ return static_cast<U>(value) <= right;
+ }
+ template <class U>
+ bool CompareGE(const U& right) const {
+ return static_cast<U>(value) >= right;
+ }
+ std::string ToString() const {
+ return internal::ToString(value);
+ }
+ const int value;
+ private:
+};
+
+// The default is for the case there the parameter is *not* a NULL or 0 literal.
+template <bool is_null_literal>
+struct ParameterWrapper {
+ template <class T>
+ static ComparisonHelper<T> WrapValue(const T& value) {
+ return ComparisonHelper<T>(value);
+ }
+ // This overload is so that we can deal with values from anonymous enums,
+ // like the one in pp_errors.h. The function template above won't be
+ // considered a match by the compiler.
+ static ComparisonHelper<int> WrapValue(int value) {
+ return ComparisonHelper<int>(value);
+ }
+};
+
+// The parameter to WrapValue *is* a NULL or 0 literal.
+template <>
+struct ParameterWrapper<true> {
+ // We just use "..." and ignore the parameter. This sidesteps some problems we
+ // would run in to (not all compilers have the same set of constraints).
+ // - We can't use a pointer type, because int and enums won't convert.
+ // - We can't use an integral type, because pointers won't convert.
+ // - We can't overload, because it will sometimes be ambiguous.
+ // - We can't templatize and deduce the parameter. Some compilers will deduce
+ // int for NULL, and then refuse to convert NULL to an int.
+ //
+ // We know in this case that the value is 0, so there's no need to capture the
+ // value. We also know it's a fundamental type, so it's safe to pass to "...".
+ // (It's illegal to pass non-POD types to ...).
+ static NullLiteralComparisonHelper WrapValue(...) {
+ return NullLiteralComparisonHelper();
+ }
+};
+
+// IS_NULL_LITERAL(type) is a little template metaprogramming for determining
+// if a type is a null or zero literal (NULL or 0 or a constant that evaluates
+// to one of those).
+// The idea is that for NULL or 0, any pointer type is always a better match
+// than "...". But no other pointer types or literals should convert
+// automatically to InternalDummyClass.
+struct InternalDummyClass {};
+char TestNullLiteral(const InternalDummyClass*);
+struct BiggerThanChar { char dummy[2]; };
+BiggerThanChar TestNullLiteral(...);
+// If the compiler chooses the overload of TestNullLiteral which returns char,
+// then we know the value converts automatically to InternalDummyClass*, which
+// should only be true of NULL and 0 constants.
+#define IS_NULL_LITERAL(a) sizeof(internal::TestNullLiteral(a)) == sizeof(char)
+
+template <class T, class U>
+static std::string MakeBinaryComparisonFailureMessage(
+ const char* comparator,
+ const T& left,
+ const U& right,
+ const char* left_precompiler_string,
+ const char* right_precompiler_string,
+ const char* file_name,
+ int line_number) {
+ std::string error_msg =
+ std::string("Failed ASSERT_") + comparator + "(" +
+ left_precompiler_string + ", " + right_precompiler_string + ")";
+ std::string left_string(left.ToString());
+ std::string right_string(ToString(right));
+ if (!left_string.empty())
+ error_msg += " Left: (" + left_string + ")";
+
+ if (!right_string.empty())
+ error_msg += " Right: (" + right_string + ")";
+
+ return TestCase::MakeFailureMessage(file_name, line_number,
+ error_msg.c_str());
+}
+
+// The Comparison function templates allow us to pass the parameter for
+// ASSERT macros below and have them be evaluated only once. This is important
+// for cases where the parameter might be an expression with side-effects, like
+// a function call.
+#define DEFINE_COMPARE_FUNCTION(comparator_name) \
+template <class T, class U> \
+std::string Compare ## comparator_name ( \
+ const T& left, \
+ const U& right, \
+ const char* left_precompiler_string, \
+ const char* right_precompiler_string, \
+ const char* file_name, \
+ int line_num) { \
+ if (!(left.Compare##comparator_name(right))) { \
+ return MakeBinaryComparisonFailureMessage(#comparator_name, \
+ left, \
+ right, \
+ left_precompiler_string, \
+ right_precompiler_string, \
+ file_name, \
+ line_num); \
+ } \
+ return std::string(); \
+}
+DEFINE_COMPARE_FUNCTION(EQ)
+DEFINE_COMPARE_FUNCTION(NE)
+DEFINE_COMPARE_FUNCTION(LT)
+DEFINE_COMPARE_FUNCTION(LE)
+DEFINE_COMPARE_FUNCTION(GT)
+DEFINE_COMPARE_FUNCTION(GE)
+#undef DEFINE_COMPARE_FUNCTION
+inline std::string CompareDoubleEq(ComparisonHelper<double> left,
+ double right,
+ const char* left_precompiler_string,
+ const char* right_precompiler_string,
+ const char* file_name,
+ int linu_num) {
+ if (!(std::fabs(left.value - right) <=
+ std::numeric_limits<double>::epsilon())) {
+ return MakeBinaryComparisonFailureMessage(
+ "~=", left, right, left_precompiler_string, right_precompiler_string,
+ __FILE__, __LINE__);
+ }
+ return std::string();
+}
+
+} // namespace internal
+
// Use the REGISTER_TEST_CASE macro in your TestCase implementation file to
// register your TestCase. If your test is named TestFoo, then add the
// following to test_foo.cc:
@@ -373,22 +694,48 @@ class TestCaseFactory {
return MakeFailureMessage(__FILE__, __LINE__, #cmd); \
} while (false)
#define ASSERT_FALSE(cmd) ASSERT_TRUE(!(cmd))
-#define ASSERT_EQ(a, b) ASSERT_TRUE((a) == (b))
-#define ASSERT_NE(a, b) ASSERT_TRUE((a) != (b))
-#define ASSERT_LT(a, b) ASSERT_TRUE((a) < (b))
-#define ASSERT_LE(a, b) ASSERT_TRUE((a) <= (b))
-#define ASSERT_GT(a, b) ASSERT_TRUE((a) > (b))
-#define ASSERT_GE(a, b) ASSERT_TRUE((a) >= (b))
-
-#define ASSERT_DOUBLE_EQ(a, b) ASSERT_TRUE( \
- std::fabs((a)-(b)) <= std::numeric_limits<double>::epsilon())
-
+#define COMPARE_BINARY_INTERNAL(comparison_type, a, b) \
+ internal::Compare##comparison_type( \
+ internal::ParameterWrapper<IS_NULL_LITERAL(a)>::WrapValue(a), \
+ (b), \
+ #a, \
+ #b, \
+ __FILE__, \
+ __LINE__)
+#define ASSERT_BINARY_INTERNAL(comparison_type, a, b) \
+do { \
+ std::string internal_assert_result_string = \
+ COMPARE_BINARY_INTERNAL(comparison_type, a, b); \
+ if (!internal_assert_result_string.empty()) { \
+ return internal_assert_result_string; \
+ } \
+} while(false)
+#define ASSERT_EQ(a, b) ASSERT_BINARY_INTERNAL(EQ, a, b)
+#define ASSERT_NE(a, b) ASSERT_BINARY_INTERNAL(NE, a, b)
+#define ASSERT_LT(a, b) ASSERT_BINARY_INTERNAL(LT, a, b)
+#define ASSERT_LE(a, b) ASSERT_BINARY_INTERNAL(LE, a, b)
+#define ASSERT_GT(a, b) ASSERT_BINARY_INTERNAL(GT, a, b)
+#define ASSERT_GE(a, b) ASSERT_BINARY_INTERNAL(GE, a, b)
+#define ASSERT_DOUBLE_EQ(a, b) \
+do { \
+ std::string internal_assert_result_string = \
+ internal::CompareDoubleEq( \
+ internal::ParameterWrapper<IS_NULL_LITERAL(a)>::WrapValue(a), \
+ (b), \
+ #a, \
+ #b, \
+ __FILE__, \
+ __LINE__); \
+ if (!internal_assert_result_string.empty()) { \
+ return internal_assert_result_string; \
+ } \
+} while(false)
// Runs |function| as a subtest and asserts that it has passed.
#define ASSERT_SUBTEST_SUCCESS(function) \
do { \
std::string result = (function); \
if (!result.empty()) \
- return result; \
+ return TestCase::MakeFailureMessage(__FILE__, __LINE__, result.c_str()); \
} while (false)
#define PASS() return std::string()
diff --git a/ppapi/tests/test_file_io.cc b/ppapi/tests/test_file_io.cc
index ec547f1..9adb6e6 100644
--- a/ppapi/tests/test_file_io.cc
+++ b/ppapi/tests/test_file_io.cc
@@ -653,11 +653,11 @@ std::string TestFileIO::TestAbortCalls() {
callback.WaitForResult(rv);
CHECK_CALLBACK_BEHAVIOR(callback);
if (callback_type() == PP_BLOCKING) {
- ASSERT_EQ(callback.result(), PP_OK);
+ ASSERT_EQ(PP_OK, callback.result());
// The operation completed synchronously, so |info| should have changed.
ASSERT_NE(0, memcmp(&info_copy, &info, sizeof(info)));
} else {
- ASSERT_EQ(callback.result(), PP_ERROR_ABORTED);
+ ASSERT_EQ(PP_ERROR_ABORTED, callback.result());
ASSERT_EQ(0, memcmp(&info_copy, &info, sizeof(info)));
}
}
@@ -697,7 +697,7 @@ std::string TestFileIO::TestAbortCalls() {
if (callback_type() == PP_BLOCKING) {
ASSERT_EQ(callback.result(), sizeof(buf));
} else {
- ASSERT_EQ(callback.result(), PP_ERROR_ABORTED);
+ ASSERT_EQ(PP_ERROR_ABORTED, callback.result());
ASSERT_EQ(0, memcmp(&buf_copy, &buf, sizeof(buf)));
}
}
@@ -719,7 +719,7 @@ std::string TestFileIO::TestAbortCalls() {
if (callback_type() == PP_BLOCKING)
ASSERT_EQ(callback.result(), sizeof(buf));
else
- ASSERT_EQ(callback.result(), PP_ERROR_ABORTED);
+ ASSERT_EQ(PP_ERROR_ABORTED, callback.result());
}
// Abort |SetLength()|.
diff --git a/ppapi/tests/test_flash_clipboard.cc b/ppapi/tests/test_flash_clipboard.cc
index 8eb756b..c328269 100644
--- a/ppapi/tests/test_flash_clipboard.cc
+++ b/ppapi/tests/test_flash_clipboard.cc
@@ -173,7 +173,8 @@ std::string TestFlashClipboard::TestReadWriteCustomData() {
std::copy(custom_data.begin(), custom_data.end(), bytes);
uint32_t format_id =
pp::flash::Clipboard::RegisterCustomFormat(instance_, "my-format");
- ASSERT_NE(format_id, PP_FLASH_CLIPBOARD_FORMAT_INVALID);
+ ASSERT_NE(static_cast<uint32_t>(PP_FLASH_CLIPBOARD_FORMAT_INVALID),
+ format_id);
std::vector<uint32_t> formats_vector(1, format_id);
std::vector<pp::Var> data_vector(1, array_buffer);
@@ -254,15 +255,20 @@ std::string TestFlashClipboard::TestRegisterCustomFormat() {
// Test an empty name is rejected.
uint32_t format_id =
pp::flash::Clipboard::RegisterCustomFormat(instance_, std::string());
- ASSERT_EQ(format_id, PP_FLASH_CLIPBOARD_FORMAT_INVALID);
+ ASSERT_EQ(static_cast<uint32_t>(PP_FLASH_CLIPBOARD_FORMAT_INVALID),
+ format_id);
// Test a valid format name.
format_id = pp::flash::Clipboard::RegisterCustomFormat(instance_, "a-b");
- ASSERT_NE(format_id, PP_FLASH_CLIPBOARD_FORMAT_INVALID);
+ ASSERT_NE(static_cast<uint32_t>(PP_FLASH_CLIPBOARD_FORMAT_INVALID),
+ format_id);
// Make sure the format doesn't collide with predefined formats.
- ASSERT_NE(format_id, PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT);
- ASSERT_NE(format_id, PP_FLASH_CLIPBOARD_FORMAT_HTML);
- ASSERT_NE(format_id, PP_FLASH_CLIPBOARD_FORMAT_RTF);
+ ASSERT_NE(static_cast<uint32_t>(PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT),
+ format_id);
+ ASSERT_NE(static_cast<uint32_t>(PP_FLASH_CLIPBOARD_FORMAT_HTML),
+ format_id);
+ ASSERT_NE(static_cast<uint32_t>(PP_FLASH_CLIPBOARD_FORMAT_RTF),
+ format_id);
// Check that if the same name is registered, the same id comes out.
uint32_t format_id2 =
diff --git a/ppapi/tests/test_flash_file.cc b/ppapi/tests/test_flash_file.cc
index e5a8ee9..8e8db30 100644
--- a/ppapi/tests/test_flash_file.cc
+++ b/ppapi/tests/test_flash_file.cc
@@ -228,7 +228,7 @@ std::string TestFlashFile::TestCreateDir() {
ASSERT_FALSE(FileModuleLocal::QueryFile(instance_, dirname, &info));
ASSERT_TRUE(FileModuleLocal::CreateDir(instance_, dirname));
ASSERT_TRUE(FileModuleLocal::QueryFile(instance_, dirname, &info));
- ASSERT_EQ(info.type, PP_FILETYPE_DIRECTORY);
+ ASSERT_EQ(PP_FILETYPE_DIRECTORY, info.type);
PASS();
}
@@ -249,13 +249,13 @@ std::string TestFlashFile::TestQueryFile() {
CloseFileHandle(file_handle);
ASSERT_TRUE(FileModuleLocal::QueryFile(instance_, filename, &info));
ASSERT_EQ(static_cast<size_t>(info.size), contents.size());
- ASSERT_EQ(info.type, PP_FILETYPE_REGULAR);
+ ASSERT_EQ(PP_FILETYPE_REGULAR, info.type);
// TODO(raymes): Test the other fields.
// Test querying a directory.
ASSERT_TRUE(FileModuleLocal::CreateDir(instance_, dirname));
ASSERT_TRUE(FileModuleLocal::QueryFile(instance_, dirname, &info));
- ASSERT_EQ(info.type, PP_FILETYPE_DIRECTORY);
+ ASSERT_EQ(PP_FILETYPE_DIRECTORY, info.type);
// TODO(raymes): Test the other fields.
// Test querying a non-existent file.
@@ -269,7 +269,7 @@ std::string TestFlashFile::TestGetDirContents() {
std::vector<FileModuleLocal::DirEntry> result;
ASSERT_TRUE(FileModuleLocal::GetDirContents(instance_, std::string(),
&result));
- ASSERT_EQ(result.size(), 1);
+ ASSERT_EQ(1, result.size());
ASSERT_EQ(result[0].name, "..");
ASSERT_EQ(result[0].is_dir, true);
diff --git a/ppapi/tests/test_flash_message_loop.cc b/ppapi/tests/test_flash_message_loop.cc
index e5b7fe8..f5dd3b8a 100644
--- a/ppapi/tests/test_flash_message_loop.cc
+++ b/ppapi/tests/test_flash_message_loop.cc
@@ -40,7 +40,7 @@ std::string TestFlashMessageLoop::TestBasics() {
delete message_loop_;
message_loop_ = NULL;
- ASSERT_EQ(result, PP_OK);
+ ASSERT_EQ(PP_OK, result);
PASS();
}
@@ -58,7 +58,7 @@ std::string TestFlashMessageLoop::TestRunWithoutQuit() {
ASSERT_TRUE(false);
}
- ASSERT_EQ(result, PP_ERROR_ABORTED);
+ ASSERT_EQ(PP_ERROR_ABORTED, result);
PASS();
}
diff --git a/ppapi/tests/test_graphics_3d.cc b/ppapi/tests/test_graphics_3d.cc
index 6b26d45..ddf5512 100644
--- a/ppapi/tests/test_graphics_3d.cc
+++ b/ppapi/tests/test_graphics_3d.cc
@@ -59,7 +59,7 @@ std::string TestGraphics3D::TestFramePPAPI() {
return error;
int32_t rv = SwapBuffersSync(&context);
- ASSERT_EQ(rv, PP_OK);
+ ASSERT_EQ(PP_OK, rv);
PASS();
}
@@ -87,7 +87,7 @@ std::string TestGraphics3D::TestFrameGL() {
return error;
int32_t rv = SwapBuffersSync(&context);
- ASSERT_EQ(rv, PP_OK);
+ ASSERT_EQ(PP_OK, rv);
PASS();
}
@@ -111,13 +111,13 @@ std::string TestGraphics3D::TestExtensionsGL() {
// available, try a couple of trivial calls. This test is not intended
// to be exhaustive; check the source can compile, link, and run without
// crashing.
- ASSERT_NE(glGetString(GL_VERSION), NULL);
+ ASSERT_NE(NULL, glGetString(GL_VERSION));
const char* ext = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
if (strstr(ext, "GL_EXT_occlusion_query_boolean")) {
GLuint a_query;
GLboolean is_a_query;
glGenQueriesEXT(1, &a_query);
- ASSERT_NE(a_query, 0);
+ ASSERT_NE(0, a_query);
glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, a_query);
is_a_query = glIsQueryEXT(a_query);
ASSERT_EQ(is_a_query, GL_TRUE);
@@ -130,7 +130,7 @@ std::string TestGraphics3D::TestExtensionsGL() {
glSetCurrentContextPPAPI(kInvalidContext);
int32_t rv = SwapBuffersSync(&context);
- ASSERT_EQ(rv, PP_OK);
+ ASSERT_EQ(PP_OK, rv);
PASS();
}
diff --git a/ppapi/tests/test_net_address_private.cc b/ppapi/tests/test_net_address_private.cc
index a3474c2..00ba3da 100644
--- a/ppapi/tests/test_net_address_private.cc
+++ b/ppapi/tests/test_net_address_private.cc
@@ -306,12 +306,12 @@ std::string TestNetAddressPrivate::TestGetAddress() {
std::string TestNetAddressPrivate::TestGetScopeID() {
uint8_t localhost_ip[4] = { 127, 0, 0, 1 };
PP_NetAddress_Private ipv4 = MakeIPv4NetAddress(localhost_ip, 80);
- ASSERT_EQ(NetAddressPrivate::GetScopeID(ipv4), 0);
+ ASSERT_EQ(0, NetAddressPrivate::GetScopeID(ipv4));
uint16_t ipv6_address[8] = { 0x1234, 0xabcd, 0, 0, 0xff, 0, 0, 0xcdef };
PP_NetAddress_Private ipv6_123 = MakeIPv6NetAddress(ipv6_address, 0, 123);
- ASSERT_EQ(NetAddressPrivate::GetScopeID(ipv6_123), 123);
+ ASSERT_EQ(123, NetAddressPrivate::GetScopeID(ipv6_123));
PP_NetAddress_Private ipv6_max =
MakeIPv6NetAddress(ipv6_address, 0, 0xFFFFFFFF);
diff --git a/ppapi/tests/test_network_monitor.cc b/ppapi/tests/test_network_monitor.cc
index 53b6bb2..2d46f90 100644
--- a/ppapi/tests/test_network_monitor.cc
+++ b/ppapi/tests/test_network_monitor.cc
@@ -137,7 +137,7 @@ std::string TestNetworkMonitor::TestBasic() {
test_callback.WaitForResult(
network_monitor.UpdateNetworkList(test_callback.GetCallback()));
- ASSERT_EQ(test_callback.result(), PP_OK);
+ ASSERT_EQ(PP_OK, test_callback.result());
ASSERT_SUBTEST_SUCCESS(VerifyNetworkList(test_callback.output()));
PASS();
@@ -150,7 +150,7 @@ std::string TestNetworkMonitor::Test2Monitors() {
test_callback.WaitForResult(
network_monitor.UpdateNetworkList(test_callback.GetCallback()));
- ASSERT_EQ(test_callback.result(), PP_OK);
+ ASSERT_EQ(PP_OK, test_callback.result());
ASSERT_SUBTEST_SUCCESS(VerifyNetworkList(test_callback.output()));
TestCompletionCallbackWithOutput<pp::NetworkList> test_callback_2(
@@ -159,7 +159,7 @@ std::string TestNetworkMonitor::Test2Monitors() {
test_callback_2.WaitForResult(
network_monitor_2.UpdateNetworkList(test_callback_2.GetCallback()));
- ASSERT_EQ(test_callback_2.result(), PP_OK);
+ ASSERT_EQ(PP_OK, test_callback_2.result());
ASSERT_SUBTEST_SUCCESS(VerifyNetworkList(test_callback_2.output()));
PASS();
@@ -175,7 +175,7 @@ std::string TestNetworkMonitor::TestDeleteInCallback() {
test_callback.WaitForResult(
network_monitor->UpdateNetworkList(test_callback.GetCallback()));
- ASSERT_EQ(test_callback.result(), PP_OK);
+ ASSERT_EQ(PP_OK, test_callback.result());
ASSERT_SUBTEST_SUCCESS(VerifyNetworkList(test_callback.output()));
PASS();
diff --git a/ppapi/tests/test_pdf.cc b/ppapi/tests/test_pdf.cc
index dbfc803..cd08385 100644
--- a/ppapi/tests/test_pdf.cc
+++ b/ppapi/tests/test_pdf.cc
@@ -39,7 +39,7 @@ std::string TestPDF::TestGetResourceImage() {
for (int i = 0; i < data.size().width(); ++i) {
for (int j = 0; j < data.size().height(); ++j) {
pp::Point point(i, j);
- ASSERT_NE(*data.GetAddr32(point), 0);
+ ASSERT_NE(0, *data.GetAddr32(point));
}
}
PASS();
diff --git a/ppapi/tests/test_platform_verification_private.cc b/ppapi/tests/test_platform_verification_private.cc
index 978781a..0efa4c1 100644
--- a/ppapi/tests/test_platform_verification_private.cc
+++ b/ppapi/tests/test_platform_verification_private.cc
@@ -37,6 +37,6 @@ std::string TestPlatformVerificationPrivate::TestChallengePlatform() {
&signed_data_signature, &platform_key_certificate,
callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
- ASSERT_EQ(callback.result(), PP_ERROR_FAILED);
+ ASSERT_EQ(PP_ERROR_FAILED, callback.result());
PASS();
}
diff --git a/ppapi/tests/test_post_message.cc b/ppapi/tests/test_post_message.cc
index 5cd4200..83ae8a6 100644
--- a/ppapi/tests/test_post_message.cc
+++ b/ppapi/tests/test_post_message.cc
@@ -318,8 +318,8 @@ std::string TestPostMessage::CheckMessageProperties(
ASSERT_TRUE(AddEchoingListener(*iter));
message_data_.clear();
instance_->PostMessage(test_data);
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_bool());
if (!message_data_.back().AsBool())
return std::string("Failed: ") + *iter;
@@ -330,11 +330,11 @@ std::string TestPostMessage::CheckMessageProperties(
}
std::string TestPostMessage::TestSendInInit() {
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(1, WaitForMessages());
// This test assumes Init already sent a message.
- ASSERT_EQ(message_data_.size(), 1);
+ ASSERT_EQ(1, message_data_.size());
ASSERT_TRUE(message_data_.back().is_string());
- ASSERT_EQ(message_data_.back().AsString(), kTestString);
+ ASSERT_EQ(kTestString, message_data_.back().AsString());
message_data_.clear();
PASS();
}
@@ -354,43 +354,43 @@ std::string TestPostMessage::TestSendingData() {
message_data_.clear();
instance_->PostMessage(pp::Var(kTestString));
// PostMessage is asynchronous, so we should not receive a response yet.
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_string());
ASSERT_EQ(message_data_.back().AsString(), kTestString);
message_data_.clear();
instance_->PostMessage(pp::Var(kTestBool));
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_bool());
ASSERT_EQ(message_data_.back().AsBool(), kTestBool);
message_data_.clear();
instance_->PostMessage(pp::Var(kTestInt));
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_number());
- ASSERT_DOUBLE_EQ(message_data_.back().AsDouble(),
- static_cast<double>(kTestInt));
+ ASSERT_DOUBLE_EQ(static_cast<double>(kTestInt),
+ message_data_.back().AsDouble());
message_data_.clear();
instance_->PostMessage(pp::Var(kTestDouble));
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_number());
ASSERT_DOUBLE_EQ(message_data_.back().AsDouble(), kTestDouble);
message_data_.clear();
instance_->PostMessage(pp::Var());
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_undefined());
message_data_.clear();
instance_->PostMessage(pp::Var(pp::Var::Null()));
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_null());
message_data_.clear();
@@ -456,8 +456,8 @@ std::string TestPostMessage::TestSendingArrayBuffer() {
message_data_.clear();
instance_->PostMessage(test_data);
// PostMessage is asynchronous, so we should not receive a response yet.
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_array_buffer());
pp::VarArrayBuffer received(message_data_.back());
message_data_.clear();
@@ -510,8 +510,8 @@ std::string TestPostMessage::TestSendingArray() {
message_data_.clear();
instance_->PostMessage(array);
// PostMessage is asynchronous, so we should not receive a response yet.
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_array());
ASSERT_TRUE(VarsEqual(array, message_data_.back()));
@@ -554,8 +554,8 @@ std::string TestPostMessage::TestSendingDictionary() {
message_data_.clear();
instance_->PostMessage(dictionary);
// PostMessage is asynchronous, so we should not receive a response yet.
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_dictionary());
ASSERT_TRUE(VarsEqual(dictionary, message_data_.back()));
@@ -577,7 +577,7 @@ std::string TestPostMessage::TestSendingResource() {
// This opens a real (temporary) file using the HTML5 FileSystem API and
// writes to it.
ASSERT_TRUE(AddEchoingListener("message_event.data"));
- ASSERT_EQ(message_data_.size(), 0);
+ ASSERT_EQ(0, message_data_.size());
std::string js_code =
"function(callback) {"
" window.webkitRequestFileSystem(window.TEMPORARY, 1024,"
@@ -677,8 +677,8 @@ std::string TestPostMessage::TestSendingComplexVar() {
ASSERT_TRUE(AddEchoingListener("message_event.data"));
instance_->PostMessage(dictionary);
// PostMessage is asynchronous, so we should not receive a response yet.
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_dictionary());
pp::VarDictionary result(message_data_.back());
ASSERT_TRUE(VarsEqual(dictionary, message_data_.back()));
@@ -696,7 +696,7 @@ std::string TestPostMessage::TestSendingComplexVar() {
ASSERT_TRUE(AddEchoingListener("message_event.data"));
instance_->PostMessage(dictionary);
// PostMessage is asynchronous, so we should not receive a response yet.
- ASSERT_EQ(message_data_.size(), 0);
+ ASSERT_EQ(0, message_data_.size());
ASSERT_EQ(WaitForMessages(), 0);
// Break the cycles.
@@ -709,7 +709,7 @@ std::string TestPostMessage::TestSendingComplexVar() {
// Test sending a cycle from JavaScript to the plugin.
ASSERT_TRUE(AddEchoingListener("message_event.data"));
PostMessageFromJavaScript("function() { var x = []; x[0] = x; return x; }");
- ASSERT_EQ(message_data_.size(), 0);
+ ASSERT_EQ(0, message_data_.size());
ASSERT_EQ(WaitForMessages(), 0);
WaitForMessages();
@@ -730,8 +730,8 @@ std::string TestPostMessage::TestMessageEvent() {
ASSERT_TRUE(AddEchoingListener("message_event.constructor.name"));
message_data_.clear();
instance_->PostMessage(pp::Var(kTestInt));
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_string());
ASSERT_EQ(message_data_.back().AsString(), "MessageEvent");
ASSERT_TRUE(ClearListeners());
@@ -747,8 +747,8 @@ std::string TestPostMessage::TestMessageEvent() {
ASSERT_TRUE(success);
message_data_.clear();
instance_->PostMessage(pp::Var(kTestInt));
- ASSERT_EQ(message_data_.size(), 0);
- ASSERT_EQ(WaitForMessages(), 1);
+ ASSERT_EQ(0, message_data_.size());
+ ASSERT_EQ(1, WaitForMessages());
ASSERT_TRUE(message_data_.back().is_bool());
ASSERT_TRUE(message_data_.back().AsBool());
ASSERT_TRUE(ClearListeners());
@@ -761,7 +761,7 @@ std::string TestPostMessage::TestMessageEvent() {
message_data_.clear();
instance_->PostMessage(pp::Var(kTestInt));
// Make sure we don't get a response in a re-entrant fashion.
- ASSERT_EQ(message_data_.size(), 0);
+ ASSERT_EQ(0, message_data_.size());
// We should get 3 messages.
ASSERT_EQ(WaitForMessages(), 3);
// Copy to a vector of doubles and sort; w3c does not specify the order for
@@ -844,7 +844,7 @@ std::string TestPostMessage::TestNonMainThread() {
PP_JoinThread(threads[i]);
// PostMessage is asynchronous, so we should not receive a response yet.
- ASSERT_EQ(message_data_.size(), 0);
+ ASSERT_EQ(0, message_data_.size());
// Make sure we got all values that we expected. Note that because it's legal
// for the JavaScript engine to treat our integers as floating points, we
@@ -855,7 +855,7 @@ std::string TestPostMessage::TestNonMainThread() {
std::vector<int32_t> expected_counts(kThreadsToRun + 1,
kMessagesToSendPerThread);
std::vector<int32_t> received_counts(kThreadsToRun + 1, 0);
- ASSERT_EQ(WaitForMessages(), expected_num);
+ ASSERT_EQ(expected_num, WaitForMessages());
for (int32_t i = 0; i < expected_num; ++i) {
const pp::Var& latest_var(message_data_[i]);
ASSERT_TRUE(latest_var.is_int() || latest_var.is_double());
@@ -869,7 +869,7 @@ std::string TestPostMessage::TestNonMainThread() {
ASSERT_TRUE(received_value <= kThreadsToRun);
++received_counts[received_value];
}
- ASSERT_EQ(received_counts, expected_counts);
+ ASSERT_EQ(expected_counts, received_counts);
message_data_.clear();
ASSERT_TRUE(ClearListeners());
diff --git a/ppapi/tests/test_test_internals.cc b/ppapi/tests/test_test_internals.cc
new file mode 100644
index 0000000..7f78ca4
--- /dev/null
+++ b/ppapi/tests/test_test_internals.cc
@@ -0,0 +1,277 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/tests/test_test_internals.h"
+
+#include <vector>
+
+namespace {
+
+std::string CheckEqual(const std::string& expected, const std::string& actual) {
+ if (expected != actual) {
+ return std::string("Expected : \"") + expected + "\", got : \"" + actual +
+ "\"";
+ }
+ PASS();
+}
+
+std::string Negate(const std::string& result) {
+ if (result.empty())
+ return std::string("FAIL: String was empty.");
+ return std::string();
+}
+
+class CallCounter {
+ public:
+ CallCounter() : num_calls_(0) {}
+
+ int return_zero() {
+ ++num_calls_;
+ return 0;
+ }
+ double return_zero_as_double() {
+ ++num_calls_;
+ return 0.0;
+ }
+
+ int num_calls() const { return num_calls_; }
+
+ private:
+ int num_calls_;
+};
+
+}
+
+REGISTER_TEST_CASE(TestInternals);
+
+bool TestTestInternals::Init() {
+ return true;
+}
+
+void TestTestInternals::RunTests(const std::string& filter) {
+ RUN_TEST(ToString, filter);
+ RUN_TEST(PassingComparisons, filter);
+ RUN_TEST(FailingComparisons, filter);
+ RUN_TEST(EvaluateOnce, filter);
+}
+
+#define WRAP_LEFT_PARAM(a) \
+ internal::ParameterWrapper<IS_NULL_LITERAL(a)>::WrapValue(a)
+std::string TestTestInternals::TestToString() {
+ // We don't use most ASSERT macros here, because they rely on ToString.
+ // ASSERT_SUBTEST_SUCCESS does not use ToString.
+ ASSERT_SUBTEST_SUCCESS(CheckEqual(WRAP_LEFT_PARAM(NULL).ToString(), "0"));
+ ASSERT_SUBTEST_SUCCESS(CheckEqual(WRAP_LEFT_PARAM(0).ToString(), "0"));
+ ASSERT_SUBTEST_SUCCESS(CheckEqual(internal::ToString(5), "5"));
+ int32_t x = 5;
+ ASSERT_SUBTEST_SUCCESS(CheckEqual(internal::ToString(x + 1), "6"));
+ std::string str = "blah";
+ ASSERT_SUBTEST_SUCCESS(CheckEqual(internal::ToString(str + "blah"),
+ "blahblah"));
+ std::vector<int> vec;
+ ASSERT_SUBTEST_SUCCESS(CheckEqual(internal::ToString(vec), std::string()));
+
+ PASS();
+}
+
+#define COMPARE_DOUBLE_EQ(a, b) \
+ internal::CompareDoubleEq( \
+ internal::ParameterWrapper<IS_NULL_LITERAL(a)>::WrapValue(a), \
+ (b), #a, #b, __FILE__, __LINE__)
+std::string TestTestInternals::TestPassingComparisons() {
+ // These comparisons should all "pass", meaning they should return the empty
+ // string.
+ {
+ const std::string* const kNull = NULL;
+ const std::string* const kDeadBeef =
+ reinterpret_cast<const std::string*>(0xdeadbeef);
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(EQ, NULL, kNull));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(EQ, kDeadBeef, kDeadBeef));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(NE, NULL, kDeadBeef));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(NE, kDeadBeef, kNull));
+ } {
+ const int64_t zero_int32 = 0;
+ const int64_t zero_int64 = 0;
+ const int32_t zero_uint32 = 0;
+ const int64_t zero_uint64 = 0;
+ const int32_t one_int32 = 1;
+ const int64_t one_int64 = 1;
+ const int32_t one_uint32 = 1;
+ const int64_t one_uint64 = 1;
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(EQ, 0, zero_int32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(EQ, 0, zero_int64));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(EQ, 0, zero_uint32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(EQ, 0, zero_uint64));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(EQ, 1, one_int32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(EQ, 1, one_int64));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(EQ, 1, one_uint32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(EQ, 1, one_uint64));
+
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(NE, 1, zero_int32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(NE, 1, zero_int64));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(NE, 1, zero_uint32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(NE, 1, zero_uint64));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(NE, 0, one_int32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(NE, 0, one_int64));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(NE, 0, one_uint32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(NE, 0, one_uint64));
+
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(LT, 0, one_int32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(LT, 0, one_uint32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(LT, 0, one_int64));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(LT, 0, one_uint64));
+
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(LE, 0, zero_int32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(LE, 0, zero_uint32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(LE, 0, zero_int64));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(LE, 0, zero_uint64));
+
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(LE, 0, one_int32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(LE, 0, one_uint32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(LE, 0, one_int64));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(LE, 0, one_uint64));
+
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(GT, 1, zero_int32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(GT, 1, zero_uint32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(GT, 1, zero_int64));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(GT, 1, zero_uint64));
+
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(GE, 1, zero_int32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(GE, 1, zero_uint32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(GE, 1, zero_int64));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(GE, 1, zero_uint64));
+
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(GE, 1, one_int32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(GE, 1, one_uint32));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(GE, 1, one_int64));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_BINARY_INTERNAL(GE, 1, one_uint64));
+ } {
+ ASSERT_SUBTEST_SUCCESS(
+ COMPARE_BINARY_INTERNAL(EQ, "hello", std::string("hello")));
+ std::vector<int> int_vector1(10, 10);
+ std::vector<int> int_vector2(int_vector1);
+ ASSERT_SUBTEST_SUCCESS(
+ COMPARE_BINARY_INTERNAL(EQ, int_vector1, int_vector2));
+ } {
+ const double kZeroDouble = 0.0;
+ const double kPositiveDouble = 1.1;
+ ASSERT_SUBTEST_SUCCESS(
+ COMPARE_BINARY_INTERNAL(LT, kZeroDouble, kPositiveDouble));
+ ASSERT_SUBTEST_SUCCESS(
+ COMPARE_BINARY_INTERNAL(GT, kPositiveDouble, kZeroDouble));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_DOUBLE_EQ(0.0, kZeroDouble));
+ ASSERT_SUBTEST_SUCCESS(COMPARE_DOUBLE_EQ(1.0 + 0.1, kPositiveDouble));
+ }
+
+ // TODO: Things that return non-empty string.
+ // TODO: Test that the parameter is evaluated exactly once.
+ PASS();
+}
+
+#define ASSERT_SUBTEST_FAILURE(param) ASSERT_SUBTEST_SUCCESS(Negate(param))
+std::string TestTestInternals::TestFailingComparisons() {
+ // Note, we don't really worry about the content of failure strings here.
+ // That's mostly covered by the ToString test above. This test just makes
+ // sure that comparisons which should return a non-empty string do so.
+ {
+ const std::string* const kNull = NULL;
+ const std::string* const kDeadBeef =
+ reinterpret_cast<const std::string*>(0xdeadbeef);
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(NE, NULL, kNull));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(NE, kDeadBeef, kDeadBeef));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(EQ, NULL, kDeadBeef));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(EQ, kDeadBeef, kNull));
+ }
+
+ // Now, just make sure we get any non-empty string at all, which will indicate
+ // test failure. We mostly rely on the ToString test to get the formats right.
+ {
+ const int64_t zero_int32 = 0;
+ const int64_t zero_int64 = 0;
+ const int32_t zero_uint32 = 0;
+ const int64_t zero_uint64 = 0;
+ const int32_t one_int32 = 1;
+ const int64_t one_int64 = 1;
+ const int32_t one_uint32 = 1;
+ const int64_t one_uint64 = 1;
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(EQ, 1, zero_int32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(EQ, 1, zero_int64));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(EQ, 1, zero_uint32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(EQ, 1, zero_uint64));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(EQ, 0, one_int32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(EQ, 0, one_int64));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(EQ, 0, one_uint32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(EQ, 0, one_uint64));
+
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(NE, 0, zero_int32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(NE, 0, zero_int64));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(NE, 0, zero_uint32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(NE, 0, zero_uint64));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(NE, 1, one_int32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(NE, 1, one_int64));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(NE, 1, one_uint32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(NE, 1, one_uint64));
+
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(LT, 1, one_int32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(LT, 1, one_uint32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(LT, 1, one_int64));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(LT, 1, one_uint64));
+
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(LE, 1, zero_int32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(LE, 1, zero_uint32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(LE, 1, zero_int64));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(LE, 1, zero_uint64));
+
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(GT, 0, zero_int32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(GT, 0, zero_uint32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(GT, 0, zero_int64));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(GT, 0, zero_uint64));
+
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(GE, 0, one_int32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(GE, 0, one_uint32));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(GE, 0, one_int64));
+ ASSERT_SUBTEST_FAILURE(COMPARE_BINARY_INTERNAL(GE, 0, one_uint64));
+ } {
+ ASSERT_SUBTEST_FAILURE(
+ COMPARE_BINARY_INTERNAL(EQ, "goodbye", std::string("hello")));
+ std::vector<int> int_vector1(10, 10);
+ std::vector<int> int_vector2;
+ ASSERT_SUBTEST_FAILURE(
+ COMPARE_BINARY_INTERNAL(EQ, int_vector1, int_vector2));
+ } {
+ const double kZeroDouble = 0.0;
+ const double kPositiveDouble = 1.1;
+ ASSERT_SUBTEST_FAILURE(
+ COMPARE_BINARY_INTERNAL(GT, kZeroDouble, kPositiveDouble));
+ ASSERT_SUBTEST_FAILURE(
+ COMPARE_BINARY_INTERNAL(LT, kPositiveDouble, kZeroDouble));
+ ASSERT_SUBTEST_FAILURE(COMPARE_DOUBLE_EQ(1.1, kZeroDouble));
+ ASSERT_SUBTEST_FAILURE(COMPARE_DOUBLE_EQ(0.0, kPositiveDouble));
+ }
+
+ // TODO: Test that the parameter is evaluated exactly once.
+ PASS();
+}
+#undef COMPARE
+#undef COMPARE_DOUBLE_EQ
+
+std::string TestTestInternals::TestEvaluateOnce() {
+ // Make sure that the ASSERT macros only evaluate each parameter once.
+ {
+ CallCounter call_counter1;
+ CallCounter call_counter2;
+ ASSERT_EQ(call_counter1.return_zero(), call_counter2.return_zero());
+ assert(call_counter1.num_calls() == 1);
+ assert(call_counter2.num_calls() == 1);
+ } {
+ CallCounter call_counter1;
+ CallCounter call_counter2;
+ ASSERT_DOUBLE_EQ(call_counter1.return_zero_as_double(),
+ call_counter2.return_zero_as_double());
+ assert(call_counter1.num_calls() == 1);
+ assert(call_counter2.num_calls() == 1);
+ }
+ PASS();
+}
+
diff --git a/ppapi/tests/test_test_internals.h b/ppapi/tests/test_test_internals.h
new file mode 100644
index 0000000..7e72ae3
--- /dev/null
+++ b/ppapi/tests/test_test_internals.h
@@ -0,0 +1,28 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_TESTS_TEST_TEST_INTERNALS_H_
+#define PPAPI_TESTS_TEST_TEST_INTERNALS_H_
+
+#include <string>
+
+#include "ppapi/tests/test_case.h"
+
+// This class is for testing the test framework itself.
+class TestTestInternals : public TestCase {
+ public:
+ explicit TestTestInternals(TestingInstance* instance) : TestCase(instance) {}
+
+ private:
+ // TestCase implementation.
+ virtual bool Init();
+ virtual void RunTests(const std::string& filter);
+
+ std::string TestToString();
+ std::string TestPassingComparisons();
+ std::string TestFailingComparisons();
+ std::string TestEvaluateOnce();
+};
+
+#endif // PPAPI_TESTS_TEST_TEST_INTERNALS_H_
diff --git a/ppapi/tests/test_url_loader.cc b/ppapi/tests/test_url_loader.cc
index 835588e..4bf2f6c 100644
--- a/ppapi/tests/test_url_loader.cc
+++ b/ppapi/tests/test_url_loader.cc
@@ -578,40 +578,38 @@ std::string TestURLLoader::TestUntrustedHttpRequests() {
// valid token (containing special characters like CR, LF).
// http://www.w3.org/TR/XMLHttpRequest/
{
- ASSERT_EQ(OpenUntrusted("cOnNeCt", std::string()), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("tRaCk", std::string()), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("tRaCe", std::string()), PP_ERROR_NOACCESS);
- ASSERT_EQ(
- OpenUntrusted("POST\x0d\x0ax-csrf-token:\x20test1234", std::string()),
- PP_ERROR_NOACCESS);
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("cOnNeCt", std::string()));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("tRaCk", std::string()));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("tRaCe", std::string()));
+ ASSERT_EQ(PP_ERROR_NOACCESS,
+ OpenUntrusted("POST\x0d\x0ax-csrf-token:\x20test1234", std::string()));
}
// HTTP methods are restricted only for untrusted loaders. Try all headers
// that are forbidden by http://www.w3.org/TR/XMLHttpRequest/.
{
- ASSERT_EQ(OpenUntrusted("GET", "Accept-Charset:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Accept-Encoding:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Connection:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Content-Length:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Cookie:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Cookie2:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted(
- "GET", "Content-Transfer-Encoding:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Date:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Expect:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Host:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Keep-Alive:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Referer:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "TE:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Trailer:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted(
- "GET", "Transfer-Encoding:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Upgrade:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "User-Agent:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Via:\n"), PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted(
- "GET", "Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==:\n"),
- PP_ERROR_NOACCESS);
- ASSERT_EQ(OpenUntrusted("GET", "Sec-foo:\n"), PP_ERROR_NOACCESS);
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Accept-Charset:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Accept-Encoding:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Connection:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Content-Length:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Cookie:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Cookie2:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS,
+ OpenUntrusted("GET", "Content-Transfer-Encoding:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Date:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Expect:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Host:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Keep-Alive:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Referer:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "TE:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Trailer:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS,
+ OpenUntrusted("GET", "Transfer-Encoding:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Upgrade:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "User-Agent:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Via:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted(
+ "GET", "Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==:\n"));
+ ASSERT_EQ(PP_ERROR_NOACCESS, OpenUntrusted("GET", "Sec-foo:\n"));
}
// Untrusted requests with custom referrer should fail.
{
@@ -640,34 +638,34 @@ std::string TestURLLoader::TestUntrustedHttpRequests() {
std::string TestURLLoader::TestTrustedHttpRequests() {
// Trusted requests can use restricted methods.
{
- ASSERT_EQ(OpenTrusted("cOnNeCt", std::string()), PP_OK);
- ASSERT_EQ(OpenTrusted("tRaCk", std::string()), PP_OK);
- ASSERT_EQ(OpenTrusted("tRaCe", std::string()), PP_OK);
+ ASSERT_EQ(PP_OK, OpenTrusted("cOnNeCt", std::string()));
+ ASSERT_EQ(PP_OK, OpenTrusted("tRaCk", std::string()));
+ ASSERT_EQ(PP_OK, OpenTrusted("tRaCe", std::string()));
}
// Trusted requests can use restricted headers.
{
- ASSERT_EQ(OpenTrusted("GET", "Accept-Charset:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Accept-Encoding:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Connection:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Content-Length:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Cookie:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Cookie2:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted(
- "GET", "Content-Transfer-Encoding:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Date:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Expect:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Host:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Keep-Alive:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Referer:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "TE:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Trailer:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Transfer-Encoding:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Upgrade:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "User-Agent:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Via:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted(
- "GET", "Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==:\n"), PP_OK);
- ASSERT_EQ(OpenTrusted("GET", "Sec-foo:\n"), PP_OK);
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Accept-Charset:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Accept-Encoding:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Connection:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Content-Length:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Cookie:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Cookie2:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Content-Transfer-Encoding:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Date:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Expect:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Host:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Keep-Alive:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Referer:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "TE:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Trailer:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Transfer-Encoding:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Upgrade:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "User-Agent:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Via:\n"));
+ ASSERT_EQ(PP_OK,
+ OpenTrusted("GET",
+ "Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==:\n"));
+ ASSERT_EQ(PP_OK, OpenTrusted("GET", "Sec-foo:\n"));
}
// Trusted requests with custom referrer should succeed.
{
diff --git a/ppapi/tests/test_websocket.cc b/ppapi/tests/test_websocket.cc
index d22da37..0e1a0ad 100644
--- a/ppapi/tests/test_websocket.cc
+++ b/ppapi/tests/test_websocket.cc
@@ -1164,7 +1164,7 @@ std::string TestWebSocket::TestCcInterfaces() {
ASSERT_EQ(0, ws.GetBufferedAmount());
ASSERT_EQ(0, ws.GetCloseCode());
ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), std::string()));
- ASSERT_EQ(false, ws.GetCloseWasClean());
+ ASSERT_FALSE(ws.GetCloseWasClean());
ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), std::string()));
ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), std::string()));
ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID, ws.GetReadyState());