gl_unittests_android.cc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include <GLES2/gl2.h>
  5. #include <GLES2/gl2ext.h>
  6. #include <android/native_window_jni.h>
  7. #include "base/bind.h"
  8. #include "base/synchronization/waitable_event.h"
  9. #include "gpu/command_buffer/tests/gl_manager.h"
  10. #include "gpu/command_buffer/tests/gl_test_utils.h"
  11. #include "testing/gmock/include/gmock/gmock.h"
  12. #include "testing/gtest/include/gtest/gtest.h"
  13. #include "ui/gfx/native_widget_types.h"
  14. #include "ui/gl/android/surface_texture.h"
  15. #include "ui/gl/gl_surface.h"
  16. #include "ui/gl/gl_utils.h"
  17. #include "ui/gl/init/gl_factory.h"
  18. namespace gpu {
  19. class GLSurfaceTextureTest : public testing::Test {
  20. protected:
  21. void SetUp() override { gl_.Initialize(GLManager::Options()); }
  22. void TearDown() override { gl_.Destroy(); }
  23. GLManager gl_;
  24. };
  25. TEST_F(GLSurfaceTextureTest, SimpleTest) {
  26. // TODO(sievers): Eliminate the need for this by using a client-side
  27. // abstraction for the SurfaceTexture in this test.
  28. GLuint texture = 0xFEEDBEEF;
  29. scoped_refptr<gl::SurfaceTexture> surface_texture(
  30. gl::SurfaceTexture::Create(texture));
  31. gfx::AcceleratedWidget window = surface_texture->CreateSurface();
  32. EXPECT_TRUE(window != nullptr);
  33. scoped_refptr<gl::GLSurface> gl_surface =
  34. gl::init::CreateViewGLSurface(gl::GetDefaultDisplayEGL(), window);
  35. EXPECT_TRUE(gl_surface.get() != nullptr);
  36. gl_.SetSurface(gl_surface.get());
  37. glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
  38. glClear(GL_COLOR_BUFFER_BIT);
  39. // glSwapBuffers();
  40. surface_texture->UpdateTexImage();
  41. GLTestHelper::CheckGLError("no errors", __LINE__);
  42. ANativeWindow_release(window);
  43. }
  44. } // namespace gpu