diff options
Diffstat (limited to 'libs/surfaceflinger_client/tests')
4 files changed, 0 insertions, 495 deletions
diff --git a/libs/surfaceflinger_client/tests/Android.mk b/libs/surfaceflinger_client/tests/Android.mk deleted file mode 100644 index 212b8e7..0000000 --- a/libs/surfaceflinger_client/tests/Android.mk +++ /dev/null @@ -1,53 +0,0 @@ -# Build the unit tests. -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -ifneq ($(TARGET_SIMULATOR),true) - -# Build the unit tests. -test_src_files := \ - Surface_test.cpp \ - -shared_libraries := \ - libcutils \ - libutils \ - libbinder \ - libsurfaceflinger_client \ - libstlport \ - -static_libraries := \ - libgtest \ - libgtest_main \ - -c_includes := \ - bionic \ - bionic/libstdc++/include \ - external/gtest/include \ - external/stlport/stlport \ - -module_tags := tests - -$(foreach file,$(test_src_files), \ - $(eval include $(CLEAR_VARS)) \ - $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \ - $(eval LOCAL_STATIC_LIBRARIES := $(static_libraries)) \ - $(eval LOCAL_C_INCLUDES := $(c_includes)) \ - $(eval LOCAL_SRC_FILES := $(file)) \ - $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \ - $(eval LOCAL_MODULE_TAGS := $(module_tags)) \ - $(eval include $(BUILD_EXECUTABLE)) \ -) - -# Build the manual test programs. -include $(call all-subdir-makefiles) - -endif - -# Include subdirectory makefiles -# ============================================================ - -# If we're building with ONE_SHOT_MAKEFILE (mm, mmm), then what the framework -# team really wants is to build the stuff defined by this makefile. -ifeq (,$(ONE_SHOT_MAKEFILE)) -include $(call first-makefiles-under,$(LOCAL_PATH)) -endif diff --git a/libs/surfaceflinger_client/tests/SharedBufferStack/Android.mk b/libs/surfaceflinger_client/tests/SharedBufferStack/Android.mk deleted file mode 100644 index d3dfe04..0000000 --- a/libs/surfaceflinger_client/tests/SharedBufferStack/Android.mk +++ /dev/null @@ -1,17 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - SharedBufferStackTest.cpp - -LOCAL_SHARED_LIBRARIES := \ - libcutils \ - libutils \ - libui \ - libsurfaceflinger_client - -LOCAL_MODULE:= test-sharedbufferstack - -LOCAL_MODULE_TAGS := tests - -include $(BUILD_EXECUTABLE) diff --git a/libs/surfaceflinger_client/tests/SharedBufferStack/SharedBufferStackTest.cpp b/libs/surfaceflinger_client/tests/SharedBufferStack/SharedBufferStackTest.cpp deleted file mode 100644 index 7ef5926..0000000 --- a/libs/surfaceflinger_client/tests/SharedBufferStack/SharedBufferStackTest.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#undef NDEBUG - -#include <assert.h> -#include <cutils/memory.h> -#include <cutils/log.h> -#include <utils/Errors.h> -#include <private/surfaceflinger/SharedBufferStack.h> - -using namespace android; - -void log(const char* prefix, int *b, size_t num); -void test0(SharedBufferServer& s, SharedBufferClient& c, size_t num, int* list); - -// ---------------------------------------------------------------------------- - -int main(int argc, char** argv) -{ - SharedClient client; - sp<SharedBufferServer> ps(new SharedBufferServer(&client, 0, 4, 0)); - SharedBufferServer& s(*ps); - SharedBufferClient c(&client, 0, 4, 0); - - printf("basic test 0\n"); - int list0[4] = {0, 1, 2, 3}; - test0(s, c, 4, list0); - - printf("basic test 1\n"); - int list1[4] = {2, 1, 0, 3}; - test0(s, c, 4, list1); - - int b = c.dequeue(); - c.lock(b); - c.queue(b); - s.retireAndLock(); - - printf("basic test 2\n"); - int list2[4] = {1, 2, 3, 0}; - test0(s, c, 4, list2); - - - printf("resize test\n"); - class SetBufferCountIPC : public SharedBufferClient::SetBufferCountCallback { - SharedBufferServer& s; - virtual status_t operator()(int bufferCount) const { - return s.resize(bufferCount); - } - public: - SetBufferCountIPC(SharedBufferServer& s) : s(s) { } - } resize(s); - - c.setBufferCount(6, resize); - int list3[6] = {3, 2, 1, 4, 5, 0}; - test0(s, c, 6, list3); - - c.setBufferCount(4, resize); - int list4[4] = {1, 2, 3, 0}; - test0(s, c, 4, list4); - - return 0; -} - -void log(const char* prefix, int *b, size_t num) -{ - printf("%s: ", prefix); - for (size_t i=0 ; i<num ; i++) { - printf("%d ", b[i]); - } - printf("\n"); -} - -// ---------------------------------------------------------------------------- - -void test0( - SharedBufferServer& s, - SharedBufferClient& c, - size_t num, - int* list) -{ - status_t err; - int b[num], u[num], r[num]; - - for (size_t i=0 ; i<num ; i++) { - b[i] = c.dequeue(); - assert(b[i]==list[i]); - } - log("DQ", b, num); - - for (size_t i=0 ; i<num-1 ; i++) { - err = c.lock(b[i]); - assert(err==0); - } - log("LK", b, num-1); - - for (size_t i=0 ; i<num-1 ; i++) { - err = c.queue(b[i]); - assert(err==0); - } - log(" Q", b, num-1); - - - for (size_t i=0 ; i<num-1 ; i++) { - r[i] = s.retireAndLock(); - assert(r[i]==list[i]); - err = s.unlock(r[i]); - assert(err == 0); - } - log("RT", r, num-1); - - err = c.lock(b[num-1]); - assert(err == 0); - log("LK", b+num-1, 1); - - err = c.queue(b[num-1]); - assert(err == 0); - log(" Q", b+num-1, 1); - - r[num-1] = s.retireAndLock(); - assert(r[num-1]==list[num-1]); - err = s.unlock(r[num-1]); - assert(err == 0); - log("RT", r+num-1, 1); - - // ------------------------------------ - printf("\n"); - - for (size_t i=0 ; i<num ; i++) { - b[i] = c.dequeue(); - assert(b[i]==list[i]); - } - log("DQ", b, num); - - for (size_t i=0 ; i<num-1 ; i++) { - err = c.lock(b[i]); - assert(err==0); - } - log("LK", b, num-1); - - for (size_t i=0 ; i<num-1 ; i++) { - u[i] = b[num-2-i]; - } - u[num-1] = b[num-1]; - - for (size_t i=0 ; i<num-1 ; i++) { - err = c.queue(u[i]); - assert(err==0); - } - log(" Q", u, num-1); - - for (size_t i=0 ; i<num-1 ; i++) { - r[i] = s.retireAndLock(); - assert(r[i]==u[i]); - err = s.unlock(r[i]); - assert(err == 0); - } - log("RT", r, num-1); - - err = c.lock(b[num-1]); - assert(err == 0); - log("LK", b+num-1, 1); - - err = c.queue(b[num-1]); - assert(err == 0); - log(" Q", b+num-1, 1); - - r[num-1] = s.retireAndLock(); - assert(r[num-1]==list[num-1]); - err = s.unlock(r[num-1]); - assert(err == 0); - log("RT", r+num-1, 1); - - // ------------------------------------ - printf("\n"); - - for (size_t i=0 ; i<num ; i++) { - b[i] = c.dequeue(); - assert(b[i]==u[i]); - } - log("DQ", b, num); - - for (size_t i=0 ; i<num-1 ; i++) { - err = c.lock(b[i]); - assert(err==0); - } - log("LK", b, num-1); - - for (size_t i=0 ; i<num-1 ; i++) { - err = c.queue(b[i]); - assert(err==0); - } - log(" Q", b, num-1); - - for (size_t i=0 ; i<num-1 ; i++) { - r[i] = s.retireAndLock(); - assert(r[i]==u[i]); - err = s.unlock(r[i]); - assert(err == 0); - } - log("RT", r, num-1); - - err = c.lock(u[num-1]); - assert(err == 0); - log("LK", u+num-1, 1); - - err = c.queue(u[num-1]); - assert(err == 0); - log(" Q", u+num-1, 1); - - r[num-1] = s.retireAndLock(); - assert(r[num-1]==u[num-1]); - err = s.unlock(r[num-1]); - assert(err == 0); - log("RT", r+num-1, 1); - - // ------------------------------------ - printf("\n"); - - b[0] = c.dequeue(); - assert(b[0]==u[0]); - log("DQ", b, 1); - - c.undoDequeue(b[0]); - assert(err == 0); - log("UDQ", b, 1); - - // ------------------------------------ - printf("\n"); - - for (size_t i=0 ; i<num ; i++) { - b[i] = c.dequeue(); - assert(b[i]==u[i]); - } - log("DQ", b, num); - - for (size_t i=0 ; i<num-1 ; i++) { - err = c.lock(b[i]); - assert(err==0); - } - log("LK", b, num-1); - - for (size_t i=0 ; i<num-1 ; i++) { - err = c.queue(b[i]); - assert(err==0); - } - log(" Q", b, num-1); - - for (size_t i=0 ; i<num-1 ; i++) { - r[i] = s.retireAndLock(); - assert(r[i]==u[i]); - err = s.unlock(r[i]); - assert(err == 0); - } - log("RT", r, num-1); - - err = c.lock(u[num-1]); - assert(err == 0); - log("LK", u+num-1, 1); - - err = c.queue(u[num-1]); - assert(err == 0); - log(" Q", u+num-1, 1); - - r[num-1] = s.retireAndLock(); - assert(r[num-1]==u[num-1]); - err = s.unlock(r[num-1]); - assert(err == 0); - log("RT", r+num-1, 1); - printf("\n"); -} diff --git a/libs/surfaceflinger_client/tests/Surface_test.cpp b/libs/surfaceflinger_client/tests/Surface_test.cpp deleted file mode 100644 index fd07479..0000000 --- a/libs/surfaceflinger_client/tests/Surface_test.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <gtest/gtest.h> - -#include <binder/IMemory.h> -#include <surfaceflinger/ISurfaceComposer.h> -#include <surfaceflinger/Surface.h> -#include <surfaceflinger/SurfaceComposerClient.h> -#include <utils/String8.h> - -namespace android { - -class SurfaceTest : public ::testing::Test { -protected: - virtual void SetUp() { - mComposerClient = new SurfaceComposerClient; - ASSERT_EQ(NO_ERROR, mComposerClient->initCheck()); - - mSurfaceControl = mComposerClient->createSurface(getpid(), - String8("Test Surface"), 0, 32, 32, PIXEL_FORMAT_RGB_888, 0); - - ASSERT_TRUE(mSurfaceControl != NULL); - ASSERT_TRUE(mSurfaceControl->isValid()); - - ASSERT_EQ(NO_ERROR, mComposerClient->openTransaction()); - ASSERT_EQ(NO_ERROR, mSurfaceControl->setLayer(30000)); - ASSERT_EQ(NO_ERROR, mSurfaceControl->show()); - ASSERT_EQ(NO_ERROR, mComposerClient->closeTransaction()); - - mSurface = mSurfaceControl->getSurface(); - ASSERT_TRUE(mSurface != NULL); - } - - virtual void TearDown() { - mComposerClient->dispose(); - } - - sp<Surface> mSurface; - sp<SurfaceComposerClient> mComposerClient; - sp<SurfaceControl> mSurfaceControl; -}; - -TEST_F(SurfaceTest, QueuesToWindowComposerIsTrueWhenVisible) { - sp<ANativeWindow> anw(mSurface); - int result = -123; - int err = anw->query(anw.get(), NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER, - &result); - EXPECT_EQ(NO_ERROR, err); - EXPECT_EQ(1, result); -} - -TEST_F(SurfaceTest, QueuesToWindowComposerIsTrueWhenPurgatorized) { - mSurfaceControl.clear(); - - sp<ANativeWindow> anw(mSurface); - int result = -123; - int err = anw->query(anw.get(), NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER, - &result); - EXPECT_EQ(NO_ERROR, err); - EXPECT_EQ(1, result); -} - -// This test probably doesn't belong here. -TEST_F(SurfaceTest, ScreenshotsOfProtectedBuffersFail) { - sp<ANativeWindow> anw(mSurface); - - // Verify the screenshot works with no protected buffers. - sp<IMemoryHeap> heap; - uint32_t w=0, h=0; - PixelFormat fmt=0; - sp<ISurfaceComposer> sf(ComposerService::getComposerService()); - ASSERT_EQ(NO_ERROR, sf->captureScreen(0, &heap, &w, &h, &fmt, 64, 64, 0, - 40000)); - ASSERT_TRUE(heap != NULL); - - // Set the PROTECTED usage bit and verify that the screenshot fails. Note - // that we need to dequeue a buffer in order for it to actually get - // allocated in SurfaceFlinger. - ASSERT_EQ(NO_ERROR, native_window_set_usage(anw.get(), - GRALLOC_USAGE_PROTECTED)); - ASSERT_EQ(NO_ERROR, native_window_set_buffer_count(anw.get(), 3)); - android_native_buffer_t* buf = 0; - for (int i = 0; i < 4; i++) { - // Loop to make sure SurfaceFlinger has retired a protected buffer. - ASSERT_EQ(NO_ERROR, anw->dequeueBuffer(anw.get(), &buf)); - ASSERT_EQ(NO_ERROR, anw->lockBuffer(anw.get(), buf)); - ASSERT_EQ(NO_ERROR, anw->queueBuffer(anw.get(), buf)); - } - heap = 0; - w = h = fmt = 0; - ASSERT_EQ(INVALID_OPERATION, sf->captureScreen(0, &heap, &w, &h, &fmt, - 64, 64, 0, 40000)); - ASSERT_TRUE(heap == NULL); - - // XXX: This should not be needed, but it seems that the new buffers don't - // correctly show up after the upcoming dequeue/lock/queue loop without it. - // We should look into this at some point. - ASSERT_EQ(NO_ERROR, native_window_set_buffer_count(anw.get(), 3)); - - // Un-set the PROTECTED usage bit and verify that the screenshot works - // again. Note that we have to change the buffers geometry to ensure that - // the buffers get reallocated, as the new usage bits are a subset of the - // old. - ASSERT_EQ(NO_ERROR, native_window_set_usage(anw.get(), 0)); - ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(anw.get(), 32, 32, 0)); - for (int i = 0; i < 4; i++) { - // Loop to make sure SurfaceFlinger has retired a protected buffer. - ASSERT_EQ(NO_ERROR, anw->dequeueBuffer(anw.get(), &buf)); - ASSERT_EQ(NO_ERROR, anw->lockBuffer(anw.get(), buf)); - ASSERT_EQ(NO_ERROR, anw->queueBuffer(anw.get(), buf)); - } - heap = 0; - w = h = fmt = 0; - ASSERT_EQ(NO_ERROR, sf->captureScreen(0, &heap, &w, &h, &fmt, 64, 64, 0, - 40000)); - ASSERT_TRUE(heap != NULL); -} - -TEST_F(SurfaceTest, ConcreteTypeIsSurface) { - sp<ANativeWindow> anw(mSurface); - int result = -123; - int err = anw->query(anw.get(), NATIVE_WINDOW_CONCRETE_TYPE, &result); - EXPECT_EQ(NO_ERROR, err); - EXPECT_EQ(NATIVE_WINDOW_SURFACE, result); -} - -} |