summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/tests/gl_unittests.cc
blob: 1a45349e012c4cca368dd96c4d1cf6b98fb14a47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2012 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 <GLES2/gl2.h>

#include "gpu/command_buffer/tests/gl_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace gpu {

class GLTest : public testing::Test {
 protected:
  virtual void SetUp() {
    gl_.Initialize(gfx::Size(4, 4));
  }

  virtual void TearDown() {
    gl_.Destroy();
  }

  GLManager gl_;
};

// Test that GL is at least minimally working.
TEST_F(GLTest, Basic) {
  glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
  glClear(GL_COLOR_BUFFER_BIT);
  uint8 pixels[4] = { 0, };
  glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
  EXPECT_EQ(0u, pixels[0]);
  EXPECT_EQ(255u, pixels[1]);
  EXPECT_EQ(0u, pixels[2]);
  EXPECT_EQ(255u, pixels[3]);
}

}  // namespace gpu