| Index: ui/gl/gl_image_surface_texture_unittest.cc
|
| diff --git a/ui/gl/gl_image_surface_texture_unittest.cc b/ui/gl/gl_image_surface_texture_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..bffc55e1911a2f9b583f36d457b33f7c605a3be0
|
| --- /dev/null
|
| +++ b/ui/gl/gl_image_surface_texture_unittest.cc
|
| @@ -0,0 +1,61 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include <android/native_window.h>
|
| +#include <android/native_window_jni.h>
|
| +
|
| +#include "base/android/jni_android.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/gfx/buffer_format_util.h"
|
| +#include "ui/gl/android/scoped_java_surface.h"
|
| +#include "ui/gl/android/surface_texture.h"
|
| +#include "ui/gl/gl_image_surface_texture.h"
|
| +#include "ui/gl/test/gl_image_test_template.h"
|
| +
|
| +namespace gfx {
|
| +namespace {
|
| +
|
| +class GLImageSurfaceTextureTestDelegate {
|
| + public:
|
| + scoped_refptr<gl::GLImage> CreateSolidColorImage(
|
| + const Size& size,
|
| + const uint8_t color[4]) const {
|
| + scoped_refptr<gl::GLImageSurfaceTexture> image(
|
| + new gl::GLImageSurfaceTexture(size));
|
| +
|
| + GLuint texture_id = 0;
|
| + glGenTextures(1, &texture_id);
|
| + scoped_refptr<gfx::SurfaceTexture> surface_texture =
|
| + gfx::SurfaceTexture::Create(texture_id);
|
| + gfx::ScopedJavaSurface surface(surface_texture.get());
|
| + JNIEnv* env = base::android::AttachCurrentThread();
|
| + ANativeWindow* native_window =
|
| + ANativeWindow_fromSurface(env, surface.j_surface().obj());
|
| + ANativeWindow_setBuffersGeometry(native_window, size.width(), size.height(),
|
| + WINDOW_FORMAT_RGBA_8888);
|
| + ANativeWindow_Buffer buffer;
|
| + bool rv = ANativeWindow_lock(native_window, &buffer, nullptr);
|
| + EXPECT_TRUE(rv);
|
| + GLImageTestSupport::SetBufferDataToColor(
|
| + size.width(), size.height(), buffer.stride * 4, 0,
|
| + BufferFormat::RGBA_8888, color, static_cast<uint8_t*>(buffer.bits));
|
| + ANativeWindow_unlockAndPost(native_window);
|
| +
|
| + rv = image->Initialize(surface_texture.get());
|
| + EXPECT_TRUE(rv);
|
| +
|
| + return image;
|
| + }
|
| +};
|
| +
|
| +INSTANTIATE_TYPED_TEST_CASE_P(GLImageSurfaceTexture,
|
| + GLImageTest,
|
| + GLImageSurfaceTextureTestDelegate);
|
| +
|
| +INSTANTIATE_TYPED_TEST_CASE_P(GLImageSurfaceTexture,
|
| + GLImageCopyTest,
|
| + GLImageSurfaceTextureTestDelegate);
|
| +
|
| +} // namespace
|
| +} // namespace gfx
|
|
|