TestSyncError.cpp (1273B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 /* 8 * Test what happens when a sync message fails. 9 */ 10 11 #include "gtest/gtest.h" 12 13 #include "mozilla/_ipdltest/IPDLUnitTest.h" 14 #include "mozilla/_ipdltest/PTestSyncErrorChild.h" 15 #include "mozilla/_ipdltest/PTestSyncErrorParent.h" 16 17 using namespace mozilla::ipc; 18 19 namespace mozilla::_ipdltest { 20 21 class TestSyncErrorParent : public PTestSyncErrorParent { 22 NS_INLINE_DECL_REFCOUNTING(TestSyncErrorParent, override) 23 private: 24 IPCResult RecvError() final override { return IPC_TEST_FAIL(this); } 25 26 ~TestSyncErrorParent() = default; 27 }; 28 29 class TestSyncErrorChild : public PTestSyncErrorChild { 30 NS_INLINE_DECL_REFCOUNTING(TestSyncErrorChild, override) 31 private: 32 IPCResult RecvStart() final override { 33 EXPECT_FALSE(SendError()) << "Error() should have return false"; 34 35 Close(); 36 37 return IPC_OK(); 38 } 39 ~TestSyncErrorChild() = default; 40 }; 41 42 IPDL_TEST(TestSyncError) { EXPECT_TRUE(mActor->SendStart()); } 43 44 } // namespace mozilla::_ipdltest