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

Unified Diff: mojo/common/test/multiprocess_test_helper_unittest.cc

Issue 194593007: Mojo: MultiprocessTestHelper: Allow {ASSERT,EXPECT}_...() to be used in child. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fix Created 6 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 | « mojo/common/test/multiprocess_test_helper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/common/test/multiprocess_test_helper_unittest.cc
diff --git a/mojo/common/test/multiprocess_test_helper_unittest.cc b/mojo/common/test/multiprocess_test_helper_unittest.cc
index a61ac22819108a1f2eb63402ad9fb9d500d9cdf2..6df1e077237ed65a5ce71e83b144df9e2f719c78 100644
--- a/mojo/common/test/multiprocess_test_helper_unittest.cc
+++ b/mojo/common/test/multiprocess_test_helper_unittest.cc
@@ -14,26 +14,10 @@
#include <fcntl.h>
#endif
-#if defined(OS_WIN)
-#include "base/win/windows_version.h"
-#endif
-
namespace mojo {
namespace test {
namespace {
-// Returns true and logs a warning on Windows prior to Vista.
-bool SkipTest() {
-#if defined(OS_WIN)
- if (base::win::GetVersion() < base::win::VERSION_VISTA) {
- LOG(WARNING) << "Test skipped: Vista or later needed.";
- return true;
- }
-#endif
-
- return false;
-}
-
bool IsNonBlocking(const embedder::PlatformHandle& handle) {
#if defined(OS_WIN)
// Haven't figured out a way to query whether a HANDLE was created with
@@ -59,9 +43,6 @@ bool ReadByte(const embedder::PlatformHandle& handle, char* c) {
typedef testing::Test MultiprocessTestHelperTest;
TEST_F(MultiprocessTestHelperTest, RunChild) {
- if (SkipTest())
- return;
-
MultiprocessTestHelper helper;
EXPECT_TRUE(helper.server_platform_handle.is_valid());
@@ -75,9 +56,6 @@ MOJO_MULTIPROCESS_TEST_CHILD_MAIN(RunChild) {
}
TEST_F(MultiprocessTestHelperTest, TestChildMainNotFound) {
- if (SkipTest())
- return;
-
MultiprocessTestHelper helper;
helper.StartChild("NoSuchTestChildMain");
int result = helper.WaitForChildShutdown();
@@ -85,9 +63,6 @@ TEST_F(MultiprocessTestHelperTest, TestChildMainNotFound) {
}
TEST_F(MultiprocessTestHelperTest, PassedChannel) {
- if (SkipTest())
- return;
-
MultiprocessTestHelper helper;
EXPECT_TRUE(helper.server_platform_handle.is_valid());
helper.StartChild("PassedChannel");
@@ -134,6 +109,49 @@ MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PassedChannel) {
return static_cast<int>(c);
}
+TEST_F(MultiprocessTestHelperTest, ChildTestPasses) {
+ MultiprocessTestHelper helper;
+ EXPECT_TRUE(helper.server_platform_handle.is_valid());
+ helper.StartChild("ChildTestPasses");
+ EXPECT_TRUE(helper.WaitForChildTestShutdown());
+}
+
+MOJO_MULTIPROCESS_TEST_CHILD_TEST(ChildTestPasses) {
+ ASSERT_TRUE(MultiprocessTestHelper::client_platform_handle.is_valid());
+ EXPECT_TRUE(IsNonBlocking(
+ MultiprocessTestHelper::client_platform_handle.get()));
+}
+
+TEST_F(MultiprocessTestHelperTest, ChildTestFailsAssert) {
+ MultiprocessTestHelper helper;
+ EXPECT_TRUE(helper.server_platform_handle.is_valid());
+ helper.StartChild("ChildTestFailsAssert");
+ EXPECT_FALSE(helper.WaitForChildTestShutdown());
+}
+
+MOJO_MULTIPROCESS_TEST_CHILD_TEST(ChildTestFailsAssert) {
+ ASSERT_FALSE(MultiprocessTestHelper::client_platform_handle.is_valid())
+ << "DISREGARD: Expected failure in child process";
+ ASSERT_FALSE(IsNonBlocking(
+ MultiprocessTestHelper::client_platform_handle.get())) << "Not reached";
+ CHECK(false) << "Not reached";
+}
+
+TEST_F(MultiprocessTestHelperTest, ChildTestFailsExpect) {
+ MultiprocessTestHelper helper;
+ EXPECT_TRUE(helper.server_platform_handle.is_valid());
+ helper.StartChild("ChildTestFailsExpect");
+ EXPECT_FALSE(helper.WaitForChildTestShutdown());
+}
+
+MOJO_MULTIPROCESS_TEST_CHILD_TEST(ChildTestFailsExpect) {
+ EXPECT_FALSE(MultiprocessTestHelper::client_platform_handle.is_valid())
+ << "DISREGARD: Expected failure #1 in child process";
+ EXPECT_FALSE(IsNonBlocking(
+ MultiprocessTestHelper::client_platform_handle.get()))
+ << "DISREGARD: Expected failure #2 in child process";
+}
+
} // namespace
} // namespace test
} // namespace mojo
« no previous file with comments | « mojo/common/test/multiprocess_test_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698