1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 #include <GLES2/gl2ext.h>
8 #include <android/native_window_jni.h>
10 #include "base/bind.h"
11 #include "base/logging.h"
12 #include "base/synchronization/waitable_event.h"
13 #include "gpu/command_buffer/tests/gl_manager.h"
14 #include "gpu/command_buffer/tests/gl_test_utils.h"
15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "ui/gfx/native_widget_types.h"
18 #include "ui/gl/android/surface_texture.h"
19 #include "ui/gl/gl_surface.h"
23 class GLSurfaceTextureTest
: public testing::Test
{
25 virtual void SetUp() OVERRIDE
{
26 gl_
.Initialize(GLManager::Options());
29 virtual void TearDown() OVERRIDE
{
36 TEST_F(GLSurfaceTextureTest
, SimpleTest
) {
37 // TODO(sievers): Eliminate the need for this by using a client-side
38 // abstraction for the SurfaceTexture in this test.
39 GLuint texture
= 0xFEEDBEEF;
41 scoped_refptr
<gfx::SurfaceTexture
> surface_texture(
42 gfx::SurfaceTexture::Create(texture
));
43 gfx::AcceleratedWidget window
= surface_texture
->CreateSurface();
44 EXPECT_TRUE(window
!= NULL
);
46 scoped_refptr
<gfx::GLSurface
> gl_surface
=
47 gfx::GLSurface::CreateViewGLSurface(window
);
48 EXPECT_TRUE(gl_surface
.get() != NULL
);
50 gl_
.SetSurface(gl_surface
.get());
52 glClearColor(0.0f
, 1.0f
, 0.0f
, 1.0f
);
53 glClear(GL_COLOR_BUFFER_BIT
);
56 surface_texture
->UpdateTexImage();
58 GLTestHelper::CheckGLError("no errors", __LINE__
);
60 ANativeWindow_release(window
);