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.
4
5#include <GLES2/gl2.h>
6#include <GLES2/gl2ext.h>
7
8#include <android/native_window_jni.h>
9
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"
20
21namespace gpu {
22
23class GLSurfaceTextureTest : public testing::Test {
24 protected:
25  virtual void SetUp() OVERRIDE {
26    gl_.Initialize(GLManager::Options());
27  }
28
29  virtual void TearDown() OVERRIDE {
30    gl_.Destroy();
31  }
32
33  GLManager gl_;
34};
35
36TEST_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;
40
41  scoped_refptr<gfx::SurfaceTexture> surface_texture(
42      gfx::SurfaceTexture::Create(texture));
43  gfx::AcceleratedWidget window = surface_texture->CreateSurface();
44  EXPECT_TRUE(window != NULL);
45
46  scoped_refptr<gfx::GLSurface> gl_surface =
47      gfx::GLSurface::CreateViewGLSurface(window);
48  EXPECT_TRUE(gl_surface.get() != NULL);
49
50  gl_.SetSurface(gl_surface.get());
51
52  glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
53  glClear(GL_COLOR_BUFFER_BIT);
54//  glSwapBuffers();
55
56  surface_texture->UpdateTexImage();
57
58  GLTestHelper::CheckGLError("no errors", __LINE__);
59
60  ANativeWindow_release(window);
61}
62
63}  // namespace gpu
64
65