OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/feature_info.h" | 5 #include "gpu/command_buffer/service/feature_info.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "gpu/command_buffer/service/gpu_service_test.h" | |
11 #include "gpu/command_buffer/service/gpu_switches.h" | 10 #include "gpu/command_buffer/service/gpu_switches.h" |
12 #include "gpu/command_buffer/service/test_helper.h" | 11 #include "gpu/command_buffer/service/test_helper.h" |
13 #include "gpu/command_buffer/service/texture_manager.h" | 12 #include "gpu/command_buffer/service/texture_manager.h" |
14 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 13 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "ui/gl/gl_implementation.h" | 15 #include "ui/gl/gl_implementation.h" |
17 #include "ui/gl/gl_mock.h" | 16 #include "ui/gl/gl_mock.h" |
18 | 17 |
| 18 using ::gfx::MockGLInterface; |
19 using ::testing::_; | 19 using ::testing::_; |
20 using ::testing::DoAll; | 20 using ::testing::DoAll; |
21 using ::testing::HasSubstr; | 21 using ::testing::HasSubstr; |
22 using ::testing::InSequence; | 22 using ::testing::InSequence; |
23 using ::testing::MatcherCast; | 23 using ::testing::MatcherCast; |
24 using ::testing::Not; | 24 using ::testing::Not; |
25 using ::testing::Pointee; | 25 using ::testing::Pointee; |
26 using ::testing::Return; | 26 using ::testing::Return; |
27 using ::testing::SetArrayArgument; | 27 using ::testing::SetArrayArgument; |
28 using ::testing::SetArgumentPointee; | 28 using ::testing::SetArgumentPointee; |
29 using ::testing::StrEq; | 29 using ::testing::StrEq; |
| 30 using ::testing::StrictMock; |
30 | 31 |
31 namespace gpu { | 32 namespace gpu { |
32 namespace gles2 { | 33 namespace gles2 { |
33 | 34 |
34 namespace { | 35 namespace { |
35 const char kGLRendererStringANGLE[] = "ANGLE (some renderer)"; | 36 const char kGLRendererStringANGLE[] = "ANGLE (some renderer)"; |
36 } // anonymous namespace | 37 } // anonymous namespace |
37 | 38 |
38 class FeatureInfoTest : public GpuServiceTest { | 39 class FeatureInfoTest : public testing::Test { |
39 public: | 40 public: |
40 FeatureInfoTest() { | 41 FeatureInfoTest() { |
41 } | 42 } |
42 | 43 |
43 void SetupInitExpectations(const char* extensions) { | 44 void SetupInitExpectations(const char* extensions) { |
44 SetupInitExpectationsWithGLVersion(extensions, "", ""); | 45 SetupInitExpectationsWithGLVersion(extensions, "", ""); |
45 } | 46 } |
46 | 47 |
47 void SetupInitExpectationsWithGLVersion( | 48 void SetupInitExpectationsWithGLVersion( |
48 const char* extensions, const char* renderer, const char* version) { | 49 const char* extensions, const char* renderer, const char* version) { |
(...skipping 13 matching lines...) Expand all Loading... |
62 gl_.get(), extensions, "", ""); | 63 gl_.get(), extensions, "", ""); |
63 info_ = new FeatureInfo(command_line); | 64 info_ = new FeatureInfo(command_line); |
64 info_->Initialize(); | 65 info_->Initialize(); |
65 } | 66 } |
66 | 67 |
67 void SetupWithoutInit() { | 68 void SetupWithoutInit() { |
68 info_ = new FeatureInfo(); | 69 info_ = new FeatureInfo(); |
69 } | 70 } |
70 | 71 |
71 protected: | 72 protected: |
| 73 virtual void SetUp() { |
| 74 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); |
| 75 ::gfx::MockGLInterface::SetGLInterface(gl_.get()); |
| 76 } |
| 77 |
72 virtual void TearDown() { | 78 virtual void TearDown() { |
73 info_ = NULL; | 79 info_ = NULL; |
74 GpuServiceTest::TearDown(); | 80 ::gfx::MockGLInterface::SetGLInterface(NULL); |
| 81 gl_.reset(); |
75 } | 82 } |
76 | 83 |
| 84 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; |
77 scoped_refptr<FeatureInfo> info_; | 85 scoped_refptr<FeatureInfo> info_; |
78 }; | 86 }; |
79 | 87 |
80 namespace { | 88 namespace { |
81 | 89 |
82 struct FormatInfo { | 90 struct FormatInfo { |
83 GLenum format; | 91 GLenum format; |
84 const GLenum* types; | 92 const GLenum* types; |
85 size_t count; | 93 size_t count; |
86 }; | 94 }; |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 base::IntToString(gpu::MAX_TEXTURE_SIZE_LIMIT_4096)); | 1046 base::IntToString(gpu::MAX_TEXTURE_SIZE_LIMIT_4096)); |
1039 // Workarounds should get parsed without the need for a context. | 1047 // Workarounds should get parsed without the need for a context. |
1040 SetupWithCommandLine(command_line); | 1048 SetupWithCommandLine(command_line); |
1041 EXPECT_TRUE(info_->workarounds().exit_on_context_lost); | 1049 EXPECT_TRUE(info_->workarounds().exit_on_context_lost); |
1042 EXPECT_EQ(1024, info_->workarounds().max_cube_map_texture_size); | 1050 EXPECT_EQ(1024, info_->workarounds().max_cube_map_texture_size); |
1043 EXPECT_EQ(4096, info_->workarounds().max_texture_size); | 1051 EXPECT_EQ(4096, info_->workarounds().max_texture_size); |
1044 } | 1052 } |
1045 | 1053 |
1046 } // namespace gles2 | 1054 } // namespace gles2 |
1047 } // namespace gpu | 1055 } // namespace gpu |
OLD | NEW |