Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a075095e authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Use result-gmock.h." am: 4511b77d am: 520566dd

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1728614

Change-Id: I5b214bf7486c0dbc418216ae400d809b61556d7c
parents 08b5b274 520566dd
Loading
Loading
Loading
Loading
+5 −12
Original line number Original line Diff line number Diff line
@@ -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>
@@ -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;
@@ -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();
@@ -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) {
@@ -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.
@@ -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.