Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / gpu / command_buffer / tests / gl_chromium_path_rendering_unittest.cc
blob0d17b7c6f3bd3575a36ed59411ea580530415e10
1 // Copyright (c) 2012 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.
5 #include <GLES2/gl2.h>
6 #include <GLES2/gl2ext.h>
7 #include <GLES2/gl2extchromium.h>
8 #include <cmath>
10 #include "gpu/command_buffer/tests/gl_manager.h"
11 #include "gpu/command_buffer/tests/gl_test_utils.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h"
15 namespace gpu {
17 class CHROMIUMPathRenderingTest : public testing::Test {
18 public:
19 static const GLsizei kResolution = 100;
21 protected:
22 void SetUp() override {
23 GLManager::Options options;
24 options.size = gfx::Size(kResolution, kResolution);
25 gl_.Initialize(options);
28 void TearDown() override { gl_.Destroy(); }
30 void ExpectEqualMatrix(const GLfloat* expected, const GLfloat* actual) {
31 for (size_t i = 0; i < 16; ++i) {
32 EXPECT_EQ(expected[i], actual[i]);
35 void ExpectEqualMatrix(const GLfloat* expected, const GLint* actual) {
36 for (size_t i = 0; i < 16; ++i) {
37 EXPECT_EQ(static_cast<GLint>(round(expected[i])), actual[i]);
40 GLManager gl_;
43 TEST_F(CHROMIUMPathRenderingTest, TestMatrix) {
44 if (!GLTestHelper::HasExtension("GL_CHROMIUM_path_rendering")) {
45 return;
47 static const GLfloat kIdentityMatrix[16] = {
48 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
49 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
50 static const GLfloat kSeqMatrix[16] = {
51 0.5f, -0.5f, -0.1f, -0.8f, 4.4f, 5.5f, 6.6f, 7.7f,
52 8.8f, 9.9f, 10.11f, 11.22f, 12.33f, 13.44f, 14.55f, 15.66f};
53 static const GLenum kMatrixModes[] = {GL_PATH_MODELVIEW_CHROMIUM,
54 GL_PATH_PROJECTION_CHROMIUM};
55 static const GLenum kGetMatrixModes[] = {GL_PATH_MODELVIEW_MATRIX_CHROMIUM,
56 GL_PATH_PROJECTION_MATRIX_CHROMIUM};
58 for (size_t i = 0; i < arraysize(kMatrixModes); ++i) {
59 GLfloat mf[16];
60 GLint mi[16];
61 memset(mf, 0, sizeof(mf));
62 memset(mi, 0, sizeof(mi));
63 glGetFloatv(kGetMatrixModes[i], mf);
64 glGetIntegerv(kGetMatrixModes[i], mi);
65 ExpectEqualMatrix(kIdentityMatrix, mf);
66 ExpectEqualMatrix(kIdentityMatrix, mi);
68 glMatrixLoadfCHROMIUM(kMatrixModes[i], kSeqMatrix);
69 memset(mf, 0, sizeof(mf));
70 memset(mi, 0, sizeof(mi));
71 glGetFloatv(kGetMatrixModes[i], mf);
72 glGetIntegerv(kGetMatrixModes[i], mi);
73 ExpectEqualMatrix(kSeqMatrix, mf);
74 ExpectEqualMatrix(kSeqMatrix, mi);
76 glMatrixLoadIdentityCHROMIUM(kMatrixModes[i]);
77 memset(mf, 0, sizeof(mf));
78 memset(mi, 0, sizeof(mi));
79 glGetFloatv(kGetMatrixModes[i], mf);
80 glGetIntegerv(kGetMatrixModes[i], mi);
81 ExpectEqualMatrix(kIdentityMatrix, mf);
82 ExpectEqualMatrix(kIdentityMatrix, mi);
84 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
88 TEST_F(CHROMIUMPathRenderingTest, TestMatrixErrors) {
89 if (!GLTestHelper::HasExtension("GL_CHROMIUM_path_rendering")) {
90 return;
92 GLfloat mf[16];
93 memset(mf, 0, sizeof(mf));
95 // This should fail.
96 glMatrixLoadfCHROMIUM(GL_PATH_MODELVIEW_CHROMIUM - 1, mf);
97 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), glGetError());
99 glMatrixLoadfCHROMIUM(GL_PATH_MODELVIEW_CHROMIUM, mf);
100 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
102 // This should fail.
103 glMatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM + 1);
104 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), glGetError());
106 glMatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM);
107 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
110 } // namespace gpu