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

Commit f9c376ff authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix DummyNativeWindow to respond to new query"

parents e2839ca3 7c8f94b0
Loading
Loading
Loading
Loading
+25 −4
Original line number Original line Diff line number Diff line
@@ -64,15 +64,14 @@ LOCAL_C_INCLUDES := $(includeFiles)
LOCAL_CFLAGS += -DLOG_TAG=\"libdisplay\"
LOCAL_CFLAGS += -DLOG_TAG=\"libdisplay\"
LOCAL_CFLAGS += -DTRACE=0
LOCAL_CFLAGS += -DTRACE=0
LOCAL_CFLAGS += -DATRACE_TAG=ATRACE_TAG_GRAPHICS
LOCAL_CFLAGS += -DATRACE_TAG=ATRACE_TAG_GRAPHICS
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES -g -O0
LOCAL_EXPORT_C_INCLUDE_DIRS := $(includeFiles)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(includeFiles)
LOCAL_SHARED_LIBRARIES := $(sharedLibraries)
LOCAL_SHARED_LIBRARIES := $(sharedLibraries)
LOCAL_STATIC_LIBRARIES := $(staticLibraries)
LOCAL_STATIC_LIBRARIES := $(staticLibraries)
LOCAL_MODULE := libdisplay
LOCAL_MODULE := libdisplay
include $(BUILD_STATIC_LIBRARY)
include $(BUILD_STATIC_LIBRARY)



graphicsAppTestFiles := \
testFiles := \
  tests/graphics_app_tests.cpp
  tests/graphics_app_tests.cpp


include $(CLEAR_VARS)
include $(CLEAR_VARS)
@@ -80,7 +79,7 @@ LOCAL_MODULE := graphics_app_tests
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_TAGS := optional


LOCAL_SRC_FILES := \
LOCAL_SRC_FILES := \
  $(testFiles) \
  $(graphicsAppTestFiles) \


LOCAL_C_INCLUDES := \
LOCAL_C_INCLUDES := \
  $(includeFiles) \
  $(includeFiles) \
@@ -93,3 +92,25 @@ LOCAL_STATIC_LIBRARIES := \
  $(staticLibraries) \
  $(staticLibraries) \


include $(BUILD_NATIVE_TEST)
include $(BUILD_NATIVE_TEST)

dummyNativeWindowTestFiles := \
  tests/dummy_native_window_tests.cpp \

include $(CLEAR_VARS)
LOCAL_MODULE := dummy_native_window_tests
LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := \
  $(dummyNativeWindowTestFiles) \

LOCAL_C_INCLUDES := \
  $(includeFiles) \

LOCAL_SHARED_LIBRARIES := \
  $(sharedLibraries) \

LOCAL_STATIC_LIBRARIES := \
  libdisplay \
  $(staticLibraries) \
include $(BUILD_NATIVE_TEST)
+5 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,11 @@ DummyNativeWindow::DummyNativeWindow() {


int DummyNativeWindow::Query(const ANativeWindow*, int what, int* value) {
int DummyNativeWindow::Query(const ANativeWindow*, int what, int* value) {
  switch (what) {
  switch (what) {
    // This must be 1 in order for eglCreateWindowSurface to not trigger an
    // error
    case NATIVE_WINDOW_IS_VALID:
      *value = 1;
      return NO_ERROR;
    case NATIVE_WINDOW_WIDTH:
    case NATIVE_WINDOW_WIDTH:
    case NATIVE_WINDOW_HEIGHT:
    case NATIVE_WINDOW_HEIGHT:
    case NATIVE_WINDOW_FORMAT:
    case NATIVE_WINDOW_FORMAT:
+64 −0
Original line number Original line Diff line number Diff line
#include <private/dvr/dummy_native_window.h>
#include <gtest/gtest.h>

#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <GLES2/gl2.h>

class DummyNativeWindowTests : public ::testing::Test {
 public:
  EGLDisplay display_;
  bool initialized_;

  DummyNativeWindowTests()
      : display_(nullptr)
      , initialized_(false)
  {
  }

  virtual void SetUp() {
    display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY);

    ASSERT_NE(nullptr, display_);
    initialized_ = eglInitialize(display_, nullptr, nullptr);

    ASSERT_TRUE(initialized_);
  }

  virtual void TearDown() {
    if (display_ && initialized_) {
      eglTerminate(display_);
    }
  }
};

// Test that eglCreateWindowSurface works with DummyNativeWindow
TEST_F(DummyNativeWindowTests, TryCreateEglWindow) {
  EGLint attribs[] = {
      EGL_NONE,
  };

  EGLint num_configs;
  EGLConfig config;
  ASSERT_TRUE(eglChooseConfig(display_, attribs, &config, 1, &num_configs));

  std::unique_ptr<android::dvr::DummyNativeWindow> dummy_window(
      new android::dvr::DummyNativeWindow());

  EGLint context_attribs[] = {
    EGL_NONE,
  };

  EGLSurface surface = eglCreateWindowSurface(display_, config,
                                              dummy_window.get(),
                                              context_attribs);

  EXPECT_NE(nullptr, surface);

  bool destroyed = eglDestroySurface(display_, surface);

  EXPECT_TRUE(destroyed);
}