Factor out a BluetoothChannelMac base class and a BluetoothRfcommChannelMac subclass.
[chromium-blink-merge.git] / cc / test / test_web_graphics_context_3d_unittest.cc
blob107f15ca3465e59de396b0c2c340be6611552b74
1 // Copyright 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.
5 #include "base/memory/scoped_ptr.h"
6 #include "cc/test/test_web_graphics_context_3d.h"
7 #include "gpu/GLES2/gl2extchromium.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/khronos/GLES2/gl2ext.h"
12 namespace cc {
13 namespace {
15 static bool check_parameter_value(TestWebGraphicsContext3D* context,
16 GLenum pname,
17 GLint expected_value) {
18 GLint actual_value = 0;
19 context->getTexParameteriv(GL_TEXTURE_2D, pname, &actual_value);
20 return expected_value == actual_value;
23 static void expect_default_parameter_values(TestWebGraphicsContext3D* context) {
24 EXPECT_TRUE(check_parameter_value(context, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
25 EXPECT_TRUE(check_parameter_value(
26 context, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR));
27 EXPECT_TRUE(check_parameter_value(context, GL_TEXTURE_WRAP_S, GL_REPEAT));
28 EXPECT_TRUE(check_parameter_value(context, GL_TEXTURE_WRAP_T, GL_REPEAT));
29 EXPECT_TRUE(check_parameter_value(
30 context, GL_TEXTURE_POOL_CHROMIUM, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM));
31 EXPECT_TRUE(check_parameter_value(context, GL_TEXTURE_USAGE_ANGLE, GL_NONE));
34 TEST(TestWebGraphicsContext3DTest, GetDefaultTextureParameterValues) {
35 scoped_ptr<TestWebGraphicsContext3D> context(
36 TestWebGraphicsContext3D::Create());
38 GLuint texture = context->createTexture();
39 context->bindTexture(GL_TEXTURE_2D, texture);
41 expect_default_parameter_values(context.get());
44 TEST(TestWebGraphicsContext3DTest, SetAndGetTextureParameter) {
45 scoped_ptr<TestWebGraphicsContext3D> context(
46 TestWebGraphicsContext3D::Create());
48 GLuint texture = context->createTexture();
49 context->bindTexture(GL_TEXTURE_2D, texture);
50 context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
52 EXPECT_TRUE(
53 check_parameter_value(context.get(), GL_TEXTURE_MIN_FILTER, GL_NEAREST));
56 TEST(TestWebGraphicsContext3DTest,
57 SetAndGetMultipleTextureParametersOnMultipleTextures) {
58 scoped_ptr<TestWebGraphicsContext3D> context(
59 TestWebGraphicsContext3D::Create());
61 // Set and get non-default texture parameters on the first texture.
62 GLuint first_texture = context->createTexture();
63 context->bindTexture(GL_TEXTURE_2D, first_texture);
64 context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
65 context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
67 EXPECT_TRUE(
68 check_parameter_value(context.get(), GL_TEXTURE_MIN_FILTER, GL_LINEAR));
69 EXPECT_TRUE(
70 check_parameter_value(context.get(), GL_TEXTURE_MAG_FILTER, GL_NEAREST));
72 // Set and get different, non-default texture parameters on the second
73 // texture.
74 GLuint second_texture = context->createTexture();
75 context->bindTexture(GL_TEXTURE_2D, second_texture);
76 context->texParameteri(
77 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
78 context->texParameteri(
79 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
81 EXPECT_TRUE(check_parameter_value(
82 context.get(), GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST));
83 EXPECT_TRUE(check_parameter_value(
84 context.get(), GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR));
86 // Get texture parameters on the first texture and verify they are still
87 // intact.
88 context->bindTexture(GL_TEXTURE_2D, first_texture);
90 EXPECT_TRUE(
91 check_parameter_value(context.get(), GL_TEXTURE_MIN_FILTER, GL_LINEAR));
92 EXPECT_TRUE(
93 check_parameter_value(context.get(), GL_TEXTURE_MAG_FILTER, GL_NEAREST));
96 } // namespace
97 } // namespace cc