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

Commit 41d2fdbf authored by Kalle Raita's avatar Kalle Raita Committed by Android (Google) Code Review
Browse files

Merge "Switch from deprecated tempnam to TemporaryFile"

parents df02bffc 454c92e0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ LOCAL_SHARED_LIBRARIES := \
	libbinder \
	libutils \
	libgui \
	libbase \

LOCAL_C_INCLUDES := \
    bionic/libc/private \
+8 −7
Original line number Diff line number Diff line
@@ -21,9 +21,13 @@

#include <utils/Log.h>

#include <android-base/test_utils.h>

#include "egl_cache.h"
#include "egl_display.h"

#include <memory>

namespace android {

class EGLCacheTest : public ::testing::Test {
@@ -79,23 +83,20 @@ protected:

    virtual void SetUp() {
        EGLCacheTest::SetUp();

        char* tn = tempnam("/sdcard", "EGL_test-cache-");
        mFilename = tn;
        free(tn);
        mTempFile.reset(new TemporaryFile());
    }

    virtual void TearDown() {
        unlink(mFilename.string());
        mTempFile.reset(nullptr);
        EGLCacheTest::TearDown();
    }

    String8 mFilename;
    std::unique_ptr<TemporaryFile> mTempFile;
};

TEST_F(EGLCacheSerializationTest, ReinitializedCacheContainsValues) {
    uint8_t buf[4] = { 0xee, 0xee, 0xee, 0xee };
    mCache->setCacheFilename(mFilename);
    mCache->setCacheFilename(&mTempFile->path[0]);
    mCache->initialize(egl_display_t::get(EGL_DEFAULT_DISPLAY));
    mCache->setBlob("abcd", 4, "efgh", 4);
    mCache->terminate();