Loading libs/binder/tests/binderLibTest.cpp +5 −12 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ #include <gtest/gtest.h> #include <gtest/gtest.h> #include <android-base/properties.h> #include <android-base/properties.h> #include <android-base/result-gmock.h> #include <android-base/result.h> #include <android-base/result.h> #include <android-base/unique_fd.h> #include <android-base/unique_fd.h> #include <binder/Binder.h> #include <binder/Binder.h> Loading @@ -52,6 +53,7 @@ using namespace android; using namespace android; using namespace std::string_literals; using namespace std::string_literals; using namespace std::chrono_literals; using namespace std::chrono_literals; using android::base::testing::HasValue; using testing::ExplainMatchResult; using testing::ExplainMatchResult; using testing::Not; using testing::Not; using testing::WithParamInterface; using testing::WithParamInterface; Loading @@ -62,15 +64,6 @@ MATCHER_P(StatusEq, expected, (negation ? "not " : "") + statusToString(expected return expected == arg; return expected == arg; } } // e.g. Result<int32_t> v = 0; EXPECT_THAT(result, ResultHasValue(0)); MATCHER_P(ResultHasValue, resultMatcher, "") { if (!arg.ok()) { *result_listener << "contains error " << arg.error(); return false; } return ExplainMatchResult(resultMatcher, arg.value(), result_listener); } static ::testing::AssertionResult IsPageAligned(void *buf) { static ::testing::AssertionResult IsPageAligned(void *buf) { if (((unsigned long)buf & ((unsigned long)PAGE_SIZE - 1)) == 0) if (((unsigned long)buf & ((unsigned long)PAGE_SIZE - 1)) == 0) return ::testing::AssertionSuccess(); return ::testing::AssertionSuccess(); Loading Loading @@ -522,7 +515,7 @@ TEST_F(BinderLibTest, SetError) { } } TEST_F(BinderLibTest, GetId) { TEST_F(BinderLibTest, GetId) { EXPECT_THAT(GetId(m_server), ResultHasValue(0)); EXPECT_THAT(GetId(m_server), HasValue(0)); } } TEST_F(BinderLibTest, PtrSize) { TEST_F(BinderLibTest, PtrSize) { Loading Loading @@ -1287,7 +1280,7 @@ TEST_P(BinderLibRpcClientTest, Test) { sp<IBinder> server = isRemote ? sp<IBinder>(CreateRemoteService(id)) sp<IBinder> server = isRemote ? sp<IBinder>(CreateRemoteService(id)) : sp<IBinder>(sp<BinderLibTestService>::make(id, false)); : sp<IBinder>(sp<BinderLibTestService>::make(id, false)); ASSERT_EQ(isRemote, !!server->remoteBinder()); ASSERT_EQ(isRemote, !!server->remoteBinder()); ASSERT_THAT(GetId(server), ResultHasValue(id)); ASSERT_THAT(GetId(server), HasValue(id)); unsigned int port = 0; unsigned int port = 0; // Fake servicedispatcher. // Fake servicedispatcher. Loading Loading @@ -1317,7 +1310,7 @@ TEST_P(BinderLibRpcClientTest, Test) { EXPECT_EQ(OK, rpcServerBinder->pingBinder()); EXPECT_EQ(OK, rpcServerBinder->pingBinder()); // Check that |rpcServerBinder| and |server| points to the same service. // Check that |rpcServerBinder| and |server| points to the same service. EXPECT_THAT(GetId(rpcServerBinder), ResultHasValue(id)); EXPECT_THAT(GetId(rpcServerBinder), HasValue(id)); // Occupy the server thread. The server should still have enough threads to handle // Occupy the server thread. The server should still have enough threads to handle // other connections. // other connections. Loading Loading
libs/binder/tests/binderLibTest.cpp +5 −12 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ #include <gtest/gtest.h> #include <gtest/gtest.h> #include <android-base/properties.h> #include <android-base/properties.h> #include <android-base/result-gmock.h> #include <android-base/result.h> #include <android-base/result.h> #include <android-base/unique_fd.h> #include <android-base/unique_fd.h> #include <binder/Binder.h> #include <binder/Binder.h> Loading @@ -52,6 +53,7 @@ using namespace android; using namespace android; using namespace std::string_literals; using namespace std::string_literals; using namespace std::chrono_literals; using namespace std::chrono_literals; using android::base::testing::HasValue; using testing::ExplainMatchResult; using testing::ExplainMatchResult; using testing::Not; using testing::Not; using testing::WithParamInterface; using testing::WithParamInterface; Loading @@ -62,15 +64,6 @@ MATCHER_P(StatusEq, expected, (negation ? "not " : "") + statusToString(expected return expected == arg; return expected == arg; } } // e.g. Result<int32_t> v = 0; EXPECT_THAT(result, ResultHasValue(0)); MATCHER_P(ResultHasValue, resultMatcher, "") { if (!arg.ok()) { *result_listener << "contains error " << arg.error(); return false; } return ExplainMatchResult(resultMatcher, arg.value(), result_listener); } static ::testing::AssertionResult IsPageAligned(void *buf) { static ::testing::AssertionResult IsPageAligned(void *buf) { if (((unsigned long)buf & ((unsigned long)PAGE_SIZE - 1)) == 0) if (((unsigned long)buf & ((unsigned long)PAGE_SIZE - 1)) == 0) return ::testing::AssertionSuccess(); return ::testing::AssertionSuccess(); Loading Loading @@ -522,7 +515,7 @@ TEST_F(BinderLibTest, SetError) { } } TEST_F(BinderLibTest, GetId) { TEST_F(BinderLibTest, GetId) { EXPECT_THAT(GetId(m_server), ResultHasValue(0)); EXPECT_THAT(GetId(m_server), HasValue(0)); } } TEST_F(BinderLibTest, PtrSize) { TEST_F(BinderLibTest, PtrSize) { Loading Loading @@ -1287,7 +1280,7 @@ TEST_P(BinderLibRpcClientTest, Test) { sp<IBinder> server = isRemote ? sp<IBinder>(CreateRemoteService(id)) sp<IBinder> server = isRemote ? sp<IBinder>(CreateRemoteService(id)) : sp<IBinder>(sp<BinderLibTestService>::make(id, false)); : sp<IBinder>(sp<BinderLibTestService>::make(id, false)); ASSERT_EQ(isRemote, !!server->remoteBinder()); ASSERT_EQ(isRemote, !!server->remoteBinder()); ASSERT_THAT(GetId(server), ResultHasValue(id)); ASSERT_THAT(GetId(server), HasValue(id)); unsigned int port = 0; unsigned int port = 0; // Fake servicedispatcher. // Fake servicedispatcher. Loading Loading @@ -1317,7 +1310,7 @@ TEST_P(BinderLibRpcClientTest, Test) { EXPECT_EQ(OK, rpcServerBinder->pingBinder()); EXPECT_EQ(OK, rpcServerBinder->pingBinder()); // Check that |rpcServerBinder| and |server| points to the same service. // Check that |rpcServerBinder| and |server| points to the same service. EXPECT_THAT(GetId(rpcServerBinder), ResultHasValue(id)); EXPECT_THAT(GetId(rpcServerBinder), HasValue(id)); // Occupy the server thread. The server should still have enough threads to handle // Occupy the server thread. The server should still have enough threads to handle // other connections. // other connections. Loading